' %}\n{{ payload }} {# escaped #}\n{{ payload|spaceless }} {# not escaped #}\n```\n\nThe filte","image":"https://o3.security/opengraph.png","datePublished":"2026-07-14T21:19:54.501Z","dateModified":"2026-08-12T03:51:08.360862744Z","url":"https://o3.security/vulnerability/CVE-2026-46628","inLanguage":"en","author":{"@id":"https://o3.security/#organization"},"publisher":{"@id":"https://o3.security/#organization"},"mainEntityOfPage":{"@type":"WebPage","@id":"https://o3.security/vulnerability/CVE-2026-46628"},"speakable":{"@type":"SpeakableSpecification","cssSelector":["h1",".vuln-summary",".vuln-severity",".vuln-mitigation"]},"about":[{"@type":"SoftwareApplication","name":"twig/twig","applicationCategory":"Packagist","softwareVersion":"3.26.0"}],"citation":[{"@type":"CreativeWork","name":"NVD","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-46628"},{"@type":"CreativeWork","name":"OSV.dev","url":"https://osv.dev/vulnerability/CVE-2026-46628"},{"@type":"CreativeWork","name":"FIRST.org EPSS","url":"https://www.first.org/epss/api-data?cve=CVE-2026-46628"},{"@type":"CreativeWork","url":"https://github.com/twigphp/Twig/releases/tag/v3.26.0"},{"@type":"CreativeWork","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/46xxx/CVE-2026-46628.json"},{"@type":"CreativeWork","url":"https://github.com/twigphp/Twig/security/advisories/GHSA-4j38-f5cw-54h7"},{"@type":"CreativeWork","url":"https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2026-46628.yaml"},{"@type":"CreativeWork","url":"https://symfony.com/cve-2026-46628"}]}' %}\n{{ payload }} {# escaped #}\n{{ payload|spaceless }} {# not escaped #}\n```\n\nThe filte","url":"https://o3.security/vulnerability/CVE-2026-46628","identifier":"CVE-2026-46628","datePublished":"2026-07-14T21:19:54.501Z","dateModified":"2026-08-12T03:51:08.360862744Z","inLanguage":"en","license":"https://creativecommons.org/licenses/by/4.0/","keywords":["CVE-2026-46628","CWE-116","CVE","vulnerability","security advisory"],"creator":{"@id":"https://o3.security/#organization"},"isAccessibleForFree":true,"citation":[{"@type":"CreativeWork","name":"NVD","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-46628"},{"@type":"CreativeWork","name":"OSV.dev","url":"https://osv.dev/vulnerability/CVE-2026-46628"},{"@type":"CreativeWork","name":"FIRST.org EPSS","url":"https://www.first.org/epss/api-data?cve=CVE-2026-46628"}]}' %}\n{{ payload }} {# escaped #}\n{{ payload|spaceless }} {# not escaped #}\n```\n\nThe filter is deprecated but still functional. With the deprecation, some downstream projects (e.g. Drupal mo"}},{"@type":"Question","name":"How severe is CVE-2026-46628?","acceptedAnswer":{"@type":"Answer","text":"No CVSS score has been assigned to CVE-2026-46628 yet. Review the advisory details and affected package list to assess your exposure."}},{"@type":"Question","name":"Which packages are affected by CVE-2026-46628?","acceptedAnswer":{"@type":"Answer","text":"CVE-2026-46628 affects the following packages: twig/twig (Packagist). Ecosystems affected: Packagist."}},{"@type":"Question","name":"How do I fix CVE-2026-46628?","acceptedAnswer":{"@type":"Answer","text":"Update twig/twig to 3.26.0 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2026-46628 is resolved across your whole dependency graph."}},{"@type":"Question","name":"How do I detect CVE-2026-46628 in my Packagist dependencies?","acceptedAnswer":{"@type":"Answer","text":"Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for twig/twig, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version."}},{"@type":"Question","name":"How do I mitigate CVE-2026-46628 if there is no patch (or I can't update yet)?","acceptedAnswer":{"@type":"Answer","text":"If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands."}},{"@type":"Question","name":"Is CVE-2026-46628 actively exploited in the wild?","acceptedAnswer":{"@type":"Answer","text":"No public exploit code has been indexed for CVE-2026-46628 yet. This does not mean the vulnerability cannot be exploited — absence of public exploits does not imply safety. Apply the recommended fix and use O3 Security to monitor your exposure."}},{"@type":"Question","name":"What is the EPSS score for CVE-2026-46628?","acceptedAnswer":{"@type":"Answer","text":"CVE-2026-46628 has an EPSS (Exploit Prediction Scoring System) score of 0.3%, placing it in the 20th percentile of all CVEs. EPSS is maintained by FIRST.org and estimates the probability that a vulnerability will be exploited in the wild within the next 30 days. This score indicates relatively lower exploitation probability, though the CVSS severity should still guide your patching priority."}},{"@type":"Question","name":"What type of vulnerability is CVE-2026-46628?","acceptedAnswer":{"@type":"Answer","text":"CVE-2026-46628 is classified as CWE-116 (CWE-116). This weakness type describe the underlying flaw category, which helps determine the potential impact and the right class of mitigation."}},{"@type":"Question","name":"When was CVE-2026-46628 published, and has it been updated?","acceptedAnswer":{"@type":"Answer","text":"CVE-2026-46628 was published on July 14, 2026 and was last updated on August 12, 2026. Advisory data evolves as severity scores, affected ranges, and exploit intelligence are revised — always check the latest version of the advisory before acting."}}]}
Your RSA-2048 keys break in 2030. Find every one of them before attackers do.
🐘 Packagist
Not in CISA KEV

CVE-2026-46628 — twig/twig

Fix: twigphp/Twig@3190b9a

CVE-2026-46628 is a CWE-116 vulnerability in twig/twig. A fix is available for twig/twig — see the affected versions and patch details below.

Twig: The `spaceless` filter implicitly marks its output as safe

Also known asGHSA-4j38-f5cw-54h7
Published
Jul 14, 2026
Updated
Aug 12, 2026
Affected
1 pkg
Patched
1 / 1
Exploits
None indexed
Exploitation data as of Oct 2, 2026 · OSV.dev, NVD, FIRST.org (EPSS)

Exploitation Status

Proof-of-concept exploit code exists

  • CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.

Exploitation and automatability from CISA’s SSVC triage for CVE-2026-46628.

EPSS Exploitation Probability

via FIRST.org ↗
0.3%probability of exploitation in next 30 days
Lower Risk0.00%
Lower risk than most CVEs20th percentile — riskier than 20% of all scored CVEsHighest risk
0.00%0.27%0.53%0.80%0.2%0.3%0.3%0.3%Aug 26Oct 26Oct 26

Probability of exploitation in the next 30 days, from FIRST.org EPSS.

Real-World Exposure

1 pkg affected
🐘twig/twig

Real-time download stats are indexed for npm and PyPI packages. This vulnerability affects Packagist packages — download data is not available via public APIs for these ecosystems.

Description

Description

The spaceless filter is registered with is_safe => ['html'], which means Twig's autoescaper does not escape its output in an HTML context. As a result, applying spaceless to attacker-controlled input that contains markup emits the markup unescaped even when the developer never wrote |raw and autoescape is enabled.

Example:

{% set payload = '<script>alert()</script>' %}
{{ payload }}          {# escaped #}
{{ payload|spaceless }} {# not escaped #}

The filter is deprecated but still functional. With the deprecation, some downstream projects (e.g. Drupal modules) have duplicated the filter and inherited the same is_safe flag.

Resolution

The spaceless filter no longer marks its output as safe. Documentation has been updated to warn that spaceless should not be applied to unsanitised user input.

Credits

Twig would like to thank Pierre Rudloff for reporting the issue.

Affected Packages

1 total 1 fixed
EcosystemPackageVulnerable rangeFix
🐘Packagisttwig/twigall versions3.26.0composer require twig/twig:^3.26.0

Affected Products

1 product · 1 configurations
Application
twigsymfony
< 3.26.0
range

Detection & mitigation playbook

Open-source dependency
  1. Detect

    Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for twig/twig, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.

  2. Fix

    Update twig/twig to 3.26.0 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2026-46628 is resolved across your whole dependency graph.

  3. Workarounds

    If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.

Frequently Asked Questions

### Description The `spaceless` filter is registered with `is_safe => ['html']`, which means Twig's autoescaper does not escape its output in an HTML context. As a result, applying `spaceless` to attacker-controlled input that contains markup emits the markup unescaped even when the developer never wrote `|raw` and autoescape is enabled. Example: ```twig {% set payload = '<script>alert()</script>' %} {{ payload }} {# escaped #} {{ payload|spaceless }} {# not escaped #} ``` The filter is deprecated but still functional. With the deprecation, some downstream projects (e.g. Drupal mo
O3 Security · Impact-Aware SCA

Is CVE-2026-46628 in your dependencies?

Find it across Packagist, including transitive dependencies.

CVE-2026-46628: twig/twig — Fixed in 3.26.0 | O3 Security