Loading...
Skip to main content

CVE-2026-24425 — Vulnerability in twig/twig — CVE Details

HIGH

Twig: Possible sandbox bypass when using a source policy

Published June 5, 2026Updated September 10, 2026Source: osv

Summary

# Description When using the sandbox with a `SourcePolicyInterface`, Twig does not always apply the sandbox restriction that forbids non-`Closure` callbacks for callback-accepting filters. The issue affects the `sort`, `filter`, `map`, and `reduce` filters. In the affected versions, the runtime check that rejects non-`Closure` callbacks in sandbox mode does not use the current template `Source`. As a result, when the sandbox is enabled through a source policy instead of being enabled globally, Twig can incorrectly treat the current execution as non-sandboxed for these callback checks. This can allow user-controlled templates to pass arbitrary PHP callables to callback-accepting filters even though the template is being sandboxed through a source policy. The issue happens when all these conditions are met: - The sandbox is not enabled globally; - A `SourcePolicyInterface` enables the sandbox for the rendered template; - The template uses one of the `sort`, `filter`, `map`, or `reduce` filters; - The callback is not a `Closure`. # Resolution The patch makes callback sandbox checks source-aware by propagating the current template `Source` to callback-accepting filters and using it when deciding whether sandbox restrictions apply. # Credits We would like to thank XavLim and Wade Sparks for reporting the issue and Fabien Potencier for fixing the issue.

Advisory Timeline

  • First published June 5, 2026 (129 days ago).
  • Last revised September 10, 2026 — 96 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

Composer
Update twig/twig to 3.26.0 or later
composer require "twig/twig:^3.26.0"

After upgrading, run your dependency scanner again to confirm the vulnerability is resolved.

Affected Packages (2)

Affects 1 ecosystem: packagist (1).

PackageEcosystemAffectedFixed In
twig/twig
packagist
v2.16.0, v2.16.1Range-based data available
twig/twig
packagist
v3.10.0, v3.10.1, v3.10.2, v3.10.3 (+28 more)3.26.0

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

  • CWE-693
    Protection Mechanism FailureMITRE

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 8.8 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
Low
Privileges Required
Low
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Frequently Asked Questions

What is CVE-2026-24425?
Twig: Possible sandbox bypass when using a source policy This vulnerability has been assigned a severity rating of HIGH (CVSS score: 8.8/10).
How do I check if my project is affected by CVE-2026-24425?
CVE-2026-24425 affects twig/twig. Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-24425 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
8.8

High exploitability or significant impact. Prioritize remediation within days.

Also Known As

GHSA-2q52-x2ff-qgfr

Related CVEs

Check if you're affected

Scan your dependencies to see if this vulnerability affects your projects.

Scan Your Dependencies