Skip to content

id(web): reject malformed bracketed IPv6 Host authorities #8776

Closed

Description

@dezren39

Evidence

pkgs/id/src/web/security.rs:89-97 handles any authority beginning with [ by returning the text before the first ], without validating the remainder. The loopback host guard at :189-197 then checks only that extracted value against allowed_hosts.

Consequently, Host: [::1]attacker.example is reduced to ::1 and passes the loopback allow-list, even though the authority is malformed and contains trailing host text. The same extraction also accepts malformed bracketed forms if their prefix matches an allow-listed address. Existing tests cover valid [::1]:3000 and ordinary disallowed hosts, but not malformed bracketed authorities (:298-330).

This is a malformed-authority validation gap in the loopback guard. Browser exploitability is limited because browsers generally do not generate this Host value from a normal URL; the guard should nevertheless reject invalid authorities rather than allow a misleading host prefix.

Acceptance criteria

  • Add regression coverage showing malformed bracketed IPv6 Host authorities (including [::1]attacker.example) receive MISDIRECTED_REQUEST on loopback binds.
  • Preserve acceptance of valid [::1] and [::1]:<numeric-port> authorities.
  • Parse/validate the complete bracketed authority before extracting the host; reject unexpected trailing text and malformed bracket/port syntax.

Activity

  1. developing-today commented on Nov 11, 2026

    @developing-today
    Contributor
  2. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  3. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · triaged

    • Agent: queue worker (repo-worker-code), lane code-a
    • Session / ID: task 15033
    • Found via: queue claim
    • Task: Triage of issue id(web): reject malformed bracketed IPv6 Host authorities #8776 — verdict: CONFIRMED by code inspection on current main (e6889a3). host_only in pkgs/id/src/web/security.rs strips [, returns the text before the first ] and never validates the remainder, so Host: [::1]attacker.example reduces to ::1, which is on the loopback allow-list; an unterminated [::1 reduces the same way. Valid controls [::1] and [::1]:3000 are accepted by the existing tests.
    • Triage decision: work kind small-fix (task/small-fix), priority/normal (a real allow-list validation gap, but browsers do not emit this malformed Host value from a normal URL, so browser exploitability is limited — a non-browser client that can set an arbitrary Host header is the realistic caller), effort/s, kind/security.
    • First concrete step: add guarded-router + host_only regression tests for malformed bracketed authorities (trailing text, unterminated bracket, non-numeric/empty port tail), watch them fail, then validate the complete bracketed authority in host_only before extracting the host.
    • Acceptance check: malformed bracketed authorities receive MISDIRECTED_REQUEST (421) on loopback binds; valid [::1] and [::1]:<numeric-port> still pass; the fix stays inside host_only (no Origin-parsing refactor, per the packet scope).
    • Fix routing: the fix is in this packet's scope, so it proceeds in this same claim per the inline-triage rule — no separate follow-on task.
  4. added
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    priority/normalOrdinary priority (the default)
    effort/sSmall: expected under 2 hours of work
    kind/securitySecurity issue or security hardening
    on Nov 11, 2026
  5. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

    • Agent: queue worker (repo-worker-code), lane code-a
    • Session / ID: task 15033
    • Found via: queue claim
    • Task: Triage + fix of issue id(web): reject malformed bracketed IPv6 Host authorities #8776 — outcome fixed_merged. Verdict: the malformed bracketed IPv6 Host bypass was CONFIRMED (reproduced against the real security.rs: [::1]attacker.example received 200 instead of 421, and host_only reduced it to the allow-listed ::1).
    • Fix: PR fix(id-web): reject malformed bracketed IPv6 Host authorities (#8776) #8797 (branch queue/15033-8776-host-bracket-fix), squash-merged as 4eb2399. host_only now validates the complete bracketed authority — only an empty tail or a : + numeric port may follow the closing bracket; malformed authorities (trailing host text, non-numeric/empty port, unterminated bracket) no longer reduce to the bracketed host and are refused with 421. Valid [::1] and [::1]:3000 controls still pass.
    • Tests: regression smoke tests plus two proptest properties for the parser invariant (added for the Codex P1 finding, thread reply 4544361786; Codex re-review on the final head c72d639 completed clean). Because the pkgs/id lib does not compile on main with the web feature (pre-existing, filed as issue pkgs/id: web lib does not compile on main — crate-split visibility left 5 unresolved/private sites in src/web #8795; error set on this branch proven identical to pristine main e6889a3), the security suite was run in a probe harness compiling the real security.rs: 2 new tests red before the fix, 21/21 green after; rustfmt --check on the file clean. PR checks were still pending in the Actions runner stall at merge (none failing); merged under the standing merge criteria.
    • Impact note: browsers do not emit this malformed Host value from a normal URL; the realistic caller is a non-browser client able to set an arbitrary Host header against a loopback-bound id serve. Severity assessed as a genuine allow-list validation gap, priority/normal.
  6. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/sSmall: expected under 2 hours of workkind/securitySecurity issue or security hardeningpriority/normalOrdinary priority (the default)status:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions