//nefariousplan

CVE-2026-41181: Traefik's Patch Added A Test Named `forward all headers by default`. It Passes.

vendor

pattern

cve

proof of concept

The patch for CVE-2026-41181 adds three test cases to Traefik's pkg/middlewares/customerrors/custom_errors_test.go. The first test is named forward all headers by default. It constructs an ErrorPage with no ErrorRequestHeaders field set, sends an inbound request carrying Authorization: Bearer secret, and asserts that the literal string Bearer secret appears in the request the Errors middleware forwards to the configured error-page service. The assertion is assert.Contains, not assert.NotContains. The test passes on the patched build. The default is the bug.

The pre-patch line is one call to CopyHeaders. The patch wrapped it.

In pkg/middlewares/customerrors/custom_errors.go, the pre-patch ServeHTTP builds a fresh pageReq aimed at the error-page service, populates its URL from the operator's query template, and then runs one line that the April 24 fix for CVE-2026-41181 wraps and preserves:

utils.CopyHeaders(pageReq.Header, req.Header)

c.backendHandler.ServeHTTP(newCodeModifier(rw, code),
    pageReq.WithContext(req.Context()))

utils.CopyHeaders is github.com/vulcand/oxy/v2/utils.CopyHeaders. The function is a range over the source http.Header map: for each key, copy the slice of values into the destination. The function has no allowlist, no denylist, and no header-name awareness. Every key on the inbound req.Header map ends up on pageReq.Header. Authorization, Cookie, X-Api-Key, X-Auth-Token, X-Forwarded-User, X-Forwarded-For, and any custom header the operator's earlier middleware put on the request: all of them.

The fix commit for CVE-2026-41181 (0fdea20e, backported to the v2.11.44, v3.6.15, and v3.7.0-rc.3 release branches) does not delete the CopyHeaders call. It wraps it:

-	utils.CopyHeaders(pageReq.Header, req.Header)
+	if c.requestHeaders != nil {
+		for _, header := range c.requestHeaders {
+			if values := req.Header.Values(header); len(values) > 0 {
+				pageReq.Header[http.CanonicalHeaderKey(header)] = values
+			}
+		}
+	} else {
+		utils.CopyHeaders(pageReq.Header, req.Header)
+	}

The new if-branch is a per-header allowlist driven by a slice the operator declares as errorRequestHeaders in dynamic configuration. The else-branch is the original line. The branch the runtime takes is selected by whether c.requestHeaders is nil. The corresponding field, ErrorPage.ErrorRequestHeaders in pkg/config/dynamic/middlewares.go, is nil in every existing dynamic configuration in the world: the field did not exist before this commit. Existing deployments upgrade to the patched binary and run the else-branch on every error response that lands inside the configured status range.

The patch's test asserts Bearer secret is forwarded

The same commit appends three test cases to the table in TestHandler. The first reads:

{
    desc:      "forward all headers by default",
    errorPage: &dynamic.ErrorPage{Service: "error", Query: "/test", Status: []string{"503"}},
    requestHeaders: map[string]string{
        "X-Request-Id":  "trace-abc",
        "Authorization": "Bearer secret",
    },
    backendCode: http.StatusServiceUnavailable,
    backendErrorHandler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintln(w, r.Header.Get("X-Request-Id"))
        fmt.Fprintln(w, r.Header.Get("Authorization"))
    }),
    validate: func(t *testing.T, recorder *httptest.ResponseRecorder) {
        t.Helper()
        assert.Contains(t, recorder.Body.String(), "trace-abc")
        assert.Contains(t, recorder.Body.String(), "Bearer secret")
    },
},

The case constructs an ErrorPage with no ErrorRequestHeaders field. It sends an inbound request carrying Authorization: Bearer secret and X-Request-Id: trace-abc. It writes a backend error handler that echoes both values into the response body, and asserts that both literal strings appear there. assert.Contains(t, ..., "Bearer secret") is the patch author's own statement, in code, of what the patched default does to bearer tokens. The patch did not break the prior behavior. The patch validated the prior behavior with a test that the project's test runner is now required to pass.

The Go struct comment in middlewares.go, added in the same commit, agrees with the test:

// ErrorRequestHeaders defines the list of request headers forwarded to the error page service.
// When nil (not set), all original request headers are forwarded.
// Set to an empty list to forward no headers, or list specific headers to forward only those.
ErrorRequestHeaders []string `json:"errorRequestHeaders,omitempty" ...`

