Repository navigation
fix(web-bot-auth): reject Signature-Agent URIs with an empty host - #163
Conversation
|
@KonstantinMirin Thank you for the contribution! I think this change is safe to make and doesn't affect any users - we at least aren't observing anyone using HTTP for verification. Kindly fix the merge conflicts, and I will merge and include. |
517cbd5 to
41b680b
Compare
|
Rebased onto main and fixed the conflicts. #176 already makes the Rust parser reject |
|
This pull request's reviews are posted as pull request reviews: see the review of |
|
Correction to my earlier comment: #176 does not reject |
41b680b to
c349088
Compare
|
@clanky-the-clanker review |
There was a problem hiding this comment.
Superseded by the review of
1498264f.
This review, of c349088d
✅ Approved — The empty-host rejection is correct and the same in the Rust and TypeScript parsers, and tests in both languages cover it. No defects found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No security issues found. The verifier now rejects https values with no host, which the URL parser would otherwise rewrite to a different URL from the one the signer sent.
📖 AGENTS.md: ✅ LGTM
No issues found.
📋 Code Quality: ✅ LGTM
The Rust names_host check uses uri.get(..8), so it cannot panic on a short value or a multi-byte character, and the TypeScript regex behaves the same way. Values with a ?, @ or : right after https:// are rejected by the URL parse that runs first. Tests in both languages cover http rejection, empty hosts, upper-case HTTPS://, and http members with parameters being ignored.
⚡ Performance: ✅ LGTM
No performance issues found.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: c349088d
|
@thibmeu #177 has merged, so this is ready. I merged |
|
@clanky-the-clanker review |
There was a problem hiding this comment.
⚠️ Out of date: this review is of1498264f; the pull request is now at03af03e7. Someone with write access can commentclanky review(orclanker reviewor@clanky-the-clanker review) to review the new commits.
✅ Approved — Both parsers now check the authority of the value as sent, before URL parsing can repair it. The Rust and TypeScript checks reject the same values, tests cover them, and no defects were found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No security issues found. Both parsers now fail closed on https values with no host. A tab or newline inside the authority would be stripped by the URL parser, but it cannot reach this check: Structured Field strings and the legacy String form carry only printable ASCII.
📖 AGENTS.md: ✅ LGTM
No issues found.
📋 Code Quality: ✅ LGTM
The reworked validate_discovery_uri in Rust and validateDiscoveryURI in TypeScript both check the scheme without regard to case. They then check that the raw authority is not empty, and only after that run the URL parser, so WHATWG normalisation cannot repair a value first.
- Rust and TypeScript agree. Rust splits the value on the first
:. It then takes the authority after//and up to the first/,\,?or#. The TypeScript regex/^https:\/\/[^/\\?#]/irejects the same cases. - A value without a colon cannot panic.
split_once(':').unwrap_or_default()returns two empty strings, so the parser reports "must use https". - Other bad authorities still fail.
https://:443andhttps://user@/xpass the raw check, and the URL parse that follows rejects them. - The new tests are escaped correctly. Both languages test a real
https://\hostvalue. The upper-caseHTTPS://legacy case is still covered, and the URI is kept as sent.
⚡ Performance: ✅ LGTM
No performance issues found.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: 1498264f
RFC 9110 Section 4.2.2 says a recipient that processes an https URI with an empty host MUST reject it as invalid, and draft-ietf-webbotauth-httpsig-protocol-01 Section 5.2.1 requires each member value to be an absolute https URI. Both parsers check the URL that the WHATWG parser returns, and that parser takes a host from "https:///x", "https:x", and "https:\x". The verifier then fetched a different URL from the one the signer sent. Check the value as sent in both parsers: it must start with "https://", in any case, followed by a host. Add matching TypeScript and Rust tests for the Section 5.2.1 rules that had none: an http member is rejected in the dictionary, type=cimd, mixed, and legacy forms; an http member that carries parameters is ignored; and an upper-case https scheme is accepted. A verify() test checks that the resolver is not called for an http member.
Split the raw scheme and authority without byte offsets. Keep focused regression cases and reuse the existing mixed-case legacy coverage.
1498264 to
03af03e
Compare
Revised 2026-11-17: #177 has merged, so this PR now contains only the empty-host change, merged with current
main.draft-ietf-webbotauth-httpsig-protocol-01Section 5.2.1 requires eachSignature-Agentmember value to be an absolute URI "whose scheme MUST be https". RFC 9110 Section 4.2.2 says: "A sender MUST NOT generate an "https" URI with an empty host identifier. A recipient that processes such a URI reference MUST reject it as invalid."After #176 (Rust) and #177 (TypeScript), both parsers check the URL that the WHATWG URL parser returns. That parser takes a host from values that have none, so both parsers accept them, and the verifier fetches a different URL from the one the signer sent:
https:///x.testhttps://x.test/https:x.testhttps://x.test/https:\x.testhttps://x.test/This change checks the value as sent in both parsers: it must start with
https://, in any case, followed by a host. Otherwise the parser raisesSignature-Agent must name a host.It also adds TypeScript and Rust tests for the Section 5.2.1 rules that #176 and #177 implement without tests:
httpmember is rejected in the dictionary form, thetype=cimdform, a header that mixes it with anhttpsmember, and the legacy String form.httpmember that carries parameters is ignored, as "A verifier MUST ignore a member that carries parameters" requires.HTTPS://scheme is accepted, because URI schemes are case-insensitive.verify()does not call the resolver for anhttpmember.Fixes #162 together with #177.
Tests
packages/web-bot-auth: 62 passed. Without the source change, the four empty-host cases fail and the others pass.crates/web-bot-auth: 57 passed, with Rust 1.95 becausesfv0.16 requires it. Without the source change,rejects_https_signature_agent_with_an_empty_hostfails and the others pass. Everytest-ruststep inpullrequest.ymlpasses, including thewasm32-unknown-unknownbuild,clippy -D warnings,rustfmt, andcargo doc.npm run lintis clean, and the other workspaces' tests pass:http-message-sig35,jsonwebkey-thumbprint2, andverification-workers33.Signature-Agentheaders: http and https members, with and without parameters, legacy and dictionary forms, and the empty-host values above.Compatibility
Both parsers now reject a
Signature-Agentvalue such ashttps:///x.testorhttps:x.test. Nothing in the repository's examples, bench fixtures, or test vectors uses one.