CVE-2024-41335
Executive Summary
CVE-2024-41335 identifies a security vulnerability in multiple Draytek Vigor router models. The flaw stems from the insecure use of the strcmp and memcmp functions, which are not constant-time comparison functions. This allows an attacker to perform a timing side-channel attack to extract sensitive information, such as authentication tokens or session keys, by measuring the time it takes for the device to compare values. The vulnerability affects a wide range of Draytek Vigor devices, including the 165/166, 2620/LTE200, 2860/2925, 2862/2926, 2133/2762/2832, 2135/2765/2766, 2865/2866/2927, 2962/3910, and 3912 series. The CVSS score is 0.0 due to incomplete data, but the actual risk is elevated due to the potential for information disclosure. No public exploit code or proof-of-concept is currently available, and the patch status remains unknown.
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
- CVSS Vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N
- Base Score: 5.9 (Medium)
- Attack Vector: Network (AV:N) – The attack can be launched remotely.
- Attack Complexity: High (AC:H) – The attacker must be able to send precise timing measurements and perform statistical analysis.
- Privileges Required: None (PR:N) – No authentication is needed.
- User Interaction: None (UI:N) – No user action is required.
- Scope: Unchanged (S:U) – The vulnerability does not affect other components.
- Confidentiality: High (C:H) – Sensitive information can be fully disclosed.
- Integrity: None (I:N) – No data modification is possible.
- Availability: None (A:N) – No denial of service.
Threat Level: Medium. While the attack complexity is high, the potential for information disclosure (e.g., admin passwords, session tokens) makes this a significant risk for exposed devices.
Deep Dive & Mechanics
The vulnerability lies in the use of strcmp and memcmp for comparing sensitive data (e.g., authentication tokens, passwords). These functions compare data byte-by-byte and return as soon as a mismatch is found. This creates a timing difference: a comparison that fails on the first byte takes less time than one that fails on the second byte, and so on.
An attacker can exploit this by sending a series of crafted requests and measuring the response time. By iterating through possible values for each byte, they can reconstruct the entire secret value. This is a classic timing side-channel attack.
Affected Devices and Firmware Versions:
- Vigor 165/166: prior to v4.2.6
- Vigor 2620/LTE200: prior to v3.9.8.8
- Vigor 2860/2925: prior to v3.9.7
- Vigor 2862/2926: prior to v3.9.9.4
- Vigor 2133/2762/2832: prior to v3.9.8
- Vigor 2135/2765/2766: prior to v4.4.5.1
- Vigor 2865/2866/2927: prior to v4.4.5.3
- Vigor 2962/3910: prior to v4.3.2.7
- Vigor 3912: prior to v4.3.5.2
- Vigor 2925: up to v3.9.6
Vulnerable vs. Patched Code
Vulnerable Code (using strcmp):
if (strcmp(user_input, secret_token) == 0) {
// grant access
}
Patched Code (using constant-time comparison):
int constant_time_memcmp(const void *a, const void *b, size_t size) {
const unsigned char *ca = (const unsigned char *)a;
const unsigned char *cb = (const unsigned char *)b;
int result = 0;
for (size_t i = 0; i < size; i++) {
result |= ca[i] ^ cb[i];
}
return result;
}
The patched version ensures that the comparison time is independent of the input values, preventing timing side-channel attacks.
Exploitation & Lab Setup
Red Team (Exploitation)
Lab Setup:
- Set up a Draytek Vigor 165 with firmware v4.2.5 (vulnerable).
- Attacker machine with Python and
scapyfor network timing measurements. - Target service: HTTP login endpoint.
Exploitation Steps:
- Identify the target endpoint that uses
strcmpfor authentication (e.g.,/cgi-bin/login). - Send a series of login requests with varying passwords and measure response times.
- Use statistical analysis to determine the correct password byte-by-byte.
Example Python Script (Conceptual):
import requests
import time
def measure_time(url, password):
start = time.time()
requests.post(url, data={"password": password})
end = time.time()
return end - start
# Iterate over possible characters
for char in "abcdefghijklmnopqrstuvwxyz":
test_password = "admin" + char
elapsed = measure_time("http://target/login", test_password)
print(f"{test_password}: {elapsed}")
Blue Team (Defense)
Detection:
- Monitor for unusual patterns of login attempts with varying passwords.
- Look for high-frequency requests to authentication endpoints.
- Use network monitoring to detect timing anomalies.
Mitigation:
- Apply firmware patches as soon as they become available.
- Implement rate limiting on login endpoints.
- Use WAF rules to block suspicious traffic.
Indicators of Compromise (IOCs)
- Network: Unusually high number of HTTP POST requests to
/cgi-bin/loginor similar endpoints. - Timing: Response times that vary significantly based on input length or content.
- Logs: Repeated failed login attempts with incremental password changes.
Detection Engineering
YARA Rule
rule Draytek_Timing_Attack_Detection {
meta:
description = "Detects potential timing attack against Draytek devices"
author = "Valters IT"
date = "2024-01-01"
strings:
$strcmp = "strcmp" nocase
$memcmp = "memcmp" nocase
condition:
any of them
}
Sigma Rule
title: Draytek Timing Attack Detection
id: draytek-timing-attack
status: experimental
description: Detects potential timing side-channel attacks on Draytek devices
logsource:
category: webserver
product: draytek
detection:
selection:
cs-uri-query|contains: "/cgi-bin/login"
condition: selection
timeframe: 5m
aggregation:
- count >= 100
falsepositives:
- Legitimate login attempts
level: medium
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg:"Draytek Timing Attack Attempt";
flow:to_server;
content:"POST";
http_method;
content:"/cgi-bin/login";
http_uri;
threshold: type both, track by_src, count 100, seconds 300;
sid:1000001;
rev:1;
)
Remediation & Mitigation
Immediate Actions:
- Disable remote management if not required.
- Restrict access to the device's web interface to trusted IPs only.
- Implement network segmentation to limit exposure.
Long-term Fix:
- Apply firmware updates from Draytek as soon as they are released.
- Replace
strcmpandmemcmpwith constant-time comparison functions in all authentication and token validation code.
Monitoring:
- Enable logging on the device and monitor for unusual login patterns.
- Use the provided detection rules to identify potential attacks.
Workaround:
- If patching is not possible, consider using a VPN or other secure access method to reduce the attack surface.
Valters IT