twig/twig security advisory
CVE-2026-47730: XSS in profiler HtmlDumper via unescaped template and profile names in twig/twig
CVE-2026-47730 is a low-severity XSS vulnerability in the PHP package twig/twig (CVSS 5.4), published 14 July 2026. It is fixed in 3.26.0; earlier versions are affected. Exploiting it needs a low-privilege user account.
low 5.4 published 2026-07-14 · updated 2026-10-24
- Affected versions
- >= 3.0.0, < 3.26.0
- Fixed in
- 3.26.0
- Newest release
- 3.30.0
- Severity
- Low · CVSS 5.4
- Type
- Cross-site scripting (XSS)
CWE-79 - Exploited in the wild
- Not on the CISA KEV list
checked 2026-11-04
Is your twig/twig version affected?
Who can exploit CVE-2026-47730
- Access: A normal, low-privilege user account in the app.
- Interaction: A user also has to do something, such as open a link or a page the attacker prepared.
CVSS vector (scored by NVD): CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N
How to fix CVE-2026-47730 in twig/twig
- Find the installed version:
composer show twig/twig. If you never required it yourself,composer why twig/twigshows which package pulls it in. - Update it:
composer update twig/twig --with-all-dependencies. You need 3.26.0 or newer. - If Composer will not go that high, your composer.json constraint is holding it back. Widen it (for example
"twig/twig": "^3.26.0"if you can take that version), or upgrade the package that requires it. - Run
composer audit. It reads the same advisory data and should no longer list CVE-2026-47730. - Commit composer.lock and deploy it. On the server, run
composer install --no-devfrom the lock file, notcomposer update.
If you cannot upgrade yet
- Escape output in your own templates and add a Content-Security-Policy that blocks inline scripts.
- Limit who can save the content the advisory names (for example rich text, SVG or form fields).
- If your app does not use the affected feature, note that in your audit, but still plan the upgrade.
The CVE-2026-47730 advisory
Twig is a template language for PHP. From 3.0.0 until 3.26.0, Twig\Profiler\Dumper\HtmlDumper writes Profile::getTemplate() and Profile::getName() into HTML output without escaping, allowing attacker-controlled template or profile names to inject arbitrary HTML when a browser renders the profiler dump. This issue is fixed in version 3.26.0.
References
- GitHub security advisory GHSA-2g2g-8p8h-fgwm github.com
- Symfony security advisory symfony.com
- Fix commit a5f6e87 github.com
- Release v3.26.0 github.com
Other twig/twig advisories
- high CVE-2026-49981: Twig: Sandbox filter, tag and function allow-list bypass when sandbox state changes between renders for a cached Template 2026-07-01
- CVE-2026-46636: Sandbox filter, tag and function allow-list bypass when sandbox state changes between renders 2026-05-27
- medium CVE-2026-48807: Sandbox __toString() policy bypass via Traversable in join/replace and in/not in operators 2026-05-27
- low CVE-2026-48805: Sandbox state regression in deprecated internal wrappers in src/Resources/core.php 2026-05-27
- medium CVE-2026-48808: Sandbox property allowlist bypass via the column filter under SourcePolicyInterface 2026-05-27
- medium CVE-2026-48806: Sandbox __toString() policy bypass via dynamic mapping keys 2026-05-27
Related
Need help patching or upgrading? Laskyr does PHP and Laravel security fixes and upgrades. Tell us what you run and we reply with a plan and a price.
Ask about a fixWhere this data comes from
- Affected and fixed versions: the Packagist security advisories API (GitHub Advisory Database and FriendsOfPHP), the same data
composer audituses. Synced 2026-11-03. - Description, score, weakness and references: NIST National Vulnerability Database (NVD), checked 2026-11-04. This product uses data from the NVD API but is not endorsed or certified by the NVD.
- Exploited-in-the-wild status: the CISA Known Exploited Vulnerabilities catalog, checked 2026-11-04.
- Compiled by Daniel Lasek at Laskyr from the sources above. The summary, “who can exploit it”, “how to fix it” and hardening sections are our plain-English reading of the record and are generated from it. The quoted description is the record's own text. Spot an error? Tell us.