CVE-2024–2961 Buddyforms 2.7.7 LFI to RCE via iconv()
A WordPress site running the Buddyforms plugin version 2.7.7 allowed an unauthenticated file upload that could be deserialised through a php://filter wrapper, and the same site ran a PHP version affected by an iconv out-of-bounds write. By chaining the two, the author turned a local file read into remote code execution.
medium.com
Published on medium.com
Recently, I stumbled upon a CTF machine which was using a vulnerable Buddyforms version (2.7.7) on WordPress site. This version is vulnerable to CVE-2023–26326 but it was not enough to exploit alone.
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 plugin accepted an uploaded file based only on its declared image type and then deserialised it through a PHP stream filter, while the installed PHP/glibc iconv conversion to ISO-2022-CN-EXT wrote past the end of a buffer.
Impact
An unauthenticated attacker could chain the two flaws to run arbitrary commands on the server, though the text notes the deserialisation needs a gadget chain and phar:// no longer works on PHP 8 and above.
What the attacker needed
Buddyforms 2.7.7 on WordPress; PHP 8.3 with vulnerable glibc iconv; A usable gadget chain for deserialisation; No authentication needed
How it was found
- Upload a file through the plugin's upload-from-URL feature, disguised with image magic bytes.
- Use a php://filter chain to unpack the malicious payload, since phar:// no longer works on PHP 8 and above.
- Use the resulting local file read to read /proc/self/maps and locate PHP's memory heap.
- Trigger the iconv out-of-bounds write through a convert.iconv filter to overwrite a function pointer.
- Execute system() commands to obtain remote code execution.
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.
Two separate software flaws were present on one server. The first let an outsider upload a file that the site later treats as trusted data, and the second is a memory bug in a text-conversion library that PHP uses. Putting them together let the author run their own commands on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.