Twig has unguarded calls to `__isset()` and to array-accesses when the sandbox is enabled
Impact
In a sandbox, and attacker can access attributes of Array-like objects as they were not checked by the security policy. They are now checked via the property policy and the __isset() method is now called after the security check. This is a BC break.
Source excerpt · OSVAffected packages
Start with the recorded fix for your release branch. Check your installed version and test compatibility before upgrading. Fixing this advisory does not rule out other vulnerabilities in the release.
| Affected range | Recorded fix |
|---|---|
| Earlier releases before 3.11.2Ecosystem versions | 3.11.2 |
| From 3.12 before 3.14.1Ecosystem versions | 3.14.1 |
Version evidence: OSV · GHSA-jjxq-ff2g-95vh
View original version evidence (223 explicit versions)
Original source description
Description
In a sandbox, and attacker can access attributes of Array-like objects as they were not checked by the security policy.
They are now checked via the property policy and the __isset() method is now called after the security check.
This is a BC break.
Resolution
The sandbox mode now ensures access to array-like's properties is allowed.
The patch for this issue is available here for the 3.11.x branch, and here for the 3.x branch.
Credits
We would like to thank Jamie Schouten for reporting the issue and Nicolas Grekas for providing the fix.
References
- Security advisory github.com/twigphp/Twig/security/advisories/GHSA-jjxq-ff2g-95vh
- Security advisory nvd.nist.gov/vuln/detail/CVE-2024-51755
- Patch github.com/twigphp/Twig/commit/831c148e786178e5f2fde9db67266be3bf241c21
- Security advisory github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2024-51755.yaml
- Source reference github.com/twigphp/Twig
- Source reference symfony.com/blog/unguarded-calls-to-__isset-and-to-array-accesses-when-the-sandbox-is-enabled