CVE-2024-51249

8.0 HIGH

📋 TL;DR

This vulnerability allows remote attackers to execute arbitrary commands on Draytek Vigor3900 routers by injecting malicious commands into the mainfunction.cgi endpoint and calling the reboot function. This affects all organizations using the vulnerable firmware version of these routers, potentially giving attackers full control over network infrastructure.

💻 Affected Systems

Products:
  • Draytek Vigor3900
Versions: 1.5.1.3
Operating Systems: Draytek proprietary firmware
Default Config Vulnerable: ⚠️ Yes
Notes: All devices running the vulnerable firmware version are affected regardless of configuration.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete compromise of the router allowing attackers to intercept all network traffic, pivot to internal systems, install persistent backdoors, or disable network connectivity entirely.

🟠

Likely Case

Attackers gain remote code execution to install malware, create backdoors, or use the router as a pivot point for further attacks on the internal network.

🟢

If Mitigated

Limited impact if network segmentation prevents lateral movement and regular monitoring detects anomalous reboot activity.

🌐 Internet-Facing: HIGH - The vulnerability can be exploited remotely without authentication, making internet-facing routers immediate targets.
🏢 Internal Only: MEDIUM - Internal routers are still vulnerable but require initial network access, though could be exploited via phishing or compromised internal hosts.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

The GitHub reference contains technical details that could be used to create working exploits. The vulnerability requires no authentication and has simple command injection.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Unknown

Vendor Advisory: Unknown

Restart Required: Yes

Instructions:

1. Check Draytek's official website for security advisories. 2. Download the latest firmware if available. 3. Backup current configuration. 4. Upload and install new firmware via web interface. 5. Restart the router.

🔧 Temporary Workarounds

Block CGI endpoint access

linux

Use firewall rules to block external access to mainfunction.cgi endpoint

iptables -A INPUT -p tcp --dport 80 -m string --string "mainfunction.cgi" --algo bm -j DROP
iptables -A INPUT -p tcp --dport 443 -m string --string "mainfunction.cgi" --algo bm -j DROP

Disable web management interface

all

Disable remote web management if not required

🧯 If You Can't Patch

  • Segment the router on a dedicated VLAN with strict firewall rules limiting inbound and outbound connections
  • Implement network monitoring for unusual reboot patterns or CGI endpoint access attempts

🔍 How to Verify

Check if Vulnerable:

Check firmware version in router web interface under System Maintenance > Firmware Information

Check Version:

curl -k https://[router-ip]/cgi-bin/mainfunction.cgi?action=reboot (DO NOT RUN ON PRODUCTION - test only)

Verify Fix Applied:

Verify firmware version is no longer 1.5.1.3 and test if command injection via mainfunction.cgi is possible

📡 Detection & Monitoring

Log Indicators:

  • Unusual reboot events in system logs
  • Access to mainfunction.cgi with suspicious parameters
  • Multiple failed authentication attempts followed by CGI access

Network Indicators:

  • HTTP requests to /cgi-bin/mainfunction.cgi with command injection patterns
  • Unusual outbound connections from router to external IPs
  • Sudden network disruption followed by router reboot

SIEM Query:

source="router_logs" AND ("mainfunction.cgi" OR "reboot") AND (cmd=* OR exec=* OR system=* OR | OR ; OR $)

🔗 References

📤 Share & Export