Hop-by-hop headers: when a client can make a proxy drop the headers that carry trust

How the Connection header lets a client ask a proxy to strip named headers, why that matters when a backend trusts a header the proxy adds, and how to test and configure proxies so it cannot remove security headers.

Lesson 17 of 69 · 10 min read · practice only with authorization

Diagram

A proxy removing a header on request

Follow the path. One example at a time.

Step 1 of 4

Proxy adds

The edge sets X-Forwarded-For or X-Auth-User for the backend.

Illustration: Proxy adds
# Proxy adds
# The edge sets X-Forwarded-For or X-Auth-User for the
# backend.

The example on the open step is one illustration, or the fix you can paste into an application you own.

What this page is made of

3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.

  1. Fallbacks are the bug

    What fails
    Stripping a header only hurts when the backend treats its absence as permission.
    Who is affected
    Whatever the default identity can reach.
    What you would notice
    Backend code that defaults to an internal or admin context when a header is missing.
    What you change
    Fail closed: missing identity headers mean 401.
  2. Proxy chains differ

    What fails
    Each proxy in a chain may handle Connection differently.
    Who is affected
    Apps behind CDNs, load balancers, and ingress controllers.
    What you would notice
    Behavior that changes when a request goes through a different hop.
    What you change
    Test the full chain and pin proxy versions and settings.
  3. Information leaks too

    What fails
    Removing a header can change caching or routing and reveal internal behavior.
    Who is affected
    Users of shared caches.
    What you would notice
    Different responses when standard headers are listed in Connection.
    What you change
    Normalize Connection at the edge.

Testing in a staging chain

For each header the edge adds, send a request that names it in Connection and compare the response with the normal request. Identical behavior is the goal. Any difference in authentication, caching, or routing is a finding to report with the hop that strips it.

baseline:                       GET /api/me  -> 200 {"user":"ana"}
Connection: close, X-Auth-User  GET /api/me  -> 200 {"user":"service"}  <- backend fell back

Configuration notes

RFC 9110 lets intermediaries remove headers listed in Connection. Configure the edge to set trust headers itself, overwrite any client copies, and not honor client-supplied hop-by-hop lists for headers it manages.

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

A backend treats a missing X-Auth-User as the internal service account. What is the fix?

Sibling techniques

Pages at the same depth, plus a lab and a glossary card for this one.

  1. MapHost header injection: when the server builds links from a header the client choseHow applications use the Host header to build password-reset links, redirects, and cache keys, how a changed Host poisons those, and how to pin the public hostname in configuration.
  1. 01HTTP headers in security testing: which ones the server trusts and which ones protect usersRequest headers that applications wrongly trust (Host, X-Forwarded-For, X-Original-URL, Referer), response headers that protect users (CSP, HSTS, frame-ancestors), and how to audit both with curl and a proxy.

Practice

  1. LabControl benchA failure is described. Choose the control that changes the outcome.