Repository navigation
lab-ops-hub: refuse crawl hosts whose NFKC mapping creates a delimiter (#567) - #570
Merged
Merged
Conversation
#567) _percent_decode_host refused delimiters in the percent-decoded form, but validate_crawl_url then NFKC-mapped the host with no structural re-check: a percent-encoded compatibility character (U+FF0F -> /, U+FF1A -> :, U+FF20 -> @, U+FF05 -> %, U+2100 -> a/c) spliced a delimiter into the returned URL, so the container fetched a host that was never judged — localhost%ef%bc%8fexample.com validated as http://localhost/example.com/. Re-check % # / : ? @ [ \ ] on the fully mapped form (colon exempt only inside a bracketed IPv6 literal) and refuse any mapped delimiter. Tests: Python battery of 14 mapped-delimiter spellings plus the localhost/127.0.0.1/192.168.0.1 + U+FF0F cases, a redirect-handler refusal for a mapped-delimiter target, and a re-parse invariant for accepted percent-encoded URLs (returned URL re-parses to exactly the judged host); TS parity battery in lib.test.ts (Worker already refuses all of these). Ablation: reverting app.py fails the new refusal tests.
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. |
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 3
✨ Finishing Touches
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 |
This was referenced Nov 14, 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.
Fixes #567
Problem
PR #533's decode-and-judge checked host delimiters on the percent-decoded form, but
validate_crawl_urlthen NFKC-mapped the host with no structural re-check. A percent-encoded compatibility character decodes to an innocent codepoint whose NFKC mapping is a delimiter — U+FF0F →/, U+FF1A →:, U+FF20 →@, U+FF03 →#, U+FF1F →?, U+FF3C →\, U+FF3B/U+FF3D →[/], U+FF05 →%, U+2100 →a/c, U+2105 →c/o— and the mapped delimiter was spliced into the returned URL. Reproduced on main87624089:http://localhost%ef%bc%8fexample.com/→ ALLOW, returnedhttp://localhost/example.com/(fetcher connects tolocalhost, never judged)127.0.0.1/192.168.0.1+%ef%bc%8f, and every delimiter case in the issue battery_ValidatingRedirectHandler(rawLocation, no Worker gate).Solution
In
pkgs/lab-ops-hub/container/app.py, after the full mapping pipeline (NFKC → ideographic-dot translation → UTS-46 ignored deletion), re-check the structural characters on the mapped form and refuse any mapped delimiter in% # / : ? @ [ \ ]— including a mapped%, which the decode step guarantees cannot survive and mapping must not reintroduce. A colon is exempt only inside a bracketed IPv6 literal; an unbracketed mapped colon is a delimiter, not an address. This also covers raw (non-percent) hosts as defence in depth.Verification
localhost/127.0.0.1/192.168.0.1+ U+FF0F and the U+2100/U+2105 expansions): all BLOCK in Python, matching the Worker verdicts probed directly againstsrc/lib.ts.%65xample.com,8%2e8%2e8%2e8, U+FF5E→~(exam~ple.com) still ALLOW in both validators; bracketed IPv6, fullwidth public names, port/userinfo substitution intact.192.168.0.1%ef%bc%8ftarget, re-parse invariant (every accepted percent-encoded URL re-parses to exactly the judged host), TS parity battery.app.pyfails the new refusal tests (2 failures); with the fix all pass.ruff format --checkclean on both Python files.Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit