High Severity CSRF to RCE Vulnerability Patched in Code Snippets Plugin
The Code Snippets WordPress plugin's import function lacked CSRF protection, allowing an attacker to trick an administrator into importing malicious code. By including an 'active' flag in the import data, the code snippet could be enabled and executed, leading to remote code execution.
wordfence.com
Published on wordfence.com
On January 23rd, our Threat Intelligence team discovered a vulnerability in Code Snippets, a WordPress plugin installed on over 200,000 sites. The flaw allowed anybody to forge a request on behalf of an administrator and inject executable code on a vulnerable site.
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
The import function lacked a CSRF nonce check, and the default-disabled state of imported snippets could be bypassed by setting an 'active' flag in the import data.
Impact
An attacker could achieve complete site takeover, create administrative accounts, exfiltrate sensitive information, and infect site users.
What the attacker needed
Victim is a logged-in administrator; victim visits attacker-controlled page; vulnerable plugin version <= 2.13.3
The fix
The plugin was fixed in version 2.14.0 by explicitly disabling imported snippets and changing the import endpoint.
How it was found
- Craft a malicious request to the import endpoint containing a code snippet with an 'active' flag set to '1'.
- Trick a logged-in administrator into visiting a page that sends the request.
- The plugin imports and activates the snippet, executing the attacker's code.
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.
This is a cross-site request forgery (CSRF) bug: a malicious website can make a logged-in administrator's browser send a request to their own WordPress site without them knowing. The plugin's import feature did not check that the request was intentional, so an attacker could import code that runs on the server. Because the imported code could be set to active, it would execute and let the attacker take over the site.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.