GHSA-pr2w-4gpj-cpq4: Twig: Sandbox: multiple `__toString()` policy bypasses via unguarded string coercion points
- Identifiers
- CVE-2026-47732GHSA-pr2w-4gpj-cpq4
- Published
- Record updated
- Affected
- twig/twig <= 3.25.0
- Fixed in
- 3.26.0
- Known exploitation
- Not listed in the CISA Known Exploited Vulnerabilities catalog at the last check.
- EPSS
- 0.4%
Summary
Twig's sandbox fails to enforce its policy for implicit __toString() calls in several constructs. A sandboxed template author can invoke __toString() on any object reachable in the render context, even when that class's __toString is not allowlisted. Confirmed bypass vectors include conditional expressions, the matches and loose comparison operators, Twig tests such as is empty, nested null-coalesce expressions, and the do tag and .. range operator.
Mitigation
The sandbox now wraps every child node that the parent will string-coerce at runtime, instead of relying on a hardcoded list of node types in SandboxNodeVisitor. A new Twig\Node\CoercesChildrenToStringInterface lets nodes declare which children must be guarded. Spread arguments are materialised and policy-checked via SandboxExtension::ensureSpreadAllowed(), and dynamic attribute names are checked at runtime inside CoreExtension::getAttribute().
Related items
- HighCVE-2026-88968: Claude Code Edit tool symlink race overwrites files outside workspace on macOSSame vendor · NVD/CVE Database
- HighCVE-2026-88066: Claude Desktop on Windows git.exe execution via search pathSame vendor · NVD/CVE Database
- HighCVE-2026-62331: praktor path traversal via Telegram document upload filenamesSame vendor · NVD/CVE Database
- MediumGHSA-w4fh-qvv9-3v23: Model Context Protocol Python SDK: Server bearer-token authentication accepts tokens issued for a different resource serverSame vendor · GitHub Advisory Database
- MediumGHSA-5h93-6whr-6q8j: Model Context Protocol Python SDK: HTTP client transports followed cross-origin redirects carrying custom headers and bodiesSame vendor · GitHub Advisory Database