CVE-2026-46628

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

Published Jul 14, 2026 CVSS 4.0 · 5.1 Medium EPSS < 1% KEV · Not listed
Description
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.

Analysis

AI-generated

Technical impact

Twig is a template language for PHP. Prior to 3.26.0, the deprecated spaceless filter is registered as safe for HTML, causing Twig auto‑escaping to emit attacker‑controlled markup unescaped when the filter is applied to untrusted input. This bypasses the templating engine’s protection, enabling an attacker to inject arbitrary HTML or JavaScript and conduct cross‑site scripting attacks.

Affected Systems

The vendor twigphp:Twig is affected. All Twig installations of version 3.x before 3.26.0 use the spaceless filter. Any environment that renders untrusted data through templates and applies the spaceless filter is impacted.

Risk and Exploitability

The CVSS score of 5.1 indicates moderate risk, while the EPSS score of < 1% denotes a low probability of exploitation. The vulnerability is not listed in the CISA KEV catalog. The likely attack vector is a web application that passes untrusted data to a template with the filter applied, thereby bypassing auto‑escaping and enabling XSS.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade Twig to version 3.26.0 or later, which removes the unsafe registration of the spaceless filter.
  • If an upgrade is not immediately feasible, eliminate or refactor all template usage of the spaceless filter, or strictly sanitize untrusted input before applying the filter.
  • Configure the Twig environment to disallow deprecated filters so that future regressions cannot re‑introduce the issue.

Generated by OpenCVE AI on July 31, 2026 at 04:35 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Debian DSA Debian DSA DSA-6311-1 php-twig security update
Debian DSA Debian DSA DSA-6320-1 php-twig security update
Github GHSA Github GHSA GHSA-4j38-f5cw-54h7 Twig: The `spaceless` filter implicitly marks its output as safe
History
Type Values Removed Values Added
First Time appeared Twigphp
Twigphp twig
Vendors & Products Twigphp
Twigphp twig
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'poc', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
Description 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.
Title Twig: The `spaceless` filter implicitly marks its output as safe
Weaknesses CWE-116
References
Metrics cvssV4_0

{'score': 5.1, 'vector': 'CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N'}

Weaknesses
  • CWE-116

    Improper Encoding or Escaping of Output

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Jul 15, 2026, 12:49 PM
Reserved
May 15, 2026, 7:34 PM
Status
Analyzed
Published
Jul 14, 2026, 10:16 PM
Modified
Oct 24, 2026, 10:10 PM