CVE-2021-3603

8.1 HIGH

📋 TL;DR

PHPMailer versions 6.4.1 and earlier contain a function name collision vulnerability in the email address validator. If a malicious function named 'php' exists in the global namespace, it will be executed instead of the built-in validator when validating email addresses. This affects any application using PHPMailer with the default validator configuration.

💻 Affected Systems

Products:
  • PHPMailer
Versions: 6.4.1 and earlier
Operating Systems: All operating systems running PHP
Default Config Vulnerable: ⚠️ Yes
Notes: Only vulnerable when using the default 'php' validator in validateAddress() function.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution if an attacker can inject a malicious 'php' function into the global namespace through other vulnerabilities, potentially leading to complete system compromise.

🟠

Likely Case

Limited impact requiring another vulnerability to inject malicious code first; most commonly would enable privilege escalation or persistence mechanisms.

🟢

If Mitigated

No impact if proper input validation and namespace isolation are implemented, or if the application doesn't use the vulnerable validator.

🌐 Internet-Facing: MEDIUM - Requires another vulnerability to be exploitable, but internet-facing systems are more likely to have multiple attack vectors.
🏢 Internal Only: LOW - Still requires another vulnerability; internal systems typically have fewer attack surfaces.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: HIGH

Exploitation requires first injecting a malicious 'php' function into the global namespace through another vulnerability.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 6.5.0 and later

Vendor Advisory: https://github.com/PHPMailer/PHPMailer/commit/45f3c18dc6a2de1cb1bf49b9b249a9ee36a5f7f3

Restart Required: No

Instructions:

1. Update PHPMailer to version 6.5.0 or later using composer: 'composer require phpmailer/phpmailer:^6.5.0' 2. Replace the PHPMailer directory with the updated version if not using composer. 3. Test email functionality.

🔧 Temporary Workarounds

Change validator method

all

Set the validator to a non-'php' method before calling validateAddress()

$mailer->validator = 'regex'; // or 'auto', 'pcre', 'html5'

Namespace isolation

all

Ensure no untrusted code can define functions in the global namespace

🧯 If You Can't Patch

  • Implement strict input validation and sanitization for all user inputs
  • Use web application firewall rules to block suspicious function definitions

🔍 How to Verify

Check if Vulnerable:

Check PHPMailer version in composer.json or the PHPMailer class file header

Check Version:

grep -r 'PHPMailer' composer.lock 2>/dev/null || grep 'VERSION' vendor/phpmailer/phpmailer/src/PHPMailer.php 2>/dev/null || echo 'Check manually'

Verify Fix Applied:

Verify PHPMailer version is 6.5.0 or later and test email validation functionality

📡 Detection & Monitoring

Log Indicators:

  • Unexpected function calls to 'php' in application logs
  • Errors in email validation processes

Network Indicators:

  • Unusual outbound connections following email validation attempts

SIEM Query:

source="application_logs" AND ("php function call" OR "validateAddress error")

🔗 References

📤 Share & Export