What is PHP object injection and phar deserialization?
PHPMailer's addAttachment function accepted a phar:// path, so a file operation on an attacker-supplied phar file would unserialise its metadata and could trigger a gadget chain. The text says this can lead to remote code execution, though it does not demonstrate an end-to-end exploit against WordPress.
blog.wpsec.com
Published on blog.wpsec.com
On 13th May 2021, WordPress released WordPress 5.7.2, which was a security release fixing one vulnerability that affected versions 3.7 to 5.7. This vulnerability is a PHP Object Injection vulnerability in PHPMailer (CVE-2020-36326, CVE-2018-19296) that occurs via the addAttachment function with a UNC pathname.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the addAttachment function did not validate the supplied path, so a phar:// wrapper could be used and its serialised metadata unserialised during a file operation.
Impact
The text states these bugs can be used to achieve remote code execution, but it does not show a working exploit against WordPress itself.
What the attacker needed
Attacker controls the attachment path; a gadget chain available in loaded classes
The fix
WordPress was fixed in version 5.7.2, and PHPMailer added a path check that rejects paths containing a URL-style scheme.
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 write-up has not been written yet. The Original tab links to the source.
PHP can save objects (bundles of data plus code) to disk in a serialised form, and reading certain archive files called phar files makes PHP rebuild those objects automatically. If an attacker can control the file path, they can point the code at their own phar file and have their chosen object rebuilt, which may run harmful code. Here the email library PHPMailer let a caller pass such a path when attaching a file.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.