Critical Vulnerability in libphp-phpmailer: Untrusted Code Execution Risk

libphp-phpmailer Updated 02 Oct 2025

Summary

17/06/2021
N/A
Yes i
Unrated
Not published

DEBIAN-CVE-2021-3603: PHPMailer 6.4.1 and earlier contain a vulnerability that can result in untrusted code being called (if such code is injected into the host project's scope by other means). Affects libphp-phpmailer versions < 6.6.3-1. Fixed in 6.6.3-1. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

libphp-phpmailer is a widely used PHP library that facilitates the sending of emails through PHP applications. It provides a robust set of features for email validation, attachment handling, and SMTP support. However, versions 6.4.1 and earlier are susceptible to a vulnerability that allows untrusted code execution if certain conditions are met, posing a significant security risk to applications relying on this library.

Vulnerability Detail

The vulnerability arises from the way the validateAddress() function handles the $patternselect parameter. When set to 'php' (the default), and if the global namespace contains a function named 'php', this function will be executed instead of the intended built-in validator. This can lead to arbitrary code execution if an attacker manages to inject malicious code into the host project's scope. The issue was mitigated in version 6.5.0, which disallows simple strings as validator function names, thus preventing this exploit.

How To Fix

Minimum fixed version

6.6.3-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade libphp-phpmailer

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, you can manually set the $patternselect parameter to a different value that does not invoke the global 'php' function. For example, you can use a custom validator function that does not conflict with existing global functions.

Conclusion

The vulnerability in libphp-phpmailer poses a serious risk due to the potential for untrusted code execution. It is crucial for users of this library to update to the patched version 6.6.3-1 or later to ensure their applications remain secure. Additionally, utilizing tools like Vulert can help monitor and alert for open-source vulnerabilities in real-time.

See every vulnerability recorded for libphp-phpmailer →

Share this vulnerability

FAQ

The main risk is the potential for untrusted code execution, which can lead to unauthorized access, data breaches, or complete system compromise.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

Versions 6.4.1 and earlier of libphp-phpmailer are vulnerable to this issue.

Yes, the vulnerability has been patched in version 6.6.3-1 and later of libphp-phpmailer.

If you cannot update the package immediately, consider implementing the suggested workaround to mitigate the risk until you can apply the update.

Related vulnerabilities

Recent vulnerabilities recorded for libphp-phpmailer.

How To Fix

Minimum fixed version

6.6.3-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade libphp-phpmailer

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback