CVE-2026-46627

Twig: Sandbox resource exhaustion via unbounded `for` / `range()`

Published Jul 14, 2026 CVSS 4.0 · 7.1 High EPSS < 1% KEV · Not listed
Description
Twig is a template language for PHP. Prior to 3.26.0, the Twig sandbox does not prevent a template from consuming CPU, memory, or wall-clock time, even under the strictest allow-list, allowing untrusted templates to cause resource exhaustion. This issue is addressed in version 3.26.0 by documenting that the sandbox does not protect against resource exhaustion.

Analysis

AI-generated

Technical impact

Twig is a template language for PHP. Before version 3.26.0, the Twig sandbox fails to throttle CPU, memory, or wall‑clock consumption even when the strictest allow‑list is enforced. This flaw enables an attacker who can supply or control an untrusted template to execute unbounded `for` loops or `range()` constructs that exhaust server resources, resulting in a denial‑of‑service. The vulnerability is listed as CWE‑400.

Affected Systems

The vulnerability affects the Twig template engine from the TwigPHP project. All installations using Twig earlier than version 3.26.0 are susceptible. Users who render untrusted templates with the strictest sandbox settings must be aware of this limitation.

Risk and Exploitability

The CVSS score of 7.1 represents the severity of the vulnerability, while the EPSS score of less than 1% indicates a very low likelihood of exploitation. The vulnerability is not listed in CISA’s KEV catalog. Exploitation would require an attacker who can supply or control a Twig template rendered by the application, typically through user input or file uploads. The attack path relies on the sandbox’s inability to throttle resource usage, so the affected system must be able to process the template.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade Twig to version 3.26.0 or later to benefit from clarified resource limits documentation.
  • Implement application‑level safeguards, such as enforcing CPU, memory, or wall‑clock time limits on template rendering processes.
  • Avoid rendering untrusted templates in the application’s main process; instead, delegate sandboxed rendering to a separate container or process with strict resource quotas.

Generated by OpenCVE AI on August 1, 2026 at 09:09 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Debian DSA Debian DSA DSA-6311-1 php-twig security update
History
Type Values Removed Values Added
Metrics ssvc

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

Type Values Removed Values Added
First Time appeared Twigphp
Twigphp twig
Vendors & Products Twigphp
Twigphp twig
Type Values Removed Values Added
Description Twig is a template language for PHP. Prior to 3.26.0, the Twig sandbox does not prevent a template from consuming CPU, memory, or wall-clock time, even under the strictest allow-list, allowing untrusted templates to cause resource exhaustion. This issue is addressed in version 3.26.0 by documenting that the sandbox does not protect against resource exhaustion.
Title Twig: Sandbox resource exhaustion via unbounded `for` / `range()`
Weaknesses CWE-400
References
Metrics cvssV4_0

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

Weaknesses
  • CWE-400

    Uncontrolled Resource Consumption

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Jul 16, 2026, 3:03 PM
Reserved
May 15, 2026, 7:34 PM
Status
Analyzed
Published
Jul 14, 2026, 10:16 PM
Modified
Oct 24, 2026, 10:10 PM