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

What Should I Do?

Address in Next Maintenance Window

Low exploitation probability (0.72%). Schedule for your next planned update.

Does your project use an affected twig/twig version?

Paste your composer.lock to check it for CVE-2026-24425 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.

Check my composer.lock

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 (174 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, scan your dependencies again to confirm the vulnerability is resolved.

Affected Packages (2)

Affects 1 ecosystem: Packagist (1).

PackageFixed In
twig/twig Packagist · Affected: v2.16.0, v2.16.1Range-based data available
twig/twig Packagist · Affected: 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. It has a 0.7% probability of exploitation within 30 days (EPSS score). 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

Significant impact if exploited, or exploitable with modest effort.

EPSS Score (30-day exploit probability)
0.72%
EPSS percentile: 49.9

This is a below-median EPSS score — only 49.9% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.

Also Known As

GHSA-2q52-x2ff-qgfr

Related CVEs

  • CVE-2026-46640
    HIGH

    Twig: Arbitrary PHP code execution via `_self.(<string>)` macro-reference compilation

  • CVE-2026-49981
    HIGH

    Twig: Sandbox filter, tag and function allow-list bypass when sandbox state changes between renders for a cached `Template`

  • CVE-2026-46634
    MEDIUM

    Twig: `template_from_string()` escapes a SourcePolicy-driven sandbox via synthesized template name

  • CVE-2026-48806
    MEDIUM

    Twig: Sandbox `__toString()` policy bypass via dynamic mapping keys

  • CVE-2024-45411
    MEDIUM

    Twig has a possible sandbox bypass

  • CVE-2026-47730
    LOW

    Twig: XSS in profiler HtmlDumper via unescaped template and profile names

  • CVE-2026-46628
    LOW

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

  • CVE-2024-51754
    LOW

    Twig has unguarded calls to `__toString()` when nesting an object into an array

Check your own dependencies

Free, with no signup for up to 10 packages.

Check my composer.lock