The two remaining test cases added by the patch are named forward only allowlisted headers and forward no headers. The first sets ErrorRequestHeaders: []string{"X-Request-Id"} and asserts assert.NotContains(t, recorder.Body.String(), "Bearer secret"). The second sets ErrorRequestHeaders: []string{} (an empty slice, distinct from nil) and asserts the same. The NotContains assertion lives in the test file. It runs on the two new explicit-allowlist branches. It does not run on the default branch.

The pre-patch docs mentioned one header. The request carried the rest.

The Traefik v3 documentation page for the Errors middleware, in its pre-patch form, contains exactly one admonition about header forwarding. The admonition is keyed "Host Header":

!!! info "Host Header"

    By default, the client `Host` header value is forwarded to the configured error
    service. To forward the `Host` value corresponding to the configured error service
    URL, the passHostHeader option must be set to `false`.

The Host header is the header the page discusses because Host has a configuration knob attached, passHostHeader, that rewrites it. The admonition exists to explain the rewriting. It does not state that the rest of the inbound request's headers travel to the error-page service unchanged. The same page also says, on its second line, The error page itself is _not_ hosted by Traefik. An operator reading the page forms a reasonable model: the middleware sends a status-keyed request to a separate service, and the only inbound-request element the middleware forwards is Host, with documented rewriting subtleties for the operators who need them.

The model is wrong, and the model is the natural read of the page that lived on the documentation site until April 24, 2026. The page enumerates configurable options. Host is in the page only because Host has a configurable option to enumerate. The other headers are absent from the page because there was no knob to discuss, not because they were absent from the wire.

The patched docs say it out loud

The same commit adds a new subsection to errorpages.md, under the heading ### errorRequestHeaders:

Defines the list of original request headers forwarded to the error page service.

By default (errorRequestHeaders not set), all request headers, including authentication
material such as Authorization and Cookie, are forwarded.

If the error page service is in a separate trust domain, use this option to restrict
which headers cross the service boundary.

The sentence beginning By default is the documentation the page should have carried for as long as the unconditional CopyHeaders line had been the codepath. Its placement is the only thing that makes it read as a feature note rather than as a security advisory: a reader sees it under the new option, framed as part of the new feature, rather than as the pre-existing risk the new feature mitigates.

The third sentence acknowledges, in Traefik's own framing, the trust boundary that justifies the option. The error-page service is something a deployment routes to. In Kubernetes deployments, it is a separate Service. In file-config deployments, it is a separate services block. In practice, an error-page service is most often a static file server, a small image with a small surface, sometimes operated by a different team or vendor than the backend that handed Traefik the 5xx in the first place. The patched docs' new sentence answers what it means for the credentials on the inbound request to cross that boundary by default: it should not have been the default to send them.

The migration note states what the patch did not change

The same commit appends to docs/content/migration/v2.md, under the heading ## v2.11.44:

In v2.11.44, a new errorRequestHeaders option has been added to the Errors middleware.

By default, the behavior is unchanged: all original request headers are forwarded to
the error page service.

If the error page service is in a separate trust domain, consider using
errorRequestHeaders to restrict which headers are forwarded.

The middle sentence is the project's own statement of what v2.11.44 did to the default. The GHSA database entry for CVE-2026-41181 (GHSA-p6hg-qh38-555r) lists v2.11.44, v3.6.15, and v3.7.0-rc.3 as the fixed versions. Both statements are public record. The fixed versions ship the option. The fixed versions do not change the default. The CVE record's "fixed in" field and the migration note's "behavior is unchanged" sentence describe the same binary.

Wide default, narrow doc

A forwarding component copies its entire inbound structure into its outbound call by default. The component's reference documentation enumerates the configurable surface. The configurable surface, before the CVE fix, contains the one element of the structure that has a knob attached. The other elements of the structure are present at runtime and absent from the page, because there is no knob to discuss. Operators read the docs and reason from the configurable surface. Their mental model of what crosses the boundary matches the enumerated knobs. The wire matches the unconditional copy.

The CVE record arrives and the fix adds an opt-in allowlist to the configurable surface. The same commit that adds the option adds the documentation paragraph that finally describes the default. The wide forwarding remains the default. The doc gap that obscured it closes; the bytes on the wire do not.

The same shape exists in any framework that propagates request context to downstream consumers. Webhook senders that POST the entire inbound payload by default. Log forwarders that dump the inbound request to a log sink. Error reporters whose default-included context contains the entire request. Metrics exporters that label timeseries with the entire header set. The documentation describes the knobs. The bytes on the wire are not the knobs.

An operator who upgrades Traefik to v2.11.44 and does not read the migration note continues to run the test case named forward all headers by default. The test case is not in the operator's repository. It is in Traefik's. It passes.

GHSA: GHSA-p6hg-qh38-555r. Fix commit: 0fdea20e.

The fix is the option. The default is the bug.