CVE-2026-46628
mediumpriority · track · 22EPSS 0.003 · 22 %ileEUUSEPSS · scored 2026-10-28
Twig is a template language for PHP. Prior to 3.26.0, the deprecated spaceless filter is registered as safe for HTML, causing Twig autoescaping to emit attacker-controlled markup unescaped when spaceless is applied to untrusted input. This issue is fixed in version 3.26.0.
cvss
Technical severity, 0–10. One row per scoring source.
base score 0–10 · higher = more severe · hover a vector to decode⚠ sources disagree · low–medium · 1.2–5.4
ssvc
A stakeholder decision — act, attend, or track — from exploitation and impact.
weaknesses
The CWE weakness classes this flaw belongs to.
affected products (3)
Products and version ranges known to be affected.
advisories (1)
Vendor and ecosystem advisories describing this.
- GHSA-4j38-f5cw-54h7Twig: The `spaceless` filter implicitly marks its output as safe2026-05-21ghsa · osvUS
### 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 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.
also known as (3)
Other names and identifiers for this entity.
sources
Which sources assert this record, and when.
references (10)
External citations — patches, advisories, analysis.
- https://github.com/twigphp/Twig/commit/3190b9ae12614dfd58cc5d8f394bac4708b17913cnnvd
- https://github.com/twigphp/Twig/releasesPatchcnnvd
- https://github.com/twigphp/Twig/releases/tag/v3.26.0cnnvd
- https://github.com/twigphp/Twig/security/advisories/GHSA-4j38-f5cw-54h7cnnvd
- https://github.com/twigphp/Twig/commit/3190b9ae12614dfd58cc5d8f394bac4708b17913enisa_euvd
- https://github.com/twigphp/Twig/releases/tag/v3.26.0enisa_euvd
- https://github.com/twigphp/Twig/security/advisories/GHSA-4j38-f5cw-54h7enisa_euvd
- https://github.com/twigphp/Twig/commit/3190b9ae12614dfd58cc5d8f394bac4708b17913Patchnvd
Attackers weaponise vulnerabilities like this against internet-exposed services. See what is exposed on your perimeter with a free passive scan.
Free scan