JoomSport's classJsportPlayerlist::loadObject() builds $options['ordering'] from $_GET['sortf'] by wrapping the value in backticks, passing the wrapped string through WordPress's sanitize_text_field(), and removing spaces with str_replace. sanitize_text_field()'s documented transformation set is invalid-UTF-8 normalisation, leading < to entity, strip-all-tags, whitespace collapse, and percent-encoded-character removal. The PoC's payload is post_title followed by a literal backtick. CVE-2026-42647 is what an unauthenticated visitor produces by sending sortf=post_title%60DESC,(SLEEP(2))%23 to any JoomSport season page below 5.7.8, and the 5.7.8 patch closes it by introducing a five-value allowlist three statements upstream of the ordering assignment while leaving the three ORDER BY concatenations in class-jsport-getplayers.php byte-identical to the vulnerable version.
CVE-2026-42647: JoomSport 5.7.8 Allowlists `sortf` Upstream. The Three `ORDER BY` Concatenations One File Over Are Byte-Identical.
vendor
pattern
cve
proof of concept
WordPress's escape API enumerates what it ships
sanitize_text_field() lives in wp-includes/formatting.php. The function dispatches to _sanitize_text_fields( $str, false ), whose body in WordPress 6.6 performs five transformations in this order. wp_check_invalid_utf8() strips bytes that fail UTF-8 validation. A str_contains( $filtered, '<' ) branch invokes wp_strip_all_tags() and rewrites <\n to <. A preg_replace( '/[\r\n\t ]+/', ' ', $filtered ) collapses runs of whitespace, newlines, and tabs to a single space. trim() strips leading and trailing whitespace. A while ( preg_match( '/%[a-f0-9]{2}/i', $filtered, $matches ) ) loop removes percent-encoded sequences. The function returns the result through the sanitize_text_field filter.
The transformation set does not contain the backtick character. The set does not contain the open paren, the close paren, the comma, the hash sign, the semicolon, or any keyword the MySQL parser reads as syntax. The function's name encodes the threat model the WordPress core developers were thinking about when they wrote it: a visitor posting body text into a form field whose value will be rendered into an HTML page, where the dangerous tokens are the ones an HTML parser interprets. The body of _sanitize_text_fields is correct, complete behaviour for that threat model.
WordPress's escape API enumerates the destinations the platform considers legal: esc_html for body text, esc_attr for attribute values, esc_url for href-bound URLs, esc_js for JavaScript-string content, esc_textarea for <textarea> bodies, esc_sql for SQL string-literal values. The platform does not ship esc_sql_identifier. JoomSport 5.7.6's classJsportPlayerlist::loadObject() needed an identifier escaper and reached for the text sanitiser the platform did ship.
The backtick wrap was the foothold
Line 80 of sportleague/classes/objects/class-jsport-playerlist.php in JoomSport 5.7.6:
if (classJsportRequest::get('sortf')) {
$typeAD = in_array(classJsportRequest::get('sortd'), array("ASC","DESC"))?classJsportRequest::get('sortd'):"ASC";
$options['ordering'] = str_replace(" ","",sanitize_text_field("`".classJsportRequest::get('sortf')."`")).' '.$typeAD;
}classJsportRequest::get('sortf') resolves to $_GET['sortf'] on the player-list route, which a public visitor reaches at ?post_type=joomsport_season&p=<id>&action=playerlist&sortf=<value>&sortd=<dir> without authentication. The handler resolves the season post, constructs classJsportPlayerlist, and lands on the assignment above. The sortd parameter is validated against the two-element array array("ASC","DESC") and falls back to "ASC" when it does not match. The sortf parameter is not validated; the assignment expects the backtick wrap, the sanitize_text_field() call, and the str_replace(" ","",...) to do the work.
The PoC sends sortf=post_title followed by a literal backtick (URL-encoded as %60), followed by DESC,(SLEEP(2))# (with # as %23). PHP's request layer decodes the percent-escapes before the handler reads them. The string entering the assignment expression is:
`post_title`DESC,(SLEEP(2))#`sanitize_text_field() runs over the string. The string contains no <, so the tag-stripping branch does not fire. The string contains no whitespace, so the whitespace collapse does not fire. The string contains no surviving percent-encoded sequences (the percent loop runs against %XX patterns that PHP's URL layer already decoded), so the percent loop does not fire. The function returns the input unchanged. str_replace(" ","",...) finds no spaces. The concatenation appends ' '.$typeAD, yielding:
`post_title`DESC,(SLEEP(2))#` ASCThis becomes $options['ordering']. Control flows into classJsportgetplayers::getPlayersFromTeam($options), where line 16 reads extract($options); and binds the value to local $ordering. Line 153 of sportleague/base/wordpress/classes/class-jsport-getplayers.php reads:
$query .= ' ORDER BY '.($ordering)The query Apache hands MariaDB ends with:
ORDER BY `post_title`DESC,(SLEEP(2))#` ASCMySQL's parser reads `post_title` as a backtick-quoted identifier, DESC as direction, , as separator, (SLEEP(2)) as a scalar expression in the ORDER BY list, and #\ ASCas everything-after-line-comment. The injectedSLEEP(2)evaluates per row; the player-list query groups byl.player_idover three lab-seeded rows; the response stalls for at least the requested interval times the row count. The lab'spoc.pymeasures a baseline median of 0.046s against an injected median of 6.058s for--sleep 2 --rounds 3. The ratio is 130x. The decision threshold for --sleep 2is 1.200s. The verdict isVULNERABLE-LIKE`.
The backtick wrap is what made the payload work. The source placed the attacker inside an identifier-quoting context, and the attacker terminated the quote with the next character of input. Without the wrap, the same payload would have arrived at the parser as bare text, which sanitize_text_field() does not defend against either but which the SQL parser would have read as an unquoted token sequence rather than a closed-quoted identifier followed by direction. The wrap was the half of the source the developer wrote thinking about SQL syntax. The wrap was also the half the attacker needed to be present.
The patch lives in one function. The sink lives in another file.
JoomSport 5.7.8's class-jsport-playerlist.php adds a guarded variable at the top of loadObject():
$sortFieldEsc = 'post_title';
$sortCols = array("played", "career_minutes","post_title");The if (classJsportRequest::get('sortf')) branch above the pagination call gains four new statements:
$pattern = '/^eventid_\d+$/';
if (in_array(classJsportRequest::get('sortf'), $sortCols)) {
$sortFieldEsc = classJsportRequest::get('sortf');
}
if (preg_match('/^eventid_\d+$/', classJsportRequest::get('sortf'))) {
$sortFieldEsc = classJsportRequest::get('sortf');
}
if (preg_match('/^ef_\d+$/', classJsportRequest::get('sortf'))) {
$sortFieldEsc = classJsportRequest::get('sortf');
}The $pattern assignment is dead. The variable is declared and never read; the next statement passes the literal '/^eventid_\d+$/' to preg_match as the first argument. The dead assignment is a small tell about the shape of this patch: the author was iterating on which regex literal to apply and shipped the local variable they had stopped reading from. The three branches that do execute form the allowlist: the accepted values for sortf are the three static columns played, career_minutes, post_title; any string matching /^eventid_\d+$/; any string matching /^ef_\d+$/. If the request value matches none of them, $sortFieldEsc stays at its default post_title.
The one structural change to the existing ordering assignment is the substitution of $sortFieldEsc for classJsportRequest::get('sortf'):
- $options['ordering'] = str_replace(" ","",sanitize_text_field("`".classJsportRequest::get('sortf')."`")).' '.$typeAD;
+ $options['ordering'] = str_replace(" ","",sanitize_text_field("`".$sortFieldEsc."`")).' '.$typeAD;The sanitize_text_field() call survives. The backtick wrap survives. The str_replace(" ","",...) survives. The patch's defence is that $sortFieldEsc is now drawn from a five-element set rather than from $_GET['sortf'], and the three cosmetic transforms are running over a value that has already been validated against the only set it is permitted to be a member of.
sportleague/base/wordpress/classes/class-jsport-getplayers.php is byte-identical between the 5.7.6 SVN tag and the 5.7.8 SVN tag. The three concatenations that consume $ordering are unchanged:
$query .= ' ORDER BY l.'.$ordering // line 102, single-season branch
$query .= ' ORDER BY '.($ordering) // line 153, complex-season branch
$query .= ' ORDER BY '.$ordering.',l.player_id' // line 197, no-season branchThe diff's audit-readable scope is one function in one file. The runtime behaviour the diff secures is the one caller the diff knew about. Any future caller, any refactor that splits the source-side validator out of the player-list handler, any new code path that lets attacker-influenced input into the $options['ordering'] slot, reaches the same three concatenations and produces the same MySQL parse.
sanitize_text_field keeps finding new sinks
Eight days ago we covered CVE-2026-3300: Everest Forms Pro's Calculation Addon passing submitted form fields through sanitize_text_field() and concatenating the results into a PHP arithmetic expression handed to eval(). The same WordPress function, applied to the same kind of attacker-controlled string, fed to a different interpreter. The PHP token boundaries sanitize_text_field() does not address are the single quote, the double quote, the semicolon, the backtick, the dollar sign, and the parenthesis. The MySQL identifier-context tokens it does not address are the same set with the substitutions appropriate to the dialect, anchored on the backtick the developer wrote into the wrap.
This is The Shell Was Not The Sink in the WordPress dialect, twice in eight days. A platform sanitiser named, implemented, and documented for one interpreter, applied to inputs that flow into a different interpreter; the function's name reading like a defence while the destination's parser reads the character the function's name encoded for as data. The Everest Forms exhibit named the missing primitive as esc_php. The JoomSport exhibit names the missing primitive as esc_sql_identifier. WordPress core's escape API enumerates the seven destinations the platform considers legal and conspicuously omits both. The plugins keep choosing the function the platform did ship.
The 5.7.8 patch is the response a WordPress plugin author can write inside the constraints the platform leaves them. The author cannot make sanitize_text_field() understand SQL identifiers. The author can move the validation upstream and ensure the function never sees a value that would need that understanding. The text-sanitiser call is preserved because removing it would not have closed the CVE either; the bug was never that sanitize_text_field() failed to sanitise, the bug was that the developer who wrote the 5.7.6 assignment was reading sanitize_text_field() as the defence. The patch does not correct that misreading. The patch hides the consequence behind a layer the misreading no longer reaches.
The 5.7.8 patch defends sortf. The three ORDER BY concatenations one file over, in code the patch did not touch, defend nothing.