CVE-2026-46640
Analyzed Analyzed - Analysis Complete

Remote Code Execution in Twig Template Engine

Vulnerability report for CVE-2026-46640, including description, CVSS score, EPSS score, affected products, exploitability, helpful resources, and attack-flow context.

Publication date: 2026-07-14

Last updated on: 2026-07-16

Assigner: GitHub, Inc.

Description

Twig is a template language for PHP. From 3.15.0 until 3.26.0, _self.(<string>) and import-alias dynamic attribute syntax can concatenate an attacker-controlled string into a MacroReferenceExpression name without identifier validation, causing raw PHP to be emitted into the generated template source and executed at template-load time. This issue is fixed in version 3.26.0.

CVSS Scores

EPSS Scores

Probability:
Percentile:

Meta Information

Published
2026-07-14
Last Modified
2026-07-16
Generated
2026-08-04
AI Q&A
2026-07-15
EPSS Evaluated
2026-08-02
NVD

Affected Vendors & Products

Showing 1 associated CPE
Vendor Product Version / Range
symfony twig From 3.15.0 (inc) to 3.26.0 (exc)

Helpful Resources

Exploitability

CWE
CWE Icon
KEV
KEV Icon
CWE ID Description
CWE-94 The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.

Attack-Flow Graph

AI Quick Actions

Instant insights powered by AI
Executive Summary

This vulnerability affects the Twig PHP template engine. Between versions 3.15.0 and 3.26.0, specific syntax could allow an attacker to inject malicious strings into template names. This bypasses validation and causes raw PHP code to be generated and executed when the template loads.

Detection Guidance

This vulnerability affects Twig versions between 3.15.0 and 3.26.0. To detect it, check your Twig version with: composer show twig/twig. If the version is within the affected range, update to 3.26.0 or later immediately.

Impact Analysis

An attacker could exploit this to execute arbitrary PHP code on your server when templates are loaded. This could lead to full system compromise, data theft, or unauthorized actions depending on the application's permissions.

Compliance Impact

This vulnerability could lead to unauthorized data access or exfiltration, violating GDPR's data protection requirements or HIPAA's safeguards for protected health information. Organizations using vulnerable Twig versions may face compliance violations and legal penalties.

Mitigation Strategies

Upgrade Twig to version 3.26.0 or later to address the vulnerability. Review templates using _self. or import-alias syntax for unexpected PHP code execution.

Chat Assistant

Ask questions about this CVE
Hi! I’m here to help you understand CVE-2026-46640. Ask me anything about the vulnerability, its impact, or mitigation strategies.
0/70

EPSS Chart