All posts
Write-up ~5 min read

The second place the fix forgot: unauthenticated SQLi in WordPress File Upload

An earlier patch escaped the uploadid in one query and missed the next one, leaving an unauthenticated SQL injection reachable from a nopriv upload handler.

Context: Incomplete fix of CVE-2026-17044

Advisory
CVE-2026-62071
CVE
CVE-2026-62071
Affected
WordPress File Upload (WordPress plugin) <= 5.1.10, patched in 5.2.0
Weakness
CWE-89 · SQL Injection
Reading
~5 min · 6 Oct 2026

A fix that escapes user input in one query and leaves the same tainted value flowing into the next one is not a fix. It is a smaller version of the same bug, and it is one of the more reliable things you can find by reading a patch.

That is the story of CVE-2026-62071: an unauthenticated SQL injection in WordPress File Upload (the wp-file-upload plugin by Iptanus, about 10k active installs), reachable with no login, that survived an earlier SQLi fix because that fix only cleaned one of the places the tainted value was used.

I found it on 16 August while re-reading fresh WordPress security fixes. I went through close to twenty plugins that day, and this was the only one where the fix turned out to be incomplete. Most patches are fine; the point of reading them is the rare one that is not.

A little theory: why $wpdb queries are still SQLi in 2026

WordPress hands plugin authors $wpdb, and $wpdb->prepare() is a perfectly good parameterised-query API. So why does the plugin ecosystem still produce new SQL injection CVEs every week?

Because prepare() is opt-in, and three habits keep tainted values out of it:

  • String concatenation into a raw query. $wpdb->get_results("... WHERE x='".$val."'") is the classic mistake, and it is still everywhere.
  • “I already sanitised it.” sanitize_text_field() trims and strips tags. It does not escape quotes. It makes a value safe to display, not safe to concatenate into SQL, and treating it as an SQL escape is a very common false sense of safety in WordPress code.
  • Magic-quotes confusion. WordPress adds slashes to every superglobal on the way in. Code that calls stripslashes_deep($_POST) removes them, which is correct for processing the data, but it also means a ' the attacker sent arrives in your handler as a bare, unescaped '. If that value is then concatenated into a query, the quote closes the string literal and you are injecting.

Put those together (stripslashes_deep, then sanitize_text_field, then string concatenation) and you have a value that looks sanitised, carries a live single quote, and lands in a query unescaped.

The concrete finding

WordPress File Upload registers its AJAX handlers for logged-out users too:

wfu_loader.phpPHP
add_action('wp_ajax_wfu_ajax_action', 'wfu_ajax_action_callback');
add_action('wp_ajax_nopriv_wfu_ajax_action', 'wfu_ajax_action_callback');

The nopriv variant is the reach: anyone on the internet can drive the upload/data-submit flow without an account. That flow carries an upload identifier (uploadid) supplied with the request and eventually calls wfu_log_action() in lib/wfu_functions.php, which writes a row to the plugin’s wfu_log table and, before inserting, looks up existing records by that id.

In 5.1.10 that lookup was built by concatenation:

lib/wfu_functions.php, wfu_log_action(), 5.1.10 (before the fix)PHP
// $uploadid arrives from the request, stripslashes_deep'd and
// run through sanitize_text_field(), which does NOT escape quotes
$rows = $wpdb->get_results(
    "SELECT * FROM ".$table_name." WHERE uploadid='".$uploadid."'"
);

sanitize_text_field() leaves a ' untouched and the magic quotes were already stripped, so a crafted uploadid breaks out of the string literal. Classic CWE-89.

The incomplete-fix part: this value had already been flagged once. An earlier advisory (CVE-2026-17044) fixed an SQLi in the same plugin by hardening wfu_get_userdata_from_uploadid(), the function that reads back user-data rows by uploadid. That patch escaped the value in that one function. But the same request-controlled uploadid also flowed into wfu_log_action() (and into several second-order read paths that re-query stored uploadid values). The first fix cleaned one sink; the next sink down the call graph was never touched. Re-reading the patched release and following the same tainted parameter into every query is what surfaced it.

One honest precondition: the injectable field was length-limited, so the working payload had to fit the gate. A ten-character boolean payload such as ' OR 1=1#a is enough to prove the break-out and confirm blind injection; the # comments out the trailing quote and the final character pads to the required length. I verified the injection by comparing the queries in MySQL’s general_log on a test install of 5.1.10.

How to find this in your own code

  • Grep for the sink, not the source: $wpdb->get_results, get_var, get_row, query with a . or " inside the argument. Any $wpdb->...("...".$var."...") is a candidate; anything using $wpdb->prepare() with %s/%d placeholders is not.
  • Follow one tainted parameter to every query. The bug here is not that the value was unescaped once; it was escaped in query A and concatenated in query B. Trace each request parameter through the whole call graph, not just the first place it is used.
  • Treat sanitize_text_field() as display safety only. If a value is going into SQL, it needs prepare(), %d or esc_sql(), regardless of what sanitiser ran earlier.
  • Check the nopriv list. wp_ajax_nopriv_* handlers are unauthenticated attack surface, and a SQLi behind one is critical, not medium.

The fix

5.2.0 routes the uploadid through parameterised queries everywhere it is used. The log write now uses $wpdb->insert() with an explicit format array, and the companion lookups use prepare() with %s:

lib/wfu_functions.php, wfu_log_action(), 5.2.0 (fixed)PHP
$existing = $wpdb->get_row($wpdb->prepare(
    'SELECT * FROM '.$table_name2.' WHERE uploadid = %s AND property = %s AND date_to = 0',
    $uploadid, $userdata_field['label']
));
the insert, with an explicit format arrayPHP
$wpdb->insert($table_name1,
    array( /* ... */ 'uploadid' => $uploadid, /* ... */ ),
    array( '%d','%d','%d','%s','%s','%s','%d','%s','%d','%d','%s','%s','%s','%s' )
);

The lesson for the fix itself: when you patch an injection, patch the parameter, not the line. Search the whole codebase for every query that touches it.

Impact

Unauthenticated, no user interaction. Patchstack rates it CVSS 3.1 9.3 Critical (AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:L). Blind SQL injection against wfu_log/wfu_userdata lets an unauthenticated attacker read arbitrary data from the WordPress database, including wp_users password hashes and secret keys, one boolean at a time. The scope-change flag reflects that a compromised database undermines the whole site, not just the plugin.

Disclosure timeline

Date Event
2026-08-16 Reported to the Patchstack Bug Bounty Program and to WPScan
2026-09-26 WordPress File Upload 5.2.0 tagged in the plugin SVN, fixing the issue
2026-10-01 CVE-2026-62071 published (CNA: Patchstack)
2026-10-06 This write-up

References

Takeaway

A patch that escapes a tainted value in one query but concatenates it into the next has only shrunk the bug.

Fix the parameter across the whole call graph, and never count sanitize_text_field() as an SQL escape.