CVE-2026-133763 in Twig
Summary
by MITRE • 11/24/2026
The sandbox checks that a template may call toString() on an object before converting it to a string. For an object, the is true test evaluates to the object itself, and that result wasn't checked. A sandboxed template could therefore print an object through a denied toString() method:
{{ obj is true }}
The same applies when the result is concatenated or passed to a filter. No tag needs to be allowed. A test in a boolean context, like {% if obj is true %}, isn't affected, since it doesn't convert the object to a string.
The sandbox now checks the result of tests like the result of filters and functions.
If you want to get the best quality for vulnerability data then you always have to consider VulDB.
Analysis
by VulDB Data Team • 11/24/2026
This vulnerability represents a logic error within the template engine's sandboxing mechanism that allows for unauthorized information disclosure through improper validation of boolean test results. The core technical flaw lies in how the system handles objects when they are subjected to specific type checks, particularly the is true condition. In many programming contexts and templating languages, an object evaluation often returns the object instance itself rather than a simple boolean value if not explicitly coerced or validated against strict truthiness rules that account for custom methods like toString(). The sandbox implementation failed to verify whether this returned object was safe before proceeding with string conversion operations. Consequently, when a template author invokes a test such as obj is true within a context that requires string representation, the engine may inadvertently call the object's toString() method without verifying if that specific method has been explicitly whitelisted or denied by the security policy.
The operational impact of this flaw is significant for applications relying on strict sandboxing to prevent code injection or unauthorized data access. An attacker who can control input passed into a templated view could exploit this gap to trigger the execution of arbitrary methods defined on that object, specifically those intended to be blocked by the sandbox configuration. This bypasses the expected security boundaries because the vulnerability does not require any special tags or permissions; it exploits standard template syntax like variable interpolation or concatenation where implicit string conversion occurs. By crafting a payload that forces an object with a dangerous toString() implementation into this specific evaluation path, an attacker can achieve unauthorized output injection, potentially leaking sensitive internal state information or executing client-side scripts if the rendered content is interpreted by a browser environment.
From a classification perspective, this issue aligns closely with CWE-94 Improper Control of Generation of Code (Code Injection) and CWE-200 Exposure of Sensitive Information to an Unauthorized Actor. The failure stems from insufficient validation of user-controlled data before processing it through security-sensitive functions, which is also characteristic of logic flaws often mapped to ATT&CK techniques involving script injection or unauthorized access to system resources. The specific mechanism involves bypassing a control flow check that should have validated the safety of method invocations during type coercion processes. This highlights a common pitfall in sandbox design where developers assume that checking for allowed tags is sufficient, neglecting the implicit behaviors triggered by standard operators and filters that do not require explicit tag authorization but still interact with object methods.
To mitigate this vulnerability, it is essential to enforce strict validation of all method calls resulting from template expressions, regardless of whether they are part of an explicitly tagged block or a standard expression evaluation. The sandbox must intercept the result of tests like obj is true and verify that any subsequent string conversion does not invoke prohibited methods such as toString(). Developers should implement explicit checks for object types before allowing them to be cast to strings within sandboxes, ensuring that only whitelisted classes are permitted to undergo implicit or explicit serialization processes. Additionally, adopting a principle of least privilege in template configuration by default-deny-ing all method calls except those explicitly required can prevent such bypasses. Regular security audits focusing on edge cases in type coercion and string conversion logic will help identify similar gaps where sandbox boundaries might be circumvented through unexpected code paths.