GitHub Security Advisory: GHSA-fw45-f5q2-2p4x
Package: github.com/traefik/traefik/v2 (GO)
Severity: MODERATE (CVSS 4.4)
CWE: CWE-770: Allocation of Resources Without Limits or Throttling
Vulnerable versions: <= 2.11.37
Patched in: 2.11.38

Summary: Traefik has unbounded io.ReadAll on auth server response body that causes OOM DOS

Details:
## Impact

There is a potential vulnerability in Traefik managing the ForwardAuth middleware responses.

When Traefik is configured to use the ForwardAuth middleware, the response body from the authentication server is read entirely into memory without any size limit. There is no `maxResponseBodySize` configuration to restrict the amount of data read from the authentication server response. If the authentication server returns an unexpectedly large or unbounded response body, Traefik will allocate unlimited memory, potentially causing an out-of-memory (OOM) condition that crashes the process.

This results in a denial of service for all routes served by the affected Traefik instance.

## Patches

- https://github.com/traefik/traefik/releases/tag/v2.11.38
- https://github.com/traefik/traefik/releases/tag/v3.6.9

## Workarounds

No workaround available.

## For more information

If there are any questions or comments about this advisory, please [open an issue](https://github.com/traefik/traefik/issues).

---

<details>
<summary>Original Description</summary>

### Summary

The ForwardAuth middleware reads the entire authentication server response body into memory using io.ReadAll with no size limit. A single HTTP request through a ForwardAuth-protected route can cause the Traefik process to allocate gigabytes of memory and be killed by the OOM killer, resulting in complete denial of service for all routes on the affected entrypoint.

### Details

In pkg/middlewares/auth/forward.go, line 213:

    body, readError := io.ReadAll(forwardResponse.Body)

When the ForwardAuth middleware receives a response from the configured authentication server, it calls io.ReadAll on the response body without any size constraint. If the auth server returns a large or infinite chunked response, Traefik will attempt to buffer the entire body in memory until the process is killed.

Traefik already recognizes this class of risk for the request body direction. When forwardBody: true is configured without maxBodySize, a warning is logged (line 91-94):

    logger.Warn().Msgf("ForwardAuth 'maxBodySize' is not configured with 'forwardBody: true', allowing unlimited request body size ...")

However, the response body path has no equivalent protection — no configuration option, no warning, and no default limit. The HTTP client has a 30-second timeout (line 102), but a streaming response can deliver hundreds of megabytes per second within that window.

| Direction | Protection | Code |
|-----------|-----------|------|
| Request body to auth server | maxBodySize config + warning log | forward.go:85-95 |
| Auth server response to Traefik | None | forward.go:213 |

### PoC

1. Create a malicious auth server (auth_infinite.py):

    from http.server import BaseHTTPRequestHandler, HTTPServer

    class InfiniteAuth(BaseHTTPRequestHandler):
        def do_GET(self):
            self.send_response(200)
            self.send_header("Transfer-Encoding", "chunked")
            self.end_hea