fix(handlers): XSS in titles/headlines + URL-encode slugs + RM_BIND fail-fast#14
Merged
Merged
Conversation
…ail-fast Closes the codex items left open across my Phase 0/1 PRs: # P1 — XSS via raw user content in handler-built HTML (#10, #12) `wrap_in_doc(title, body)` interpolated the raw `title` straight into the document's `<title>` element. With user-controlled inputs (issue subjects, time-entry spent_on, project names, user display names) reaching this fn, a payload like `</title><script>alert(1)</script>` is a stored XSS. The `render_detail(..., headline_html, ...)` parameter is contractually pre-rendered HTML (kit `|safe`s it through the template), so handlers that compose it from user data must escape themselves. W1 (Issue), W2 (Project), W3 (TimeEntry), W4a (User), W4b (Role) all did this with raw interpolation. Fix: - `common::html_escape` — minimal `& < > " '` escape, no extra dep. - `wrap_in_doc` escapes its `title` parameter. - Every handler that composes `headline_html` from user data now calls `html_escape` first. - New regression test `detail_escapes_xss_in_subject_for_title_and_headline` in `issues.rs` exercises the full XSS surface. # P2 — URL slug encoding (#13) `/roles/<name>`, `/projects/<identifier>`, `/users/<login>` paths interpolated the slug raw. A name with `#`/`?`/`/` would break the browser's URL parse (`#` = fragment, `/` = path segment). Fix: - `common::encode_path_segment` — percent-encodes everything outside RFC-3986 unreserved + path-safe chars. No new dep (rule is small). - Roles, projects, users all route hrefs through it. - New regression test `list_percent_encodes_role_names_with_reserved_chars` in `roles.rs` (Q/A → Q%2FA, R&D → R%26D). # P1 — RM_BIND fail-fast (#7) `std::env::var("RM_BIND").ok().and_then(|s| s.parse().ok())` collapsed unset and malformed into the same fallback. A typo silently started the server on the default. Now we distinguish: - Unset → default - Malformed → return `io::Error::other(...)` immediately # Skipped - #9 (auth routes not reachable) — already fixed by #10's `build_router_with` refactor that mounts `rm_auth::router(cfg)`. - #8 (lowercase vs PascalCase OGAR table names) — schema- divergence noted in W3's doc, lands in a dedicated PR; needs the per-port DDL emission story W4-followups will revisit. cargo fmt --check + cargo clippy --all-targets -- -D warnings + cargo test --workspace all green locally; 108 tests across 5 crates.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Jun 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes codex items on my Phase 0/1 PRs
<title>+ headline anchorcommon::html_escape+ escape at handler call sitesspent_onin headlinehtml_escapepattern/#?break URL parsecommon::encode_path_segment(RFC-3986)RM_BINDsilently falls back to default#9build_router_with#8XSS — what was broken
wrap_in_doc(title, body)interpolated rawtitlestraight into the document's<title>element. A subject like</title><script>alert(1)</script>reaches it verbatim fromfind_issue(...)?.subject.render_detail(..., headline_html, ...)is contractually pre-rendered HTML (|safein the askama template). W1–W4 handlers all composed it like:Stored XSS. Both paths fixed via the new
html_escape.URL encoding — what was broken
/roles/<role_name>withR&Dbecomes/roles/R&D— the&is a parameter delimiter for some servers;#would terminate at a fragment;/would split into another path segment. Now routed throughencode_path_segment:DoD
common.rs:html_escape,encode_path_segment/projects/:identifier,/roles/:name,/users/:login) now percent-encodeheadline_htmlcomposition escapes user-controlled stringsmain.rsfails fast on malformed RM_BINDAll three CI gates green: fmt + clippy + cargo test --workspace (108 tests across 5 crates).
🤖 Generated with Claude Code