2.3low
Symfony: Inline Fragments Let Untrusted Forwarded Headers Set the Host, Scheme and Port of the URLs Generated for the Main Request
- Severity
- 2.3low CVSS:4.0 by Checkmarx
- Exploit likelihood
- 0.23% (higher than 15% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- Checkmarx
- Also known as
- GHSA-wg5q-m2ww-f3c9
Description
Improper trust of forwarded headers in RouterListener::onKernelFinishRequest() in Symfony HttpKernel versions prior to 5.4.56, 6.x prior to 6.4.50, 7.x prior to 7.4.23, and 8.x prior to 8.1.11 allows a remote attacker to control the host, scheme, and port of absolute URLs generated for the rest of the request, poisoning links in pages stored by a shared cache and in e-mails sent after the page was rendered.When a page renders an inline fragment (render() in Twig, or an ESI tag rendered inline), SubRequestHandler temporarily adds 127.0.0.1 to the trusted proxies, and RouterListener rebuilds the router context from the main request while that trust is still active, so the X-Forwarded-* and Forwarded headers of a request whose client address is 127.0.0.1 are trusted even though that address is not a configured trusted proxy. From that point on, every absolute URL the router generates for the rest of the main request takes its host, scheme, and port from headers sent by the client, including URLs produced by url() in Twig and by UrlGeneratorInterface::ABSOLUTE_URL. Applications are affected when they are reached over HTTP from 127.0.0.1, for example behind a TLS terminator, reverse proxy, local HTTP cache, or sidecar proxy on the same host, and that proxy passes the client’s forwarded headers along. With the default configuration (framework.trusted_proxies unset), all forwarded headers, including X-Forwarded-Host, are trusted during that window. Applications served through php-fpm, mod_php, or a proxy on another host are not affected. When framework.trusted_hosts is configured, a forwarded host outside the list is rejected, but the scheme and port can still be changed.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| symfony/http-kernel | before 5.4.56, from 6.0.0 before 6.4.50, from 7.0.0 before 7.4.23, from 8.0.0 before 8.1.11 | CVE List |
| symfony/http-kernel (Packagist) | before 5.4.56, from 6.0.0 before 6.4.50, from 7.0.0 before 7.4.23, from 8.0.0 before 8.1.11 | GitHub Advisory Database |
| symfony/symfony (Packagist) | before 5.4.56, from 6.0.0 before 6.4.50, from 7.0.0 before 7.4.23, from 8.0.0 before 8.1.11 | GitHub Advisory Database |
All scores
| Checkmarx | 2.3low CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:L/VA:N/SC:L/SI:N/SA:N |
| GitHub | low CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:L/VA:N/SC:L/SI:N/SA:N |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
Improper trust of forwarded headers in RouterListener::onKernelFinishRequest() in Symfony HttpKernel versions prior to 5.4.56, 6.x prior to 6.4.50, 7.x prior to 7.4.23, and 8.x prior to 8.1.11 allows a remote attacker to control the host, scheme, and port of absolute URLs generated for the rest of the request, poisoning links in pages stored by a shared cache and in e-mails sent after the page was rendered.When a page renders an inline fragment (render() in Twig, or an ESI tag rendered inline), SubRequestHandler temporarily adds 127.0.0.1 to the trusted proxies, and RouterListener rebuilds the router context from the main request while that trust is still active, so the X-Forwarded-* and Forwarded headers of a request whose client address is 127.0.0.1 are trusted even though that address is not a configured trusted proxy. From that point on, every absolute URL the router generates for the rest of the main request takes its host, scheme, and port from headers sent by the client, including URLs produced by url() in Twig and by UrlGeneratorInterface::ABSOLUTE_URL. Applications are affected when they are reached over HTTP from 127.0.0.1, for example behind a TLS terminator, reverse proxy, local HTTP cache, or sidecar proxy on the same host, and that proxy passes the client’s forwarded headers along. With the default configuration (framework.trusted_proxies unset), all forwarded headers, including X-Forwarded-Host, are trusted during that window. Applications served through php-fpm, mod_php, or a proxy on another host are not affected. When framework.trusted_hosts is configured, a forwarded host outside the list is rejected, but the scheme and port can still be changed.
GitHub Advisory Database
Description
When a page renders an inline fragment, with render() in Twig or with an ESI tag rendered inline because no gateway cache is used, SubRequestHandler adds 127.0.0.1 to the trusted proxies while the sub-request runs, with the trusted header set of the application, so that the internal sub-request is trusted. RouterListener::onKernelFinishRequest() runs inside that window: when the sub-request finishes, it rebuilds the router's RequestContext from the main request with RequestContext::fromRequest(). If the main request itself came from 127.0.0.1, its X-Forwarded-* and Forwarded headers are then trusted, although the application never declared 127.0.0.1 a trusted proxy.
From that point on, every absolute URL the router generates for the rest of the main request takes its host, scheme and port from headers sent by the client: url() in Twig, UrlGeneratorInterface::ABSOLUTE_URL, links in a page that a shared cache stores, or in an e-mail sent after the page was rendered.
This affects applications reached over HTTP from 127.0.0.1 without that address being a trusted proxy, for instance behind a TLS terminator or a reverse proxy running on the same host in front of an application server, behind a local HTTP cache, or behind a sidecar proxy. When framework.trusted_proxies is not configured, which is the default, every forwarded header is trusted during that window, X-Forwarded-Host included, and a web server or proxy that only accepts known hosts does not help, since the host comes from that header. Applications served through php-fpm, mod_php, or a proxy running on another host are not affected, since REMOTE_ADDR is not 127.0.0.1 there. When framework.trusted_hosts is configured, a forwarded host outside of the list is rejected, but the scheme and the port can still be changed.
Resolution
RouterListener now saves the router context of the parent request when a sub-request starts, and restores it when the sub-request finishes, instead of computing it again from the parent request while the trusted proxies of the sub-request still apply to it. URLs generated after an inline fragment are built from the same context as before it.
Code that reads the main request while the sub-request itself runs, such as Request::getClientIp() in a listener of that sub-request, still sees 127.0.0.1 trusted. Applications running behind a proxy on 127.0.0.1 should have that proxy set the forwarded headers itself instead of passing the client's along, and configure framework.trusted_hosts.
The patches for this issue are available here for branch 5.4 (and forward-ported to 6.4, 7.4, 8.1 and 8.2).
Credits
Symfony would like to thank Nicolas Grekas for reporting the issue and providing the fix.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-123339 changed 2026-11-06 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-wg5q-m2ww-f3c9 changed 2026-12-01 | CC-BY-4.0 |
| NVD | CVE-2026-123339 changed 2026-11-06 | Public domain |