The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
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
    • 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-3603

CVE-2021-3603: PHPMailer RCE Vulnerability

CVE-2021-3603 is a remote code execution flaw in PHPMailer 6.4.1 and earlier that allows untrusted code execution through function name manipulation. This article covers technical details, affected versions, and mitigation.

Published: February 25, 2026

CVE-2021-3603 Overview

CVE-2021-3603 is a code injection vulnerability affecting PHPMailer versions 6.4.1 and earlier. The vulnerability exists in the validateAddress() function where the $patternselect parameter, when set to the default value 'php', can be hijacked by a malicious function of the same name injected into the global namespace. If an attacker can inject a function called php into the host project's scope through other means, that malicious function will be called in preference to PHPMailer's built-in validator.

Critical Impact

Successful exploitation allows execution of arbitrary untrusted code if attackers can inject a function named 'php' into the global namespace, potentially leading to complete application compromise.

Affected Products

  • PHPMailer versions up to and including 6.4.1
  • Fedora 33 (via PHPMailer packages)
  • Fedora 34 (via PHPMailer packages)

Discovery Timeline

  • 2021-06-17 - CVE-2021-3603 published to NVD
  • 2024-11-21 - Last updated in NVD database

Technical Details for CVE-2021-3603

Vulnerability Analysis

This vulnerability stems from PHP's callable resolution behavior combined with PHPMailer's validation logic. When validateAddress() is called with the default $patternselect value of 'php', the function checks if this string is callable. In PHP, if a function named 'php' exists in the global namespace, it will be treated as callable and invoked instead of PHPMailer's intended built-in validation logic.

The attack requires a precondition where malicious code has already been injected into the application's global namespace (through a separate vulnerability or compromise). Once such code defines a function called php, any subsequent email address validation through PHPMailer will execute that attacker-controlled function with the email address as an argument.

Root Cause

The root cause is CWE-829: Inclusion of Functionality from Untrusted Control Sphere. PHPMailer's validation logic used simple string-based callable detection without properly restricting function resolution to its own namespace. The is_callable() check in PHP returns true for any string that matches a defined function name in the global scope, allowing external code to override expected behavior.

Attack Vector

The vulnerability is exploited over the network when applications using vulnerable PHPMailer versions process user-supplied email addresses. The attack chain requires:

  1. An attacker first injects a malicious php function into the application's global namespace (via a separate code injection vulnerability, autoloader poisoning, or compromised dependency)
  2. When PHPMailer's validateAddress() is called with the default validator setting
  3. PHP's callable resolution finds the attacker's php function
  4. The malicious function executes with the email address parameter, potentially leading to further code execution

The security patch in PHPMailer 6.5.0 addresses this by denying the use of simple strings as validator function names entirely:

php
         if (null === $patternselect) {
             $patternselect = static::$validator;
         }
-        //Don't allow overriding built-in validators with callables
-        if (
-            is_callable($patternselect) &&
-            //It's callable and not a string, or it's a string callable that's not a built-in pattern
-            (!is_string($patternselect) || !in_array(strtolower($patternselect), ['php', 'pcre', 'pcre8', 'html5']))
-        ) {
+        //Don't allow strings as callables, see SECURITY.md and CVE-2021-3603
+        if (is_callable($patternselect) && !is_string($patternselect)) {
             return call_user_func($patternselect, $address);
         }
         //Reject line breaks in addresses; it's valid RFC5322, but not RFC5321

Source: GitHub Commit 45f3c18

Detection Methods for CVE-2021-3603

Indicators of Compromise

  • Presence of unexpected function definitions named php in application code or included files
  • Unusual autoloader behavior or modified Composer files introducing rogue dependencies
  • Unexpected code execution patterns during email validation operations
  • Web application logs showing anomalous behavior when processing email addresses

Detection Strategies

  • Scan deployed applications for PHPMailer versions prior to 6.5.0 using dependency scanning tools
  • Monitor for unauthorized function definitions in the global namespace, particularly functions named php, pcre, pcre8, or html5
  • Implement static code analysis to detect potential namespace pollution vulnerabilities
  • Review application logs for unusual email validation failures or exceptions

Monitoring Recommendations

  • Enable PHP error logging to capture unexpected function calls during email operations
  • Implement file integrity monitoring on application codebases to detect injected functions
  • Use runtime application self-protection (RASP) solutions to monitor callable invocations
  • Set up alerts for changes to Composer lock files or autoloader configurations

How to Mitigate CVE-2021-3603

Immediate Actions Required

  • Upgrade PHPMailer to version 6.5.0 or later immediately
  • Audit your application's global namespace for any unexpected function definitions
  • Review all dependencies and third-party code that may inject functions into the global namespace
  • Implement strict autoloading practices to prevent namespace pollution

Patch Information

The vulnerability was mitigated in PHPMailer 6.5.0 by fundamentally changing how validator function names are handled. The fix denies the use of simple strings as validator function names altogether, only allowing non-string callables (such as closures or arrays representing object methods). This prevents any possibility of global namespace function hijacking. The security patch is available via the official PHPMailer GitHub repository. Fedora users should apply updates from the Fedora package announcements.

Workarounds

  • If immediate upgrade is not possible, explicitly set a non-string validator callable in your PHPMailer configuration
  • Implement namespace isolation by wrapping PHPMailer usage in a dedicated namespace
  • Add runtime checks to verify no rogue php function exists before calling validateAddress()
  • Consider using the 'pcre8' or 'html5' validators with explicit namespace prefixes as temporary mitigation
bash
# Update PHPMailer via Composer
composer require phpmailer/phpmailer:^6.5.0

# Verify installed version
composer show phpmailer/phpmailer | grep versions

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

  • Vulnerability Details
  • TypeRCE

  • Vendor/TechPhpmailer

  • SeverityHIGH

  • CVSS Score8.1

  • EPSS Probability0.40%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H
  • Impact Assessment
  • ConfidentialityHigh
  • IntegrityNone
  • AvailabilityHigh
  • CWE References
  • CWE-829
  • Technical References
  • Fedora Package Announcement

  • Fedora Package Announcement

  • Huntr Bounty Report
  • Vendor Resources
  • GitHub Commit Update
  • Related CVEs
  • CVE-2020-36326: PHPMailer RCE Vulnerability via Phar
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