# GHSA-FMP9-6WXR-CFMQ: Description When the parent of an embed tag was an expression other than a string or a variable, the sandbox didn't see that expression

- Database: GitHub
- Severity: CVSS 5.3 (Medium)
- Published: 2026-11-24
- Modified: 2026-11-24

## Tracked as

- [CVE-2026-133767](https://cve.now/CVE-2026-133767.md): twig/twig sandbox bypass in dynamic embed parents

## Affected versions

- twig/twig (Packagist): fixed in 3.31.1

## Description

### Description

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:

```twig
{% embed 'leak_' ~ app_secret() %}{% endembed %}
```

Method calls and property reads were not affected, since they're checked at runtime.

### Resolution

The sandbox now checks the parent expression of `embed` like any other expression of the template.

The patch for this issue is available [here](https://github.com/twigphp/Twig/commit/fe395ad247b8e6c6f34f39bc211119ecb11f80b3) for branch 3.x.

### Credits

We would like to thank [Ivan Tse](https://github.com/ivantsepp) for reporting the issue, and Fabien Potencier for providing the fix.

## References

- https://github.com/twigphp/Twig/security/advisories/GHSA-fmp9-6wxr-cfmq

Page: https://cve.now/GHSA-FMP9-6WXR-CFMQ

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
