Repository navigation
Reject signed ports in Url::parse - #3233
Silvertree2010 wants to merge 1 commit into
Conversation
Found while testing crates/fetch/src/http.rs:140 (Url::parse) Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Port validation and tests crates/fetch/src/http.rs |
Url::parse checks that port text contains only ASCII digits before parsing. Existing nonzero and u16 range checks remain. Tests cover signed ports in URLs and redirects, and acceptance of port 80. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: echelon, endthestart
Merge Risk: 
Minimal · up to 13849
-
Signed URL ports are rejected as intended, including redirects, without an identified merge-blocking risk.
Security architecture risk: 
Minimal · up to 13849
-
The change rejects signed ports before requests proceed. It preserves existing port limits, redirect protections, and request destinations for URLs that remain valid. No material security risk was found introduced or worsened by this change.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — The changed exposure is limited to rejecting previously accepted signed-port URLs in the inspected fetch path. URLs that remain accepted retain the same host, port, TLS selection, and path; no additional destination or privilege becomes reachable.
Trust Boundaries and Controls
- observed — Redirects that introduce an authority, including absolute and network-path references, re-enter Url::parse. Relative references retain the existing parsed authority, so they cannot introduce signed port text around the new gate.
-
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 1 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
Fixes: none (found while testing
crates/fetch/src/http.rs:140 (Url::parse); no existing issue)Problem
The URL parser accepts a signed port such as
:+80. A URL likehttp://example.com:+80/xis accepted as port 80, and so is a redirectLocationthat goes throughUrl::join.Cause:
Url::parseread the port withp.parse::<u16>(), and Rust's integer parser accepts a leading+.Change
The port text must now be all ASCII digits before it is parsed. Anything else returns
BadUrl("bad port"). BecauseUrl::joincallsUrl::parse, redirects get the same check.Not in this PR: Port range and zero handling are unchanged: 0 and values above 65535 are still rejected. Host validation is unchanged.
How it was checked
cargo xtask cipasses on this branch, rebased on currentmain. Note: it passes exceptaccessibility::every_interactive_node_has_a_name_in_every_view_and_tool, which also fails onmainwithout this change.http::tests::rejects_signed_portsfails onmainwithout the fix and passes with it (cargo test -p lightcraft-fetch rejects_signed_ports)Merging
Checklist
unwrap/expect/panic!, no indexing or unchecked arithmetic on a number from a file, a person or an agent (get,checked_mul, NaN and char boundaries handled)tr()and has its key incrates/ui-egui/locales/*.json; a new shortcut is free indocs/library-shortcuts.mddocs/parity-checklist.mdand its entry indocs/gaps.mdare updated, honestly (🟡 when it is partial), in the same commitassets/ATTRIBUTION.md; no font or media files added🤖 Generated with AI by ApolloOffice, see the Co-Authored-By trailers for the models
Summary by CodeRabbit
+or-sign are now rejected. Valid unsigned ports, including port 80, continue to be accepted.