The patch for CVE-2026-6379 closes six SQL injections in WP Photo Album Plus by replacing string concatenation with $wpdb->prepare(). The same file, in the same release the patch shipped in, calls $wpdb->prepare() twenty-one more times outside the patch. Every one of those twenty-one calls is wrapped in stripslashes() that removes the escaping prepare() just added. The patch reached for the right primitive. The file already had the primitive twenty-one times, defanged.
CVE-2026-6379: The Patch Reached For prepare(). The Same File Already Calls prepare() Twenty-One Times, Wrapped In stripslashes()
vendor
patterns
cve
proof of concept
The bug the CVE names
WPScan filed CVE-2026-6379 against WP Photo Album Plus before 9.1.11.001. The advisory text reads: "does not properly sanitize and escape a parameter before using it in a SQL query, allowing unauthenticated users to perform SQL injection attacks." The parameter is wppa-supersearch. The sink is in wppa_get_photos(), dispatched off the gallery shortcode that any public page can render.
Reachability is direct. [wppa] is the shortcode every WPPA+ user puts on their gallery page. When a request hits that page with wppa-supersearch=..., the value flows through wppa_url_to_runparms() into wppa_get_photos() with no auth check between them. The wppa-occur=N parameter has to match the shortcode's occurrence index on the page, which is 1 for the first [wppa] block. That is the entire precondition.
wppa-supersearch is parsed as CSV: s1,type,s3,DATA. The type byte routes the request into a switch. The vulnerable case is type='o' (Owner):
// wppa-functions.php, 9.1.10.011, line 1244
case 'o':
wppa( 'is_upldr', $data );
$query = "SELECT id FROM $wpdb->wppa_photos
WHERE owner = '" . $data . "' AND album > 0 ORDER BY $order";
$total_ids = wppa_combine_virtual( $query, 17 );
break;$data is the trailing field of the CSV, reassembled with implode(',', ...) so any internal commas survive. It is concatenated raw into a single-quoted string. The payload to break out:
wppa-supersearch=,o,,x' OR (SELECT 1 FROM (SELECT(SLEEP(5)))A)-- -Which produces, in MySQL's general log on a vulnerable lab:
SELECT id FROM wp_wppa_photos
WHERE owner = 'x' OR (SELECT 1 FROM (SELECT(SLEEP(5)))A)-- -' AND album > 0 ORDER BY idThe response is delayed five seconds. The query results are consumed by wppa_combine_virtual(), which does not echo rows into the HTTP body, so the exfil channel is time-based blind. Byte-by-byte extraction recovers wp_users.user_pass (a phpass hash, crackable offline) in a few minutes. The PoC kit at dinosn/cve-2026-6379 ships the lab, the curl, and a working --mode hash extractor.
The patch the maintainer shipped
Commit d2b0d05d, dated 2026-04-17, rewrites the six SQL sinks in wppa_get_photos() that built queries via string concatenation. The owner case becomes:
- $query = "SELECT id FROM $wpdb->wppa_photos
- WHERE owner = '" . $data . "' AND album > 0 ORDER BY $order";
+ $query = $wpdb->prepare(
+ "SELECT id FROM $wpdb->wppa_photos WHERE owner = %s AND album > 0",
+ $data );$wpdb->prepare() is WordPress's documented primitive for parameterized SQL. With %s, the value is cast to a string, escaped with mysqli_real_escape_string, and wrapped in single quotes. The same shape lands on the name case, the tag case, and three calendar cases (exifdtm, timestamp, modified). The patch is correct for what it touches.
$order (also attacker-influenceable through plugin state earlier in the same function) is removed from the four queries the maintainer rewrote. The remaining ORDER BY $order references in unrelated queries stay. The maintainer is patching one window of the dataflow at a time.
The file already had prepare()
Reach for $wpdb->prepare( in wppa-functions.php, in the patched build, and count:
$ grep -c 'stripslashes( \$wpdb->prepare' wppa-functions.php
21Twenty-one queries in the same file, in the same release that closed CVE-2026-6379, already use $wpdb->prepare(). Every one of them is wrapped in stripslashes(). The shape recurs on lines 660, 711, 831, 838, 889, 895, 900, 971, 1028, 1034, 1041, 1122, 1144, 1190, 1413, 1417, 1468, 1473, 1479, 1484, 1494. Pull one site in full, at line 658 in the patched file:
$ids = wppa_expand_enum( $wppa_session['search_albums'] );
$ids = str_replace( '.', "','", $ids );
$query = stripslashes( $wpdb->prepare(
"SELECT * FROM $wpdb->wppa_albums WHERE id IN (%s) ORDER BY id", $ids ) );The maintainer knows about $wpdb->prepare(). They reach for it twenty-one times outside the patch. They wrap each call in stripslashes() and they do it deliberately. The wrapping is not a bug; it is the workaround that makes prepare() work in this context. The workaround is what re-introduces the class the CVE was supposed to close.
What stripslashes() is undoing
$wpdb->prepare( "... IN (%s)", $ids ) treats %s as a single string value. If $ids = "1,2,3", prepare emits IN ('1,2,3'), which matches no rows: SQL evaluates id IN ('1,2,3') as one comparison against a five-character literal. The maintainer wants IN (1,2,3), or equivalently IN ('1','2','3').
The workaround the file uses, twenty-one times:
$ids = str_replace( '.', "','", $ids ); // build 1','2','3
prepare( "... IN (%s)", $ids ) // emit IN ('1\',\'2\',\'3')
stripslashes( ... ) // strip the backslashes
// final: // IN ('1','2','3')Prepare escapes the inner single quotes with backslashes because %s escapes every single quote it sees. stripslashes() then strips those backslashes back out. The query parses. The IN list iterates over each element. The site appears to work.
It appears to work because every element of $ids, in the normal flow, is a digit string the plugin built from wppa_expand_enum() over a server-side enum. The escape that prepare added had nothing to escape. The strip that stripslashes did had nothing to strip. The two transforms cancel for benign input and the maintainer's invariant holds.
The invariant breaks at the moment any element of the list contains a single quote. Prepare escapes the quote. Stripslashes removes the escape. The quote arrives in the SQL string unescaped, inside an interpolation the parser will read as the end of one literal and the start of the next. The very escape $wpdb->prepare() exists to add is being removed by the expression that calls it.
This is the escape-then-unescape shape. A security primitive is applied to user input, then its inverse transform is called on the output in the same expression because the primitive's output shape does not fit the consumer. The fix is in the code. The unfix is wrapped around it.
Which of the twenty-one see attacker-influenced data
Some of the twenty-one sites are dead code. Line 660 lives inside if ( false && wppa( 'usr' ) ), with the false && in the source. Some accept only $ids from server-side enumerations and never see a quote. At least some take their list from values the same wppa-supersearch parser populates via the 't' case, which walks wppa_index.slug lookups and feeds the results into the next stripslashes(prepare(...)) site:
// wppa-functions.php, line 706 (patched)
$query = $wpdb->prepare(
"SELECT albums FROM $wpdb->wppa_index WHERE slug = %s", $d );
$index = wppa_get_var( $query );
if ( ! $index ) return [];
$ids = str_replace( '.', "','", wppa_expand_enum( $index ) );
$query = stripslashes( $wpdb->prepare(
"SELECT id FROM $wpdb->wppa_albums WHERE id IN (%s)", $ids ) );$d is attacker-controlled (it is the wppa-supersearch=,t,,... payload). The slug = %s lookup is safe. The value returned from $wpdb->wppa_index.albums flows back into the next query via the escape-then-unescape wrap, where any single quote that the plugin's own write paths can stash into that column survives the round-trip into unquoted SQL. The post does not turn that observation into a second working PoC. The PoC author flagged the class as "candidate for a follow-up CVE" and documented the line numbers; that is honest about the verification gap.
The structural claim does not need a second working PoC to land. The patch reached for $wpdb->prepare(). The file calls $wpdb->prepare() twenty-one more times. The wrapping the file uses defeats the escape on any attacker-influenced list element. Wherever that condition is reached, the injection class the CVE was supposed to close is still open in the same file the CVE patched.
The thing the maintainer wrote in a comment
Line 1144, in the patched file, in the middle of one of the twenty-one wraps:
$query = stripslashes( $wpdb->prepare(
"SELECT id FROM $wpdb->wppa_photos WHERE album IN (%s)"
/* ORDER BY $order"*/, $a ) );The commented-out ORDER BY $order is the maintainer's own testimony. They removed the $order interpolation at this site for the same reason the patch removed it at four others: $order is attacker-influenced earlier in the function. The fix is in the comment. The remaining ORDER BY $order references elsewhere in the file are not in comments; they are live.
The maintainer knows about $wpdb->prepare(). They reach for it twenty-one times in the file the CVE patched. The maintainer knows $order is dangerous. They have written that knowledge into a comment. The patch addresses the bugs that grep finds. The bugs that look like prepare(), and the bugs documented in comments, are not the ones the patch sees.
A defender reading the advisory
WPScan's advisory entry for CVE-2026-6379 says "fixed in 9.1.11.001." The CISA-style takeaway is to update the plugin. The update closes the six concatenation sinks the maintainer rewrote. The defender ships the patch, runs a regression test against wppa-supersearch=,o,,x'%20OR..., sees the five-second delay disappear, and marks the row green.
The same release ships twenty-one stripslashes(prepare(... IN (%s) ...)) calls in the same file. None of them surface in a regression test against the parameter named in the CVE, because the parameter is no longer the injection. The next CVE on this codebase, if it lands, will be against a different parameter and the same class. Static scanners that flag raw string concatenation will not flag prepare() being called. Static scanners that flag stripslashes() will get noise from every legitimate use of the function across WordPress core. The pattern that makes the injection legible is exactly the one the workaround removes.
This is the design-debt driver shape. The file's primary SQL-construction idiom is stripslashes( $wpdb->prepare( ... IN (%s) ... ) ). The CVE caught the cases where the idiom had not yet been reached for. The patch did not address the idiom. Each line in the codebase that uses the idiom is a primitive waiting on an attacker-controlled value reaching the IN list.
PoC: dinosn/cve-2026-6379
The patch closes the bugs that grep finds. The bugs that look like prepare() are the ones the patch does not see.