Repository navigation
fix(id/web): build header subtitle with DOM APIs — filename innerHTML injection (#1457) - #1473
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 37 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Summary
Fixes #1457: the header subtitle built its link with
innerHTMLand interpolated the last-opened document's raw filename (and path) unescaped — a crafted filename became live markup in the app shell (stored XSS, no CSP on the app-shell pages to contain it).Confirmed by triage (queue task 1462) on current main:
main.tsdecoded the server URL-encodeddata-filenameback to the raw name (decodeURIComponent), passed it throughonMainSwapped, and interpolated it at the subtitle sink.Change
updateHeaderSubtitlemoves to a new module,pkgs/id/web/src/header-subtitle.ts, and builds the link with DOM APIs: anchor viacreateElement, filename viatextContent,hrefviasetAttribute,data-navpreserved.hrefis set as an attribute rather than the property so the SPA router'sgetAttribute("href")read (click delegation inmain.ts) keeps the exact path string it has always navigated to; quotes in a path stay inside the attribute value.main.tsimports the helper; the innerHTML interpolation is gone. No server template changes.pkgs/id/web/src/header-subtitle.test.ts(vitest/happy-dom, mirroring thehome.test.tsuntrusted-name pattern), pinning:<img src=x onerror="alert(1)">.mdrenders as literal text in a single anchor — noimgelement;x</a><svg onload=alert(2)>cannot break out — nosvgelement, one anchor, full text;notes.md→ exactly one anchor, correct text andhref, subtitle text// notes.md;hrefattribute (noonmouseoverattribute appears);// p2p file sharingas text.Audit note (acceptance item): the other innerHTML sinks
Per #1457's acceptance criteria, the remaining client-side
innerHTMLassignments inmain.tswere audited:fetchPartialandnavigateToassign response text fetched from the app's own server endpoints (X-Partial-Requestpartials — server-rendered template HTML). They interpolate no client-side values into that markup; document names inside the server templates are html-escaped server-side (templates.rs). These sinks receive server-template HTML only.list.innerHTML = "",container.innerHTML = ""). The subtitle was the sole sink interpolating a client-held untrusted value, and it is the one fixed here.Tests
CI (id workflow) is the verification: the new
header-subtitle.test.tssuite plus the existing web unit suites. Implemented by queue task 1498 (follow-up to triage task 1462).Need help on this PR? Tag
@codesmith-botwith what you need.