Skip to content
SQL injection Write-up Intermediate

How I Obtained CVEs in WordPress Plugins Using Static Analysis Engine - Semgrep

The author used the Semgrep static analysis engine to scan roughly 400 WordPress plugins for common PHP vulnerability patterns such as SQL injection, XSS, missing capability checks, CSRF and object injection. Manual triage of the flagged code confirmed several issues, including an unauthenticated blind SQL injection via an ORDER BY parameter and a CSRF flaw that let an attacker replace a plugin's stored API key.

COFFSec Follow

Published on coffsec.medium.com

A deep technical walkthrough of how I used Semgrep — a static analysis engine — to systematically hunt for vulnerabilities across the WordPress plugin ecosystem, resulting in assigned CVEs.

COFFSec, on coffsec.medium.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

Likely missing or inappropriate sanitisation and missing security checks: user input was concatenated into SQL, echoed without escaping, or state-changing actions lacked a nonce or capability check.

Impact

An unauthenticated attacker could run time-based blind SQL injection against a vulnerable plugin, and a logged-in admin could be tricked into letting an attacker replace the plugin's API key, potentially receiving the data the plugin sends to that API.

What the attacker needed

Vulnerable WordPress plugin installed; for SQLi: no authentication needed; for CSRF: victim is a logged-in admin; victim visits attacker-controlled page

The fix

The text does not state that any specific plugin was fixed; the implied fix is to use $wpdb->prepare() where possible, whitelist ORDER BY columns, escape output with esc_html()/esc_attr(), and add nonce and capability checks to state-changing handlers.

How it was found

  1. Download a corpus of WordPress plugins from the official SVN repository.
  2. Write Semgrep rules for SQL injection, XSS, access control, CSRF, object injection, file inclusion and file upload.
  3. Run Semgrep across the corpus and collect JSON results.
  4. Filter results for ERROR-severity findings and triage each one manually.
  5. Trace source, sanitisation, sink and any auth or nonce gate for each finding.
  6. Build a minimal proof of concept to confirm exploitability.

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.

A scanner reads the source code of many plugins and flags places where user-supplied input reaches a dangerous operation without proper cleaning. The author then manually checked each flag to confirm it was real, and in some cases built a small request to prove it. The confirmed bugs were reported and received CVE identifiers.

What is SQL injection?

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.