Skip to content

Fix ConflictingHeadersException on generic reverse-proxy hosting#16

Open
back-2-95 wants to merge 1 commit into
mainfrom
fix/reverse-proxy-conflicting-headers
Open

Fix ConflictingHeadersException on generic reverse-proxy hosting#16
back-2-95 wants to merge 1 commit into
mainfrom
fix/reverse-proxy-conflicting-headers

Conversation

@back-2-95

Copy link
Copy Markdown
Member

Summary

  • In the generic auto-detect branch of Reader.php (used when no known hosting system is detected, e.g. our own Traefik-fronted UpCloud hosts), reverse_proxy_trusted_headers trusted both Request::HEADER_FORWARDED and the individual Request::HEADER_X_FORWARDED_* headers at the same time.
  • Symfony's Request::getTrustedValues() throws ConflictingHeadersException whenever a request carries both a trusted Forwarded header and a trusted X-Forwarded-* header whose derived values disagree.
  • Traefik (and similar reverse proxies) only ever add X-Forwarded-* headers, never Forwarded. Since Traefik doesn't restrict which client IPs it trusts to set forwarding headers (no forwardedHeaders.trustedIPs), any external client can send its own Forwarded header straight through. Because Drupal trusted both header types, a mismatching client-supplied Forwarded header crashed the request.
  • Found via a production incident on druidfi/reka (PR druidfi/reka#516's deploy is when it started surfacing): ConflictingHeadersException on essentially every request from clients sending a Forwarded header.

Fix

Drop Request::HEADER_FORWARDED from the trusted header bitmask in the auto-detect branch, since it's never actually the header format these proxies use.

Test plan

  • php -l src/Reader.php
  • CI test suite (make test)

The auto-detect branch trusted both the "Forwarded" header and the
individual "X-Forwarded-*" headers at once, which Symfony explicitly
disallows. Proxies like Traefik only send X-Forwarded-*, so any client
sending its own "Forwarded" header straight through the proxy causes
Request::getTrustedValues() to throw when the two disagree. Drop
HEADER_FORWARDED from the trusted set to match what these proxies
actually send.
@back-2-95 back-2-95 added the help wanted Extra attention is needed label Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Development

Successfully merging this pull request may close these issues.

1 participant