Join the Cyber Forum: Threat Intel on May 12, 2026 to learn how AI is reshaping threat defense.Join the Virtual Cyber Forum: Threat IntelRegister Now
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • AI Data Pipelines
      Security Data Pipeline for AI SIEM and Data Optimization
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2021-26120

CVE-2021-26120: Smarty Template Engine RCE Vulnerability

CVE-2021-26120 is a remote code execution vulnerability in Smarty template engine that allows attackers to inject malicious code via unexpected function names. This article covers technical details, affected versions, and mitigation.

Published: February 25, 2026

CVE-2021-26120 Overview

CVE-2021-26120 is a critical code injection vulnerability affecting Smarty, a popular PHP template engine. The flaw exists in versions prior to 3.1.39 and allows attackers to inject arbitrary code via an unexpected function name after a {function name= substring within Smarty templates. This vulnerability enables remote attackers to execute arbitrary PHP code on systems running vulnerable Smarty installations without requiring authentication or user interaction.

Critical Impact

This code injection vulnerability allows unauthenticated remote attackers to execute arbitrary PHP code on affected systems, potentially leading to complete server compromise, data theft, or use of the server for further attacks.

Affected Products

  • Smarty versions prior to 3.1.39
  • Debian Linux 9.0
  • Debian Linux 10.0
  • Debian Linux 11.0

Discovery Timeline

  • 2021-02-22 - CVE-2021-26120 published to NVD
  • 2024-11-21 - Last updated in NVD database

Technical Details for CVE-2021-26120

Vulnerability Analysis

This vulnerability is classified as CWE-94 (Improper Control of Generation of Code, or Code Injection). The flaw resides in how Smarty parses and processes the {function} tag within templates. When processing template directives, the Smarty compiler fails to properly validate function names that follow the {function name= syntax. An attacker can craft a malicious template containing unexpected characters or constructs after this substring, which the parser incorrectly interprets as legitimate code to be executed.

The vulnerability is particularly dangerous because Smarty templates are compiled into PHP code for execution. When malicious input bypasses the validation mechanisms, the injected code is incorporated directly into the compiled template and subsequently executed with the same privileges as the PHP process handling the request.

Root Cause

The root cause of CVE-2021-26120 lies in insufficient input validation within Smarty's template compiler. The {function} tag handler does not adequately sanitize or validate the function name parameter before incorporating it into the generated PHP code. This allows specially crafted function names to break out of the intended context and inject arbitrary PHP statements into the compiled template output.

Attack Vector

The attack vector is network-based and requires no authentication or user interaction. An attacker can exploit this vulnerability by:

  1. Identifying a web application that uses a vulnerable version of Smarty
  2. Finding an input vector that allows template content to be influenced (e.g., user-controlled template data, CMS functionality, or template injection points)
  3. Injecting a malicious {function name= directive with crafted content designed to escape the function definition context
  4. Triggering the template compilation process, which incorporates the malicious code into the generated PHP
  5. The injected code executes when the compiled template is processed

The vulnerability mechanism exploits the template parsing logic where function name validation is insufficient. When a malformed {function name= directive is encountered, the parser fails to properly sanitize the subsequent content, allowing PHP code injection into the compiled template output. For technical details on the specific parsing flaw, see the Smarty CHANGELOG.

Detection Methods for CVE-2021-26120

Indicators of Compromise

  • Unusual {function name= patterns in template files or web request logs containing special characters or PHP syntax
  • Unexpected PHP code execution from web server processes
  • Modified or newly created files in temporary directories used by Smarty for compiled templates
  • Web server error logs showing parsing errors or unusual template compilation failures
  • Outbound network connections from the web server to unknown destinations

Detection Strategies

  • Deploy web application firewall (WAF) rules to detect and block requests containing suspicious {function name= patterns with injection attempts
  • Monitor Smarty compiled template directories for unexpected file modifications or malicious PHP code
  • Implement file integrity monitoring on template directories and Smarty cache locations
  • Analyze web application logs for unusual template-related requests or error patterns
  • Use static code analysis tools to scan templates for potentially malicious {function} tag usage

Monitoring Recommendations

  • Enable verbose logging for PHP applications using Smarty to capture template compilation events
  • Configure intrusion detection systems (IDS) to alert on patterns associated with PHP code injection
  • Implement real-time monitoring of web server process behavior for signs of code execution exploitation
  • Set up alerts for any changes to compiled template files outside of normal deployment windows

How to Mitigate CVE-2021-26120

Immediate Actions Required

  • Upgrade Smarty to version 3.1.39 or later immediately on all affected systems
  • Audit all templates for potentially malicious {function} tag usage
  • Review and restrict user input that may influence template content
  • Implement input validation and sanitization for any user-controllable data that could reach template processing
  • Consider temporarily disabling dynamic template features if immediate patching is not possible

Patch Information

The vulnerability has been addressed in Smarty version 3.1.39. Organizations should upgrade to this version or later to remediate the vulnerability. The fix implements proper validation of function names within the {function} tag handler, preventing the injection of arbitrary code through malformed function names.

For detailed patch information, refer to the Smarty CHANGELOG. Distribution-specific patches are available for Debian systems as documented in DSA-5151 and Gentoo GLSA 202105-06.

Workarounds

  • Implement strict input validation to reject any template content containing {function directives from untrusted sources
  • Use a web application firewall (WAF) to filter requests containing suspicious Smarty template syntax
  • Restrict file system permissions on template directories to prevent unauthorized template modifications
  • Disable user-controllable template functionality if upgrading is not immediately feasible
  • Consider sandboxing Smarty template compilation in isolated environments with limited privileges
bash
# Verify installed Smarty version
composer show smarty/smarty | grep versions

# Upgrade Smarty to patched version
composer require smarty/smarty:^3.1.39

# For Debian systems, apply security updates
sudo apt-get update && sudo apt-get install --only-upgrade smarty3

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeRCE

  • Vendor/TechSmarty

  • SeverityCRITICAL

  • CVSS Score9.8

  • EPSS Probability75.58%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityHigh
  • CWE References
  • CWE-94
  • Technical References
  • GitHub Changelog Document

  • Debian LTS Security Announcement

  • Debian LTS Security Update

  • Debian Security Advisory DSA-5151
  • Vendor Resources
  • Gentoo GLSA 202105-06
  • Related CVEs
  • CVE-2024-35226: Smarty Template Engine RCE Vulnerability

  • CVE-2021-29454: Smarty Template Engine RCE Vulnerability

  • CVE-2021-26119: Smarty Sandbox Escape Vulnerability
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English