Advisory Database
  • Advisories
  • Dependency Scanning
  1. composer
  2. ›
  3. twig/twig
  4. ›
  5. CVE-2026-24425

CVE-2026-24425: Twig: Possible sandbox bypass when using a source policy

June 5, 2026

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.

References

  • github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2026-24425.yaml
  • github.com/advisories/GHSA-2q52-x2ff-qgfr
  • github.com/twigphp/Twig/releases/tag/v3.26.0
  • github.com/twigphp/Twig/security/advisories/GHSA-2q52-x2ff-qgfr
  • nvd.nist.gov/vuln/detail/CVE-2026-24425
  • symfony.com/cve-2026-24425
  • www.vulncheck.com/advisories/twig-x-x-sandbox-bypass-via-sourcepolicyinterface

Code Behaviors & Features

Detect and mitigate CVE-2026-24425 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions starting from 2.16.0 up to 2.16.1, all versions starting from 3.9.0 before 3.26.0

Fixed versions

  • 3.26.0

Solution

Upgrade to version 3.26.0 or above.

Impact 8.8 HIGH

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

Learn more about CVSS

Weakness

  • CWE-693: Protection Mechanism Failure

Source file

packagist/twig/twig/CVE-2026-24425.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Sat, 11 Jul 2026 00:19:00 +0000.