Advisory Database
  • Advisories
  • Dependency Scanning
  1. composer
  2. ›
  3. twig/twig
  4. ›
  5. CVE-2026-46634

CVE-2026-46634: Twig: `template_from_string()` escapes a SourcePolicy-driven sandbox via synthesized template name

May 21, 2026

When the sandbox is enabled selectively via SourcePolicyInterface (and not globally), a sandboxed template that is allowed to call template_from_string and include can render an arbitrary inner template with no security policy enforcement.

Environment::createTemplate() compiles the inner string under a synthesized name (__string_template__<hash>), so a name/path-based SourcePolicy returns false for it, and the inner template’s checkSecurity() becomes a no-op. From a template the integrator believes is sandboxed, an attacker can use any tag/filter/function (including constant() to read secrets, or |map("system") to execute shell commands).

References

  • github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2026-46634.yaml
  • github.com/advisories/GHSA-24x9-r6q4-q93w
  • github.com/twigphp/Twig/security/advisories/GHSA-24x9-r6q4-q93w
  • nvd.nist.gov/vuln/detail/CVE-2026-46634
  • symfony.com/cve-2026-46634

Code Behaviors & Features

Detect and mitigate CVE-2026-46634 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →

Affected versions

All versions starting from 3.9.0 before 3.26.0

Fixed versions

  • 3.26.0

Solution

Upgrade to version 3.26.0 or above.

Weakness

  • CWE-693: Protection Mechanism Failure

Source file

packagist/twig/twig/CVE-2026-46634.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 11 Nov 2026 00:16:05 +0000.