Skip to content
CSRF Write-up Intermediate

What is the Code Snippets Vulnerability?

The Code Snippets WordPress plugin before version 2.14.0 lacked a Referer check on its import menu, allowing CSRF. An attacker could trick a logged-in administrator into visiting a malicious page, which would forge a request to import and execute arbitrary PHP code, leading to remote code execution and site takeover.

blog.wpsec.com

Published on blog.wpsec.com

A high-severity Cross-Site Request Forgery (CSRF) vulnerability, tracked as CVE-2020–8417, exists in a popular WordPress plugin called Code Snippets, rendering over 200,000 websites vulnerable to site takeover.

Jonas Lejon, on blog.wpsec.com

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 plugin's import menu did not verify the HTTP Referer header, so it lacked CSRF protection and accepted forged requests.

Impact

An attacker could forge a request on behalf of an administrator to inject and execute arbitrary code, potentially leading to remote code execution, creation of administrative accounts, data exfiltration, and site takeover.

What the attacker needed

Victim is logged-in administrator; victim visits malicious page; vulnerable plugin version <2.14.0

The fix

The vulnerability was fixed in version 2.14.0; users should update the plugin to the latest version.

How it was found

  1. Set up a local WordPress site with the vulnerable Code Snippets plugin version 2.13.3.
  2. Ensure there is a single administrator user and no existing code snippets.
  3. As an attacker, post a comment on the site containing a link to a malicious web page.
  4. Trick the logged-in administrator into visiting the malicious page.
  5. The malicious page sends a forged request that imports and executes attacker code, creating a new snippet and an administrative user.

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 about a WordPress plugin that lets administrators add small pieces of code to their site. The plugin's import feature did not check where a request came from, so a malicious website could make an administrator's browser send a request to import and run harmful code without the administrator knowing. That let an attacker take over the site.

What is CSRF?

Another site makes a signed-in user's browser perform an action they did not intend.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.