---
id: CVE-2026-46633
title: 'Twig: PHP code injection via `{% use %}` template name'
summary: >-
  Twig is a template language for PHP. Starting in 1.15.1 and prior to 3.26.0,
  Compiler::string() does not escape single quotes when a template name from a
  {% use %} tag is placed inside a PHP single-quoted string literal, allowing a
  craft…
severity: high
cvss: 8.7
cvssVector: 'CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N'
cvssSource: cna
cwe:
  - CWE-94
vendor: twigphp
product: Twig
affected:
  - 'Twig >= 1.15.1, < 3.26.0'
ssvc:
  exploitation: none
  automatable: 'no'
  technicalImpact: total
  timestamp: '2026-07-15T00:00:00+00:00'
published: '2026-07-14'
updated: '2026-11-04'
sourceUpdated: '2026-11-04T00:01:29.155Z'
source: CVEORG
sourceUrl: 'https://www.cve.org/CVERecord?id=CVE-2026-46633'
references:
  - url: 'https://github.com/twigphp/Twig/security/advisories/GHSA-7p85-w9px-jpjp'
    label: 'https://github.com/twigphp/Twig/security/advisories/GHSA-7p85-w9px-jpjp'
  - url: >-
      https://github.com/twigphp/Twig/commit/679447fa29083043665482ccf7d64372472621b8
    label: >-
      https://github.com/twigphp/Twig/commit/679447fa29083043665482ccf7d64372472621b8
  - url: >-
      https://github.com/twigphp/Twig/commit/a2c6db7ea7d2c90923e6708019ec1442526d1c30
    label: >-
      https://github.com/twigphp/Twig/commit/a2c6db7ea7d2c90923e6708019ec1442526d1c30
  - url: >-
      https://github.com/twigphp/Twig/commit/e9ff55f6910832428e48a35b2e0748189ad49ae3
    label: >-
      https://github.com/twigphp/Twig/commit/e9ff55f6910832428e48a35b2e0748189ad49ae3
  - url: 'https://gist.github.com/vladko312/d61b950f168c791db4786b83dc7a81e6'
    label: 'https://gist.github.com/vladko312/d61b950f168c791db4786b83dc7a81e6'
  - url: >-
      https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2026-46633.yaml
    label: >-
      https://github.com/FriendsOfPHP/security-advisories/blob/master/twig/twig/CVE-2026-46633.yaml
  - url: 'https://github.com/twigphp/Twig/releases/tag/v3.26.0'
    label: 'https://github.com/twigphp/Twig/releases/tag/v3.26.0'
  - url: 'https://symfony.com/cve-2026-46633'
    label: 'https://symfony.com/cve-2026-46633'
  - url: 'https://nvd.nist.gov/vuln/detail/CVE-2026-46633'
  - url: 'https://github.com/advisories/GHSA-7p85-w9px-jpjp'
tags:
  - cve.org
  - ghsa
  - composer
epss: 0.00774
epssPercentile: 0.55909
aliases:
  - GHSA-7p85-w9px-jpjp
ecosystem: composer
patched:
  - twig/twig 3.26.0
scores:
  cna: 8.7
  ghsa: 9.8
ingestedAt: '2026-11-04T00:59:33.232Z'
---

## Overview

Twig is a template language for PHP. Starting in 1.15.1 and prior to 3.26.0, Compiler::string() does not escape single quotes when a template name from a {% use %} tag is placed inside a PHP single-quoted string literal, allowing a crafted template name to terminate the string and inject arbitrary PHP expressions into the compiled cache file. This issue is fixed in version 3.26.0.

## Affected

- `Twig >= 1.15.1, < 3.26.0`

## Remediation

Refer to the linked advisories for vendor-supplied fixes and affected version ranges.

## Package advisory (CVE-2026-46633)

Affected packages:

- `twig/twig >= 1.15.1, < 3.26.0`

Patched in:

- `twig/twig 3.26.0`

Source: https://github.com/advisories/GHSA-7p85-w9px-jpjp
