Repository navigation
chrome-nav.js: validate the page path the chrome restore keys on - #2901
Merged
Merged
Conversation
- Hardens the `shared`-mode restore: the canonical-path hint and the request-path fallback both pass one same-origin-path check before any selector href is rebuilt from them; no change for conforming sites - Clears the CodeQL `js/xss-through-dom` alert on the merits (parse and check origin, not encode), closing the hardening filed at the 2026-09-18 triage - Probe in chrome-canonical.test.mjs is red against the previous code; the goldens delta is the bundle fingerprint only
✅ Deploy Preview for docsydocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
- Renames `raw` to `urlOrPath` (what `sameOriginPath` accepts) and `hint` (the canonical-path attribute); bundle bytes unchanged, so no goldens delta
- Drops the one-use local in readCanonicalPath: a falsy input is the helper's null, so the contract reads "anything falsy or unsafe yields null"; goldens follow the bundle
- An origin-inheriting scheme (`blob:`) passes the origin check with a non-path `pathname`, so the guard now requires the leading `/` too (r1.1) - The request-path fallback had no probe of its own: a hint-less page at a canonical and at a protocol-relative request URL, red against main (r1.3); the probe comments keep to input classes and point at the guard (r1.4)
- The guard moves to the sink that composes: `langHome + rel` is parsed and written only when it stays same-origin, so a `//` after the language prefix can't read as a host; the path-shape test goes, the parser decides (r2.1, r2.6) - Resolves against `location.href`, so `file:`-served sites keep their active state (r2.2) - Probes: one hostile hint per check, a foreign-host request path restores the root navbar, the lang fixture gets the `/ja//host/…` case, red on main
- A same-origin parse isn't enough when the pathname is then written as a relative reference: `/.//host/…` drops its dot segment and reads back as a host. The pathname now round-trips through the parser before it's returned (r3.1); the dot-segment hint joins the probes - Declaration comments keep to contracts; the gotchas sit beside their checks (r3.2, r3.3)
- The re-parse compared origins only, so a doubled own-host prefix (`//site//site//host/…`) still came back as `//host/…`; the path must now be a fixed point of the parser (same origin, same pathname), which also retires the `blob:` string test (r4.1) - Probes: double-wrap hints in both files, the `blob:` value pointed at another page, a sanity match before the lang probe strips the hint; red on the previous code (r4.5, r4.6)
…link in the lang probe - The doubled own-host form re-parses to the same origin with a different path, not to another host; the comment says so (r5.1), and the clause restating `if (target)` goes (r5.2) - The lang probe asserts the donor's root link, not a path shape, so a composition that wrote a wrong same-origin page would fail (r5.4)
This was referenced Oct 30, 2026
chalin
added a commit
to chalin/docsy
that referenced
this pull request
Oct 31, 2026
Changelog v0.18.1: credit the contributed tabpane fix (docsy#2869) Changelog v0.18.1: Security line for the chrome-restore hardening (docsy#2901) Link cache: docsy#2869, docsy#2901, docsy#2910 Changelog v0.18.1: the Security line links the chrome guide
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.
js/xss-through-domonmain)currentPath()limited to same-origin paths that re-parse to themselves, whatever thedata-canonical-pathhint or the request URL supplies/<lang>//host/…compositionbase), legitimately cross-originjs/xss-through-domovertheme/assets/js) reports 2 results onmain, both sourced at thedata-canonical-pathread, and 0 on this branch (the repo's default setup doesn't analyze fork PRs, hence the local run)href, so only a parser-produced path passesencodeURIleavesjavascript:intact; string tests miss spellings the parser catches)sameOriginPathintheme/assets/js/chrome-nav.js