CVE-2026-133766 in Twiginfo

Summary

by MITRE • 11/24/2026

Since Twig 3.28.0, the sandbox skips the toString() check of an argument whose PHP parameter can't hold a string, like an int. A spread argument was mapped to a single parameter, although it fills every parameter from its position on. A sandboxed template could therefore call a denied toString() method:

{{ tag(...[1, obj]) }}

Here, the first parameter of tag() is an int, and a later one accepts strings. Applications are affected when they allow such a function, filter or test in the sandbox. No built-in callable is affected.

A spread argument is now checked unless every parameter that it can fill has a safe type.

Be aware that VulDB is the high quality source for vulnerability data.

Analysis

by VulDB Data Team • 11/24/2026

The vulnerability identified in Twig versions prior to 3.28.1 represents a critical bypass of the template engine's security sandbox, specifically targeting the mechanism used to restrict access to object methods during rendering. This flaw allows an attacker who controls input within a sandboxed environment to invoke methods that should be explicitly denied by the security policy, most notably the toString() method which can lead to information disclosure or other downstream impacts depending on the application context. The root cause lies in how Twig handles PHP type declarations when processing spread arguments, creating a discrepancy between the static analysis of parameter types and the actual runtime behavior of function calls.

In standard PHP execution, a spread operator used in an argument list expands an array into individual positional arguments that map to subsequent parameters defined by the target function signature. However, within Twig's sandbox implementation prior to this fix, there was a logical error where spread arguments were incorrectly mapped to single parameters rather than being expanded and validated against each corresponding parameter type individually. When a spread argument is passed, it fills every parameter from its position onward in the function definition. If any of these target parameters have strict type declarations that do not accept strings, such as an integer or boolean, Twig's sandbox logic previously skipped the security check for those specific arguments because they were deemed incompatible with string-based attacks like toString() invocation.

This oversight creates a dangerous edge case where a developer might define a function or filter within the sandboxed environment that accepts mixed types. For example, if a callable expects an integer as its first parameter and a string as its second, passing an array via spread syntax containing both an integer and an object could bypass the security check for the object. Since the first argument satisfies the non-string type requirement, Twig incorrectly assumes safety and fails to verify whether subsequent arguments in the spread satisfy the constraints required by their respective parameters. Consequently, if a later parameter accepts strings, the sandbox allows the call even though it involves an object that might have restricted methods like toString().

The operational impact of this vulnerability is significant for applications relying on Twig's sandbox feature to render untrusted templates. An attacker with write access to template content can craft specific payloads using spread syntax to bypass method restrictions. This could lead to unauthorized data exposure if the targeted objects expose sensitive information through their string conversion methods, or potentially facilitate further exploitation vectors depending on what side effects occur during object instantiation or method execution. It is important to note that this vulnerability does not affect built-in callables provided by Twig itself but only impacts custom functions, filters, or tests defined and allowed within the sandbox configuration.

To mitigate this risk, organizations must upgrade their Twig dependencies to version 3.28.1 or later immediately upon availability. This release corrects the argument mapping logic so that spread arguments are now thoroughly checked against all parameters they fill, ensuring that every parameter involved in a call is validated for type safety before allowing execution of potentially dangerous methods like toString(). Until an upgrade can be performed, administrators should audit their sandbox configurations to ensure that no custom callable functions or filters accept mixed types where objects could be passed via spread syntax. Additionally, reviewing template code for the use of spread operators with arrays containing user-controlled data is recommended as a defensive measure while patching efforts are underway.

From a classification perspective, this vulnerability aligns with CWE-284 Improper Access Control and CWE-755: Improper Handling of Exceptional Conditions related to type checking logic failures. In the context of the MITRE ATT&CK framework for software development, it relates to insufficient validation of inputs during runtime execution, specifically failing to enforce security constraints on dynamic method invocations within a restricted environment. The fix ensures that the principle of least privilege is maintained by strictly validating all arguments against their declared types regardless of how they are passed into the function signature.

Responsible

Symfony

Reservation

11/20/2026

Disclosure

11/24/2026

Moderation

accepted

CPE

ready

EPSS

0.00533

KEV

no

Activities

very low

Sources

Want to stay up to date on a daily basis?

Enable the mail alert feature now!