DD-WRT UPnP SSDP Buffer Overflow Vulnerability (CVE-2021-27137) Analysis and Mitigation Guide
Executive & SecOps Summary
SECOPS ASSESSMENTDD-WRT firmware versions before build 45724 with UPnP functionality enabled
Unauthenticated remote attackers can execute arbitrary code or cause a Denial of Service (DoS) by sending crafted SSDP M-SEARCH requests, with active exploitation by botnets (e.g., c0xmo) confirmed in the wild [1, 2, references]
Immediately upgrade DD-WRT firmware to build 45724 or later, and disable UPnP services until the patch is applied [1, references]
Affected Products & Version Scope
Remediation & Live Workaround Commands
PATCH & WORKAROUND1. Firmware Upgrade (Recommended)
Apply the official patch by upgrading your DD-WRT router to build 45724 or later, which replaces unsafe string operations with bounded alternatives [references].
2. Temporary Mitigation (If patching is not immediately possible)
Since UPnP is disabled by default in DD-WRT, ensure it is turned off if it was previously enabled.
Via DD-WRT Web GUI:
- Log in to the DD-WRT Web Administration interface.
- Navigate to NAT / QoS -> UPnP.
- Set UPnP Service to Disable.
- Click Save and then Apply Settings.
Via Command Line Interface (SSH/Telnet):
# Disable UPnP service and commit changes
nvram set upnp_enable=0
nvram commit
# Terminate the running UPnP daemon
killall upnpdStop Exposing VPN Ports to the Internet — Switch to Zero-Trust Access
Eliminate public-facing VPN concentrators and firewall management ports with identity-first Zero-Trust Network Access.
Technical Root Cause & Exploitation Mechanics
This vulnerability (CVE-2021-27137) is a stack-based buffer overflow (CWE-121) residing in the UPnP (Universal Plug and Play) handling component (router/upnp/src/ssdp.c) of the DD-WRT open-source router firmware.
Root Cause & Exploit Mechanics
- Unsafe String Copy: The vulnerability exists within the
ssdp_msearchfunction, which processes incoming Simple Service Discovery Protocol (SSDP) discovery requests. The function utilizes the unsafestrcpyfunction to copy user-controlled input into a fixed-size internal stack buffer without validating the input length. - Attack Vector: An attacker can transmit a specially crafted SSDP
M-SEARCHrequest over UDP port 1900. By supplying an overly long header value, the attacker overflows the stack buffer, allowing them to overwrite the return address and hijack the control flow. - In-the-Wild Exploitation: This vulnerability is actively exploited and listed on the CISA KEV catalog. Threat actors, including Gafgyt variants like the
c0xmobotnet, leverage this flaw to compromise IoT devices, propagate malware, and terminate competing botnet processes on infected routers [references].
Official Vendor Advisories & References
An issue was discovered in router/upnp/src/ssdp.c in DD-WRT before 45724. An unsafe strcpy in the UPnP handling functionality allows an unauthenticated remote attacker to send a request that would overflow an internal fixed buffer. Exploitation requires the DD-WRT user to enable UPnP (which is off by default, and only listens on internal interfaces by default). This occurs in ssdp_msearch (reachable by an M-SEARCH request).
Subscribe to Daily Vulnerability Briefings & KEV Alerts
Concise morning briefings for SecOps, DevSecOps, and SRE teams covering newly exploited CVEs and mitigation priorities.