Twig: Sandbox `__toString()` policy bypass via `Traversable` in `join` and `replace` filters
Key facts
- Attack vector
- Network
- Privileges required
- Low
- User interaction
- None
- Attack complexity
- Low
- Attack requirements
- None
- Impact type
- Security bypass
- Confidentiality · integrity · availability
- High · Low · None
- Fix status
- Fixed
Attack profile from CVSS 4.0 · CNA. Fix status from CNA and GitHub. Impact type from CWE-693.
Summary
Twig is a template language for PHP. Prior to 3.27.0, the sandbox __toString() checks do not fully cover Traversable values passed to join and replace filters or operands evaluated by the in and not in operators, allowing contained Stringable objects to be coerced to strings without consulting the sandbox policy. This issue is fixed in version 3.27.0.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- No
- Technical impact
- Partial
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| symfony | Twig | before 3.27.0 | 3.27.0 | Patch available | CNA |
| — | twig/twig (Packagist) | before 3.27.0 | 3.27.0 | Patch available | GHSA-8x9c-rmqh-456c |
- Twig Vendorsymfony Affected before 3.27.0 Fixed in 3.27.0 Patch available CNA
- twig/twig (Packagist) Vendor— Affected before 3.27.0 Fixed in 3.27.0 Patch available GHSA-8x9c-rmqh-456c
Remediation
- Fix · CNA Twig (twigphp) Fixed in 3.27.0
- Fix · GHSA-8x9c-rmqh-456c twig/twig (Packagist) Fixed in 3.27.0 Advisory →
Vendor assessments
Timeline
- 2026-10-02 Threatist record created from CVE-2026-48807
- 2026-10-03 Alias added: GHSA-8x9c-rmqh-456c
References
Other 4
- https://github.com/twigphp/Twig/releases/tag/v3.27.0
- https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2026-48807.yaml
- https://github.com/twigphp/Twig
- https://symfony.com/blog/cve-2026-48807-sandbox-tostring-policy-bypass-via-traversable-in-join-replace-and-in-not-in-operators
More symfony Twig vulnerabilities
- TI-2026-34283 Twig: The `spaceless` filter implicitly marks its output as safe CVSS 4.0MEDIUM 5.1
- TI-2022-07667 Code injection in Twig CVSS 3.1CRITICAL 9.8
- TI-2018-10028 Twig before 2.4.4 allows Server-Side Template Injection (SSTI) via the search search_key… CVSS 3.0CRITICAL 9.8
- TI-2022-18637 Twig may load a template outside a configured directory when using the filesystem loader CVSS 3.1HIGH 7.5
- TI-2026-34292 Twig: Arbitrary PHP code execution via `_self.(<string>)` macro-reference compilation CVSS 4.0HIGH 8.7
- TI-2026-34285 Twig: PHP code injection via `{% use %}` template name CVSS 4.0HIGH 8.7
Sources
- CVE-2026-48807 · CVE Program
- CVE-2026-48807 · NVD
- FIRST EPSS
- GHSA-8x9c-rmqh-456c · GitHub Advisory Database · CC BY 4.0
- CVE-2026-48807 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences