Skip to main content
Press slash or control plus K to focus the search. Use the arrow keys to navigate results and press enter to open a threat.
Reconnecting to live updates…

GHSA-5v5v-ww74-355v: Twig: Sandbox `__toString()` policy bypass via dynamic mapping keys

0
Medium
Published: 06/30/2026 (06/30/2026, 18:42:49 UTC)
Source: GCVE Database
Product: twig/twig

Description

A vulnerability in twig/twig prior to version 3.27.0 allows sandboxed templates to bypass the sandbox __toString() policy via dynamic mapping keys. This occurs because dynamic keys in array expressions were not properly checked before PHP coerced them to strings, enabling unauthorized __toString() calls. The issue was fixed by marking dynamic mapping keys as string-coercion sites, ensuring sandbox policy enforcement before string conversion.

Affected software

Packagistghsa
twig/twig
Affected versions
<3.27.0

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

AILast updated: 06/30/2026, 23:47:14 UTC

Technical Analysis

This vulnerability is a residual bypass of a previous fix for unguarded __toString() calls in twig/twig. In version 3.26.0, the sandbox visitor was extended to wrap child nodes coerced to strings with a check node, but ArrayExpression did not implement the required interface for its dynamic mapping keys. When a dynamic key resolves to a Stringable object, PHP invokes __toString() directly without sandbox policy checks, allowing sandboxed template authors to trigger __toString() on any object reachable in the render context. The fix in version 3.27.0 adds the interface to ArrayExpression's dynamic keys, ensuring sandbox policy checks occur before string coercion, closing the enforcement gap.

Potential Impact

The vulnerability allows unauthorized disclosure of data returned by __toString() methods on objects accessible in the sandboxed template context. This is a policy enforcement gap that can lead to information leakage within sandboxed Twig templates. Direct output of objects is correctly blocked, so the impact is limited to dynamic mapping keys used as string keys in arrays.

Mitigation Recommendations

A fix is available in twig/twig version 3.27.0 that properly enforces sandbox __toString() policy on dynamic mapping keys. Users should upgrade to version 3.27.0 or later to remediate this vulnerability. No other mitigation is indicated.

Pro Console: star threats, build custom feeds, automate alerts via Slack, email & webhooks.Upgrade to Pro

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: 06/30/2026, 23:47:14 UTC

Last updated: 06/30/2026, 23:47:14 UTC

Views: 2

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

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

Breach by OffSeqOFFSEQFRIENDS — 25% OFF

Check if your credentials are on the dark web

Instant breach scanning across billions of leaked records. Free tier available.

Scan now
OffSeq TrainingCredly Certified

Lead Pen Test Professional

Technical5-day eLearningPECB Accredited
View courses