Twig sandbox bypass through dynamic embed parent expressions
Key facts
- Attack vector
- Network
- Privileges required
- Low
- User interaction
- None
- Attack complexity
- Low
- Attack requirements
- None
- Impact type
- Security bypass
- Confidentiality · integrity · availability
- Low · Low · None
- Fix status
- Fixed
Attack profile from CVSS 4.0 · CNA. Fix status from CNA. Impact type from CWE-693.
Summary
The twig/twig package before 3.31.1 does not check the parent expression of an embed tag against the sandbox policy. The functions, filters, tests and string conversions in that expression, including __toString() methods, are not checked either (CWE-693, CWE-863). A sandboxed template allowed to use embed can call any function, filter or test, and any __toString() method.
Written with Claude Haiku 5.5 from the sources below · 2026-11-24
Description from the CNA
When the parent of an embed tag was an expression other than a string or a variable, the sandbox didn't see that expression. The functions, filters and tests of the expression weren't checked against the policy, and neither were its conversions to strings. A sandboxed template allowed to use embed could therefore call any function, filter or test, and any __toString() method: {% embed 'leak_' ~ app_secret() %}{% endembed %} Method calls and property reads were not affected, since they're checked at runtime. The sandbox now checks the parent expression of embed like any other expression of the template.
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
Remediation
Upgrade twig/twig to version 3.31.1, the first fixed version.
Written with Claude Haiku 5.5 from the sources below · 2026-11-24
- Fix · CNA twig/twig (Twig) Fixed in 3.31.1
Fixed in the same release
Records fixed by the same vendor advisory or release, as the CNA lists them.
- Release ·
twig/twig 3.31.1
7 records Highest priority Priority LOW 7 LOW
Other records, highest priority first
- TI-2026-97282 Sandbox bypass in Twig join filter exposes object propertiesPriority LOW 25
- TI-2026-97279 Sandbox toString() policy bypass in Twig via assignmentsPriority LOW 25
- TI-2026-97277 Sandbox toString policy bypass via is true test in TwigPriority LOW 25
Timeline
- 2026-11-24 Threatist record created from CVE-2026-133767
References
More Twig vulnerabilities
- TI-2026-97282 Sandbox bypass in Twig join filter exposes object properties CVSS 4.0MEDIUM 5.3
- TI-2026-97279 Sandbox toString() policy bypass in Twig via assignments CVSS 4.0MEDIUM 5.3
- TI-2026-97277 Sandbox toString policy bypass via is true test in Twig CVSS 4.0MEDIUM 5.3
- TI-2026-97287 Unbounded converter cache in Twig markdown-extra exhausts memory CVSS 4.0LOW 2.3
- TI-2026-97286 Sandbox bypass in Twig guard tag lets templates use disallowed tags CVSS 4.0LOW 2.3
- TI-2026-97285 Twig skips autoescaping for variables named like import aliases CVSS 4.0LOW 2.3
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences