Skip to content
RCE Disclosed report Advanced CVE-2021-3603

PHPMailer untrusted code may be run from an overridden address validator

PHPMailer's default email validator used a callable named 'php', so if an attacker could define a function with that name, it would be invoked during address validation. This provides a trigger pathway for code execution, though it requires the attacker to already have code injection capability.

PHPMailer/PHPMailer

Originally disclosed on huntr

If a function is defined that has the same name as the default built-in email address validation scheme (php), it will be called in default configuration as when no validation scheme is provided, the default scheme's callable php was being called. If an attacker is able to inject such a function into the application (a much bigger issue), it will be called whenever an email address is validated, such as when calling validateAddress().

Impact

Low impact – exploitation requires that an attacker can already inject code into an application, but it provides a trigger pathway.

Patches

This is patched in PHPMailer 6.5.0 by denying the use of simple strings as validator function names, which is a very minor BC break.

Workarounds

Inject your own email validator function.

References

Reported by Vikrant Singh Chauhan via huntr.dev. CVE-2021-3603

For more information

If you have any questions or comments about this advisory:

From the GitHub Advisory Database (GHSA-77mr-wc79-m8j3, CC BY 4.0).

The original report as published on the GitHub Advisory Database. Images and videos are our own copies; raw HTML is shown as text. View it on GitHub Advisory Database.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely, the validator accepted a plain string as a function name and called it without ensuring it was a trusted built-in function.

Impact

Low impact – exploitation requires that an attacker can already inject code into an application, but it provides a trigger pathway.

What the attacker needed

Attacker can inject code into the application

The fix

This was fixed in PHPMailer 6.5.0 by denying the use of simple strings as validator function names.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

PHPMailer is a library for sending email. It checks email addresses using a function whose name is 'php'. If an attacker can add their own function with that name, PHPMailer will call it when checking an address. This is dangerous only if the attacker can already run code in the application.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.