Description
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.
Published: 2026-07-14
Score: 7.1 High
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

Twig is a PHP templating system that enforces a sandbox policy restricting how objects can be converted to strings. Before version 3.27.0 the sandbox's __toString checks were incomplete for Traversable objects passed to the join, replace, or used as operands of in and not in operators. As a result, Stringable objects inside those Traversable values could be coerced into strings without the sandbox policy being consulted, creating a mechanism for attackers to bypass the sandbox. This weakness, which is corrected in Twig 3.27.0, aligns with CWE‑693 and CWE‑863.

Affected Systems

All Twig versions distributed by the twigphp project that precede 3.27.0 are affected. The fix was delivered in the 3.27.0 release and applies to all earlier releases regardless of major version. Applications embedding Twig whose templates may pass Traversable objects to the join or replace filters or to in/not in logic must be considered vulnerable until updated.

Risk and Exploitability

The CVSS base score of 7.1 indicates a High severity. The EPSS score of less than 1 % indicates a low probability of widespread exploitation. The vulnerability is not listed in CISA’s KEV catalog. The likely attack vector involves an attacker supplying or manipulating a template that passes Traversable objects to the vulnerable filters or operators, thereby bypassing the sandbox.

Generated by OpenCVE AI on July 31, 2026 at 04:31 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade Twig to version 3.27.0 or later to apply the official fix.
  • If an upgrade cannot be performed immediately, sanitize or replace any Traversable objects passed to join, replace, in, or not in filters so that they contain only non‑Stringable values before rendering.
  • As a temporary measure, disable or tightly constrain sandbox checks for the vulnerable filters, or restrict template input to trusted sources until a patch is deployed.

Generated by OpenCVE AI on July 31, 2026 at 04:31 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-8x9c-rmqh-456c Twig: Sandbox `__toString()` policy bypass via `Traversable` in `join` and `replace` filters
History

Wed, 15 Jul 2026 18:45:00 +0000

Type Values Removed Values Added
First Time appeared Twigphp
Twigphp twig
Vendors & Products Twigphp
Twigphp twig

Wed, 15 Jul 2026 13:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'none', 'Technical Impact': 'partial'}, 'version': '2.0.3'}


Tue, 14 Jul 2026 21:45:00 +0000

Type Values Removed Values Added
Description 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.
Title Twig: Sandbox `__toString()` policy bypass via `Traversable` in `join` and `replace` filters
Weaknesses CWE-693
CWE-863
References
Metrics cvssV4_0

{'score': 7.1, 'vector': 'CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:L/VA:N/SC:N/SI:N/SA:N'}


cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-07-15T12:50:42.588Z

Reserved: 2026-05-22T20:57:10.975Z

Link: CVE-2026-48807

cve-icon Vulnrichment

Updated: 2026-07-15T12:47:13.670Z

cve-icon NVD

No data.

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-07-31T04:45:17Z

Weaknesses
  • CWE-693

    Protection Mechanism Failure

  • CWE-863

    Incorrect Authorization