GHSA-62c8-mh53-4cqv HTTP client can manipulate custom HTTP headers that are added by Traefik
ImpactThere is a vulnerability in Traefik that allows the client to remove the X-Forwarded headers (except the header X-Forwarded-For).Patcheshttps://github.com/traefik/traefik/releases/tag/v2.11.9https://github.com/traefik/traefik/releases/tag/v3.1.3WorkaroundsNo workaround.For more informationIf you have any questions or comments about this advisory, please [open an issue](https://github.com/traefik/traefik/issues).When a HTTP request is processed by Traefik, certain HTTP headers such as X-Forwarded-Host or X-Forwarded-Port are added by Traefik before the request is routed to the application. For a HTTP client, it should not be possible to remove or modify these headers. Since the application trusts the value of these headers, security implications might arise, if they can be modified.For HTTP/1.1, however, it was found that some of theses custom headers can indeed be removed and in certain cases manipulated. The attack relies on the HTTP/1.1 behavior, that headers can be defined as hop-by-hop via the HTTP Connection header. By setting the following connection header, the X-Forwarded-Host header can, for example, be removed:Connection: close, X-Forwarded-HostDepending on how the receiving application handles such cases, security implications may arise. Moreover, some application frameworks (e.g. Django) first transform the "-" to "_" signs, making it possible for the HTTP client to even modify these headers in these cases.This is similar to [CVE-2022-31813](https://nvd.nist.gov/vuln/detail/CVE-2022-31813) for Apache HTTP Server.DetailsIt was found that the following headers can be removed in this way (i.e. by specifing them within a connection header):X-Forwarded-HostX-Forwarded-PortX-Forwarded-ProtoX-Forwarded-ServerX-Real-IpX-Forwarded-Tls-Client-CertX-Forwarded-Tls-Client-Cert-InfoPoCThe following docker-compose file has been used for a simple setup:The following traefik.yaml has been used:The Python container just includes a simple Python HTTP server that prints the HTTP headers it receives. Here is the Dockerfile for the container:And here is the Python script:The environment is run with `sudo docker-compose up`.A normal HTTP request/response pair looks like this:**Request 1****Response 1**The custom headers added by Traefik can be seen in the response.Next, a request, where the X-Forwarded-Host header is defined as a hop-by-hop header via the Connection header is sent:**Request 2****Response 2**As can be seen from the response, the X-Forwarded-Host header that had been added by Traefik has been removed from the request.Moreover, the next request/response pair demonstrates that a custom header with underscore instead of hyphen can be added:**Request 3****Response 3**Some backend frameworks (e.g. Django) handle X-Forwarded-Host and X_forwarded_host in the same way. As there is no X-Forwarded-Host header present in the request, the X_forwarded_host header will be used.It should be noted that when X-Forwarded-Host is present and a X_forwarded_host header is sent, usually the first occurence of the header will be used, which is in this case X-Forwarded-Host.It should be noted that the headers X-Forwarded-Tls-Client-Cert and X-Forwarded-Tls-Client-Cert-Info are also affected. Here, client certificate authentication would need to be enabled in the Traefik setup.ImpactAll applications that trust the custom headers set by Traefik are affected by this vulnerability. As an example, assume that a backend application trusts Traefik to validate client certificates and trusts therefore the values that are sent within the X-Forwarded-Tls-Client-Cert header, but does not validate the certificate anew.If the header is removed via the vulnerability, and the application framework allows for alternative names (e.g. by transforming the headers to lower case, and "-" to "_"), an attacker can place his own X_Forwarded_TLS_Client_Cert header in the request. This could lead to privilege escalation, as the attacker may put an (invalid) certificate in this header that would just be accepted by the application, but may contain other data than the certificate that is presented to Traefik for Client Certificate Authentication.Moreover, if the backend application uses any of the other custom headers for security-sensitive operations, the removal or modification of these headers may also security implications (e.g. access control bypass).The severity is the same as for [CVE-2022-31813](https://nvd.nist.gov/vuln/detail/CVE-2022-31813) for Apache HTTP Server, i.e. 9.8 Critical.
CVSS v4.0 score: 9.3
CVSS v3.1 score: 7.5