Skip to content

http1: reject fragment/backslash in target + duplicate Content-Type (#47 hardening)#57

Merged
EdmondDantes merged 1 commit into
mainfrom
47-hardening-fragment-backslash-dupct
May 29, 2026
Merged

http1: reject fragment/backslash in target + duplicate Content-Type (#47 hardening)#57
EdmondDantes merged 1 commit into
mainfrom
47-hardening-fragment-backslash-dupct

Conversation

@EdmondDantes
Copy link
Copy Markdown
Contributor

Finishes the optional #47 hardening — three request checks that Http11Probe flagged as Warn (200 accepted) but where stricter 400 closes real ambiguity vectors:

  • raw # in request-target (fragment — never sent on the wire, RFC 9112 §3.2) → 400
  • raw \ in request-target (not a URI char, RFC 3986; \/ parsed inconsistently → path confusion) → 400
  • duplicate Content-Type (RFC 9110 §8.3 singleton) → 400 (ct_seen_count)

Percent-encoded %23 / %5C stay legal (200). New h1/021-request-target-hardening. Full tests/phpt 202/202 (validated the whole set, per the version→505 lesson).

Not done — multi-space request-line: llhttp consumes the request-line spacing before our callbacks fire, so it's not detectable post-parse without llhttp-leniency changes (deliberately avoided). That single Warn stays; it's RFC-Should, 200 acceptable.

)

Optional RFC hardening of the request-target and singleton headers — all
were Warn in Http11Probe (200 accepted) but stricter rejection closes
real path-confusion / framing-ambiguity vectors:

- raw '#' in the request-target (fragment, never sent per RFC 9112 §3.2) → 400
- raw '\' in the request-target (not a URI char, RFC 3986; '\' vs '/'
  parsed inconsistently) → 400
- duplicate Content-Type (RFC 9110 §8.3 singleton) → 400 (new ct_seen_count)

Percent-encoded %23 / %5C stay legal. New h1/021. Re-ran the WHOLE
tests/phpt (202/202) — lesson from the version→505 misfire: validate the
full set after a parser change, not one case. Multi-space request-line
is NOT done: llhttp consumes the spaces before our callbacks, so it's
not detectable post-parse without llhttp leniency changes.
@github-actions
Copy link
Copy Markdown
Contributor

Coverage

Total lines: 80.78% → 80.82% (+0.04 pp)

File Baseline Current Δ Touched
src/http1/http_parser.c 82.25% 83.27% +1.02 pp

@EdmondDantes EdmondDantes merged commit ea04f23 into main May 29, 2026
8 checks passed
@EdmondDantes EdmondDantes deleted the 47-hardening-fragment-backslash-dupct branch May 29, 2026 19:30
EdmondDantes added a commit that referenced this pull request May 29, 2026
…n-url

http1: scan request-target in on_url (single pass, follow-up to #57)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant