Repository navigation
Fix malformed Accept request header according RFC - #55
Merged
g-andrade merged 2 commits intoSep 16, 2026
Merged
Conversation
Media types were joined with semicolons rather than commas. RFC 9110,
section 12.5.1, defines `Accept = #( media-range [ weight ] )`, and the
`#` list construct of section 5.6.1 is comma-delimited by definition; a
semicolon instead introduces the parameters of the preceding media-range.
The resulting value does not parse at all, rather than merely carrying the
wrong meaning: `application/x-gzip` is not a valid `parameter`, having no
`"="` and containing `/`, which is not a `tchar`.
Strict intermediaries reject or flag it: the OWASP Core Rule Set matches
rule 920600 ("Illegal Accept header") on every database download, which
in turn can get the client's address banned by tools layered on the WAF.
Owner
|
Thank you for your contribution! Released in version 2.3.16, pushed to Hex. |
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.
Hi! First of all, thank you for locus - it is a genuinely pleasant library to depend on and it has been quietly doing its job in our deployment for a long time :)
The problem
locus_loader:http_base_request_headers/0joins the acceptable media types with semicolons:which produces
RFC 9110, section 12.5.1 defines
The
#list construct (section 5.6.1) is comma-delimited by definition, and senders MUST generateelement *( OWS "," OWS element ). The semicolon is reserved for parameters of the preceding media-range.The current value does not merely carry the wrong meaning — it does not parse at all.
application/x-gzipcannot be aparameter: it has no"=", and/is not atchar, so it is not even a validparameter-name. Everything after the first semicolon is unparseable against theAcceptgrammar.Why it matters in practice
This is not only a spec technicality. Strict intermediaries reject or flag the header - the OWASP Core Rule Set matches rule 920600 ("Illegal Accept header") on every database download at the default paranoia level. Where an IP-reputation tool such as CrowdSec sits on top of the WAF, the repeated "protocol violation" gets the client's address banned outright. That is painful in containerised deployments, where many replicas share one NAT egress address and the ban takes unrelated traffic down with it — and
no_cachedeployments re-download on every start, so the hits add up quickly.The change
One separator,
"; "→", ". The set of advertised media types and everything else about the request is unchanged. Both remote origins are covered, since{maxmind, _}and{http, _}sharehttp_request_headers/1.Three eunit tests are added alongside the existing ones in
locus_loader: the exact header value, the absence of semicolons, and that the conditional (if-modified-since) request carries the sameAccept. They fail onmasterand pass with the fix.Checks
make check-fast(erlfmt, xref, hank, elvis),make check-slow(dialyzer),make eunit(11 tests) andrebar3 ct --suite locus_remote_sources_SUITE(175 tests, including the local-httpd groups that actually put this header on the wire) all pass on OTP 27.Happy to adjust naming or drop the tests if you would rather keep the diff to the single line :))