-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The bug the CVE names\n\nWPScan 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.\n\nReachability 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.\n\n`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):\n\n```php\n// wppa-functions.php, 9.1.10.011, line 1244\ncase 'o':\n wppa( 'is_upldr', $data );\n $query = \"SELECT id FROM $wpdb->wppa_photos\n WHERE owner = '\" . $data . \"' AND album > 0 ORDER BY $order\";\n $total_ids = wppa_combine_virtual( $query, 17 );\n break;\n```\n\n`$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:\n\n```\nwppa-supersearch=,o,,x' OR (SELECT 1 FROM (SELECT(SLEEP(5)))A)-- -\n```\n\nWhich produces, in MySQL's general log on a vulnerable lab:\n\n```sql\nSELECT id FROM wp_wppa_photos\nWHERE owner = 'x' OR (SELECT 1 FROM (SELECT(SLEEP(5)))A)-- -' AND album > 0 ORDER BY id\n```\n\nThe 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](https://github.com/dinosn/cve-2026-6379) ships the lab, the curl, and a working `--mode hash` extractor.\n\n## The patch the maintainer shipped\n\nCommit `d2b0d05d`, dated 2026-04-17, rewrites the six SQL sinks in `wppa_get_photos()` that built queries via string concatenation. The owner case becomes:\n\n```diff\n- $query = \"SELECT id FROM $wpdb->wppa_photos\n- WHERE owner = '\" . $data . \"' AND album > 0 ORDER BY $order\";\n+ $query = $wpdb->prepare(\n+ \"SELECT id FROM $wpdb->wppa_photos WHERE owner = %s AND album > 0\",\n+ $data );\n```\n\n`$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.\n\n`$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.\n\n## The file already had prepare()\n\nReach for `$wpdb->prepare(` in `wppa-functions.php`, in the patched build, and count:\n\n```\n$ grep -c 'stripslashes( \\$wpdb->prepare' wppa-functions.php\n21\n```\n\nTwenty-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:\n\n```php\n$ids = wppa_expand_enum( $wppa_session['search_albums'] );\n$ids = str_replace( '.', \"','\", $ids );\n$query = stripslashes( $wpdb->prepare(\n \"SELECT * FROM $wpdb->wppa_albums WHERE id IN (%s) ORDER BY id\", $ids ) );\n```\n\nThe 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.\n\n## What stripslashes() is undoing\n\n`$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')`.\n\nThe workaround the file uses, twenty-one times:\n\n```\n$ids = str_replace( '.', \"','\", $ids ); // build 1','2','3\nprepare( \"... IN (%s)\", $ids ) // emit IN ('1\\',\\'2\\',\\'3')\nstripslashes( ... ) // strip the backslashes\n// final: // IN ('1','2','3')\n```\n\nPrepare 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.\n\nIt 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.\n\nThe 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.\n\nThis 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.\n\n## Which of the twenty-one see attacker-influenced data\n\nSome 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:\n\n```php\n// wppa-functions.php, line 706 (patched)\n$query = $wpdb->prepare(\n \"SELECT albums FROM $wpdb->wppa_index WHERE slug = %s\", $d );\n$index = wppa_get_var( $query );\nif ( ! $index ) return [];\n$ids = str_replace( '.', \"','\", wppa_expand_enum( $index ) );\n$query = stripslashes( $wpdb->prepare(\n \"SELECT id FROM $wpdb->wppa_albums WHERE id IN (%s)\", $ids ) );\n```\n\n`$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.\n\nThe 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.\n\n## The thing the maintainer wrote in a comment\n\nLine 1144, in the patched file, in the middle of one of the twenty-one wraps:\n\n```php\n$query = stripslashes( $wpdb->prepare(\n \"SELECT id FROM $wpdb->wppa_photos WHERE album IN (%s)\"\n /* ORDER BY $order\"*/, $a ) );\n```\n\nThe 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.\n\nThe 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.\n\n## A defender reading the advisory\n\nWPScan'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.\n\nThe 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.\n\nThis 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.\n\nPoC: [dinosn/cve-2026-6379](https://github.com/dinosn/cve-2026-6379)","closing_line":"The patch closes the bugs that grep finds. The bugs that look like prepare() are the ones the patch does not see.","hook_md":"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.","post_id":454,"slug":"wppa-cve-2026-6379-stripslashes-undoes-prepare","title":"CVE-2026-6379: The Patch Reached For prepare(). The Same File Already Calls prepare() Twenty-One Times, Wrapped In stripslashes()","type":"initial","unreadable_sentence":"The patch closes the bugs that grep finds. The bugs that look like prepare() are the ones the patch does not see."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCanThpwAKCRDeZjl4jgkQ JoBiAQCrhUgOwJISND2BMG/LN8d5gIgwpglNtl+0f506z84/JgEA9mBNa/777lfH vZpqneBoAAmENZKRloewyjsSI531KQM= =czOd -----END PGP SIGNATURE-----