All vulnerabilities

Packagist

CVE-2026-133764

Sandbox `__toString()` policy bypass via the input of custom tests

Severity
Low 2.3
Published
24 Nov 2026
Last changed
24 Nov 2026
Added to UpHeron
24 Nov 2026
Fixed in
3.31.1
Weakness
Protection mechanism failure (CWE-693)Incorrect authorization (CWE-863)
Attack
Over the network · Only under certain conditions · Needs a user account · No user action needed
Attacker can
Read some data
CVSS vector
CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N
Sources
CVE Program

Description

The sandbox checks that a template may call toString() on an object before converting it to a string. It didn't check the input of tests. The PHP callable of a test may convert this input to a string, for example when its parameter is typed as string. PHP then calls toString() on an object without the sandbox checking it first:

{{ obj is upperish }}

Applications are affected when they register such a test and allow it in the sandbox. No built-in test is affected.

The sandbox now checks the input of tests like the input of filters. The built-in tests that never convert their input to a string still skip the check.

From the CVE Program.

Affected software

SoftwareAffected versions
twig/twigPackagist · osv:Packagist:twig/twig
  • Every version before 3.31.1

About twig/twig

Monthly downloads (Packagist)
14,503,338Packagist, 24 Nov 2026
Total downloads (Packagist)
517,678,663Packagist, 24 Nov 2026

References

  • CVE.org https://www.cve.org/CVERecord?id=CVE-2026-133764