CVE-2026-47732
published 2026-07-14CVE-2026-47732: Twig is a template language for PHP. Prior to 3.26.0, several Twig language constructs trigger PHP string coercion on a Stringable operand without consulting…
PriorityP337medium6.5CVSS 3.1
AVNACLPRLUINSUCHINAN
EPSS
0.40%
34.0th percentile
Twig is a template language for PHP. Prior to 3.26.0, several Twig language constructs trigger PHP string coercion on a Stringable operand without consulting SecurityPolicy::checkMethodAllowed(), allowing a sandboxed template author to invoke __toString() on objects reachable in the render context through conditional expressions, comparison operators, tests, template-loading tags, dynamic attribute names, spread arguments, the do tag, and the .. range operator. This issue is fixed in version 3.26.0.
Affected
4 ranges
| Vendor | Product | Version range | Fixed in |
|---|---|---|---|
| symfony | twig | < 3.26.0 | 3.26.0 |
| twig | twig | >= 0 < 3.27.0 | 3.27.0 |
| twig | twig | >= 0 < 3.26.0 | 3.26.0 |
| twigphp | twig | < 3.26.0 | 3.26.0 |
CVSS provenance
nvdv3.16.5MEDIUMCVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N
nvdv4.07.1HIGHCVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:L/VA:N/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
Stop checking back — get the weekly exploitation signal.
Every Monday: what got weaponized or added to CISA KEV in the last seven days — each CVE cross-linked to its PoC, Nuclei template, and detection rule. Free, one email a week, unsubscribe in one click.
GHSA
Twig: Sandbox `__toString()` policy bypass via `Traversable` in `join` and `replace` filters
ghsa·2026-06-30
CVE-2026-48807 [MEDIUM] CWE-693 Twig: Sandbox `__toString()` policy bypass via `Traversable` in `join` and `replace` filters
Twig: Sandbox `__toString()` policy bypass via `Traversable` in `join` and `replace` filters
### Description
This is a residual bypass of CVE-2026-47732 / GHSA-pr2w-4gpj-cpq4 left after the initial fix for unguarded `__toString()` calls. It covers two related coercion points that were not caught by the original patch.
**`Traversable` in `join` and `replace` filters.** `SandboxExtension::ensureToStringAllowed()` recurses into PHP arrays so that a `Stringable` object hidden inside an array argument cannot be string-coerced without consulting the security policy. The recursion stops at PHP arrays: a `Traversable` value passed at the same position is not materialised, so its contents are not policy-checked. `CoreExtension::join()` and `CoreExtension::replace()` later materialise such `Trave
GHSA
Twig: Sandbox `__toString()` policy bypass via dynamic mapping keys
ghsa·2026-06-30
CVE-2026-48806 [MEDIUM] CWE-693 Twig: Sandbox `__toString()` policy bypass via dynamic mapping keys
Twig: Sandbox `__toString()` policy bypass via dynamic mapping keys
### Description
This is a residual bypass of CVE-2026-47732 / GHSA-pr2w-4gpj-cpq4 left after the initial fix for unguarded `__toString()` calls.
In 3.26.0 the sandbox visitor was extended to wrap every child node that its parent will string-coerce at runtime with `CheckToStringNode`, gated by the new `CoercesChildrenToStringInterface`. `ArrayExpression` did not implement the interface for its mapping keys: when a dynamic key expression resolves to a `Stringable` object, `ArrayExpression::compile()` emits a raw `(string)` cast (via `StringCastUnary` for `ContextVariable` keys, and no cast at all for richer key expressions). PHP then invokes `__toString()` directly, without ever calling `SandboxExtension::ensureToStringAl
VulDB
twigphp Twig __toString sandbox
vuldb·2026-06-06
CVE-2026-47732 [CRITICAL] twigphp Twig __toString sandbox
A vulnerability marked as critical has been reported in twigphp Twig. This issue affects the function __toString. The manipulation leads to sandbox issue.
This vulnerability is referenced as CVE-2026-47732. Remote exploitation of the attack is possible. No exploit is available.
It is suggested to upgrade the affected component.
GHSA
Twig: Sandbox: multiple `__toString()` policy bypasses via unguarded string coercion points
ghsa·2026-06-05
CVE-2026-47732 [HIGH] CWE-20 Twig: Sandbox: multiple `__toString()` policy bypasses via unguarded string coercion points
Twig: Sandbox: multiple `__toString()` policy bypasses via unguarded string coercion points
### Description
`SandboxNodeVisitor` enforces `SecurityPolicy::checkMethodAllowed()` for implicit `__toString()` calls by wrapping selected AST nodes in `CheckToStringNode`. The set of wrapped nodes is incomplete, and several Twig language constructs still trigger PHP string coercion on a `Stringable` operand without first consulting the policy. A sandboxed template author can therefore invoke `__toString()` on any object reachable in the render context, even when `__toString` on its class is not allowlisted.
Confirmed bypass vectors:
- Conditional expressions (`a ? b : c`, `a ?: b`, `a ?? b`) used as the input of a string-coercing filter or as a filter/function argument.
- The `matches` operato
No detection rules found.
No public exploits indexed.
Bugzilla
CVE-2026-47732 phpMyAdmin: Twig: Security policy bypass leads to information disclosure [fedora-all]
bugzilla·2026-07-15·CVSS 7.1
CVE-2026-47732 [HIGH] CVE-2026-47732 phpMyAdmin: Twig: Security policy bypass leads to information disclosure [fedora-all]
CVE-2026-47732 phpMyAdmin: Twig: Security policy bypass leads to information disclosure [fedora-all]
Disclaimer: Community trackers are created by Red Hat Product Security team on a best effort basis. Package maintainers are required to ascertain if the flaw indeed affects their package, before starting the update process.
Twig is a template language for PHP. Prior to 3.26.0, several Twig language constructs trigger PHP string coercion on a Stringable operand without consulting SecurityPolicy::checkMethodAllowed(), allowing a sandboxed template author to invoke __toString() on objects reachable in the render context through conditional expressions, comparison operators, tests, template-loading tags, dynamic attribute names, spread arguments, the do tag, and the .. range operator. This is
Bugzilla
CVE-2026-47732 phpMyAdmin: Twig: Security policy bypass leads to information disclosure [epel-all]
bugzilla·2026-07-15·CVSS 7.1
CVE-2026-47732 [HIGH] CVE-2026-47732 phpMyAdmin: Twig: Security policy bypass leads to information disclosure [epel-all]
CVE-2026-47732 phpMyAdmin: Twig: Security policy bypass leads to information disclosure [epel-all]
Disclaimer: Community trackers are created by Red Hat Product Security team on a best effort basis. Package maintainers are required to ascertain if the flaw indeed affects their package, before starting the update process.
Twig is a template language for PHP. Prior to 3.26.0, several Twig language constructs trigger PHP string coercion on a Stringable operand without consulting SecurityPolicy::checkMethodAllowed(), allowing a sandboxed template author to invoke __toString() on objects reachable in the render context through conditional expressions, comparison operators, tests, template-loading tags, dynamic attribute names, spread arguments, the do tag, and the .. range operator. This issu
Bugzilla
CVE-2026-47732 twig/twig: Twig: Security policy bypass leads to information disclosure
bugzilla·2026-07-14·CVSS 7.1
CVE-2026-47732 [HIGH] CVE-2026-47732 twig/twig: Twig: Security policy bypass leads to information disclosure
CVE-2026-47732 twig/twig: Twig: Security policy bypass leads to information disclosure
Twig is a template language for PHP. Prior to 3.26.0, several Twig language constructs trigger PHP string coercion on a Stringable operand without consulting SecurityPolicy::checkMethodAllowed(), allowing a sandboxed template author to invoke __toString() on objects reachable in the render context through conditional expressions, comparison operators, tests, template-loading tags, dynamic attribute names, spread arguments, the do tag, and the .. range operator. This issue is fixed in version 3.26.0.
2026-07-14
Published