CWE-693: Protection Mechanism Failure in twigphp Twig (CVE-2026-48806)
Twig is a template language for PHP. Prior to 3.27.0, ArrayExpression does not guard dynamic mapping keys that are coerced to strings, allowing PHP to invoke __toString() on a Stringable object used as a mapping key without calling SandboxExtension::ensureToStringAllowed(). This issue is fixed in version 3.27.0.
AI Analysis
Technical Summary
The twig/twig package before version 3.27.0 contains a vulnerability where sandboxed templates can bypass the sandbox __toString() policy due to improper validation of dynamic mapping keys. Specifically, dynamic keys in array expressions were not checked prior to PHP's string coercion, allowing unauthorized __toString() method calls. This flaw was addressed by updating the code to treat dynamic mapping keys as string-coercion sites, ensuring sandbox policies are enforced before any string conversion occurs.
Potential Impact
Sandboxed templates may execute __toString() methods that should be restricted, potentially allowing unauthorized code execution paths or information disclosure within the sandbox environment. This undermines the sandbox's intended security controls.
Mitigation Recommendations
A fix is available in twig/twig version 3.27.0 and later. Users should upgrade to version 3.27.0 or newer to ensure the sandbox __toString() policy bypass is resolved. No additional mitigations are indicated.
CWE-693: Protection Mechanism Failure in twigphp Twig (CVE-2026-48806)
Description
Twig is a template language for PHP. Prior to 3.27.0, ArrayExpression does not guard dynamic mapping keys that are coerced to strings, allowing PHP to invoke __toString() on a Stringable object used as a mapping key without calling SandboxExtension::ensureToStringAllowed(). This issue is fixed in version 3.27.0.
CVSS v4.0
Score 7.1high
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The twig/twig package before version 3.27.0 contains a vulnerability where sandboxed templates can bypass the sandbox __toString() policy due to improper validation of dynamic mapping keys. Specifically, dynamic keys in array expressions were not checked prior to PHP's string coercion, allowing unauthorized __toString() method calls. This flaw was addressed by updating the code to treat dynamic mapping keys as string-coercion sites, ensuring sandbox policies are enforced before any string conversion occurs.
Potential Impact
Sandboxed templates may execute __toString() methods that should be restricted, potentially allowing unauthorized code execution paths or information disclosure within the sandbox environment. This undermines the sandbox's intended security controls.
Mitigation Recommendations
A fix is available in twig/twig version 3.27.0 and later. Users should upgrade to version 3.27.0 or newer to ensure the sandbox __toString() policy bypass is resolved. No additional mitigations are indicated.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-5v5v-ww74-355v
- Osv Schema Version
- 1.4.0
- Aliases
- ["CVE-2026-48806"]
- Ecosystems
- ["Packagist"]
- Database Specific Severity
- MODERATE
- Cvss Version
- null
Threat ID: 6a4452e027e9c797198e108d
Added to database: 06/30/2026, 23:36:00 UTC
Last enriched: 07/15/2026, 07:55:53 UTC
Last updated: 07/31/2026, 19:24:49 UTC
Views: 55
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.