GHSA-2q52-x2ff-qgfr

Suggest an improvement
Source
https://github.com/advisories/GHSA-2q52-x2ff-qgfr
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/06/GHSA-2q52-x2ff-qgfr/GHSA-2q52-x2ff-qgfr.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-2q52-x2ff-qgfr
Aliases
  • CVE-2026-24425
Published
2026-06-05T20:41:33Z
Modified
2026-06-05T21:00:07.934077033Z
Severity
  • 8.8 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H CVSS Calculator
  • 8.7 (High) CVSS_V4 - CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N CVSS Calculator
Summary
Twig: Possible sandbox bypass when using a source policy
Details

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.

Database specific
{
    "cwe_ids": [
        "CWE-693"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-06-05T20:41:33Z",
    "nvd_published_at": "2026-05-20T14:16:38Z",
    "severity": "HIGH"
}
References

Affected packages

Packagist / twig/twig

Package

Name
twig/twig
Purl
pkg:composer/twig%2Ftwig

Affected ranges

Type
ECOSYSTEM
Events
Introduced
2.16.0
Last affected
2.16.1

Affected versions

v2.*
v2.16.0
v2.16.1

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/06/GHSA-2q52-x2ff-qgfr/GHSA-2q52-x2ff-qgfr.json"

Packagist / twig/twig

Package

Name
twig/twig
Purl
pkg:composer/twig%2Ftwig

Affected ranges

Type
ECOSYSTEM
Events
Introduced
3.9.0
Fixed
3.26.0

Affected versions

v3.*
v3.9.0
v3.9.1
v3.9.2
v3.9.3
v3.10.0
v3.10.1
v3.10.2
v3.10.3
v3.11.0
v3.11.1
v3.11.2
v3.11.3
v3.12.0
v3.13.0
v3.14.0
v3.14.1
v3.14.2
v3.15.0
v3.16.0
v3.17.0
v3.17.1
v3.18.0
v3.19.0
v3.20.0
v3.21.0
v3.21.1
v3.22.0
v3.22.1
v3.22.2
v3.23.0
v3.24.0
v3.25.0

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/06/GHSA-2q52-x2ff-qgfr/GHSA-2q52-x2ff-qgfr.json"