Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2024-25331

CVE-2024-25331: D-Link DIR-822 Router RCE Vulnerability

CVE-2024-25331 is a remote code execution flaw in D-Link DIR-822 routers caused by an HNAP stack-based buffer overflow. This vulnerability allows unauthenticated LAN-side attackers to execute arbitrary code.

Published:

CVE-2024-25331 Overview

CVE-2024-25331 is a stack-based buffer overflow [CWE-121] in the Home Network Administration Protocol (HNAP) service of D-Link DIR-822 routers. The flaw affects DIR-822 Rev. B firmware v2.02KRB09 and DIR-822-CA Rev. B firmware v2.03WWb01. An unauthenticated attacker on the LAN can send a crafted HNAP request to overwrite the call stack and execute arbitrary code on the device. Successful exploitation grants the attacker control of the router with the privileges of the HNAP daemon, enabling traffic interception, pivoting into internal networks, and persistent firmware-level compromise.

Critical Impact

Unauthenticated attackers with LAN access can achieve remote code execution on affected D-Link DIR-822 routers through a single crafted HNAP request.

Affected Products

  • D-Link DIR-822 Rev. B Firmware v2.02KRB09
  • D-Link DIR-822-CA Rev. B Firmware v2.03WWb01
  • HNAP service component on affected DIR-822 hardware revisions

Discovery Timeline

  • 2024-03-12 - CVE-2024-25331 published to NVD
  • 2026-04-15 - Last updated in NVD database

Technical Details for CVE-2024-25331

Vulnerability Analysis

The vulnerability resides in the HNAP request handling code on the router's LAN-facing web interface. HNAP is a SOAP-based protocol D-Link uses for device management and configuration over HTTP. The handler copies attacker-controlled values from incoming HNAP SOAP requests into fixed-size stack buffers without enforcing length checks. Sending an oversized field overflows the buffer and overwrites the saved return address and adjacent stack data. Because the HNAP endpoint does not require authentication for the vulnerable code path, any host on the LAN can reach it. The advisory describes the issue as elevated from an HNAP stack overflow to full LAN-side unauthenticated RCE.

Root Cause

The root cause is missing bounds validation in the HNAP request parser, classified as a classic stack-based buffer overflow [CWE-121]. The firmware trusts the length of attacker-supplied SOAP element values when copying them into local stack buffers. Combined with the lack of authentication on the vulnerable HNAP action, the flaw collapses into a pre-auth memory corruption primitive.

Attack Vector

The attack requires network adjacency to the router's LAN interface but no credentials or user interaction. An attacker who has joined the wireless network, plugged into a LAN port, or compromised any LAN-connected host can reach the HNAP endpoint on the router's management IP. The attacker sends a crafted HTTP POST containing an HNAP SOAP envelope with an oversized field, triggering the overflow and redirecting execution to attacker-controlled shellcode or a ROP chain. No code example is published by the vendor or coordinator. Refer to the D-Link Security Announcement and the Ensign InfoSecurity Advisory for additional technical context.

Detection Methods for CVE-2024-25331

Indicators of Compromise

  • Unexpected HTTP POST requests to /HNAP1/ on the router's LAN IP from non-administrative hosts
  • HNAP SOAP requests containing abnormally long element values or malformed envelopes
  • Router crashes, reboots, or HNAP service restarts coinciding with inbound management traffic
  • New outbound connections initiated by the router to unfamiliar external hosts after suspicious HNAP traffic

Detection Strategies

  • Inspect LAN-side HTTP traffic for POSTs to /HNAP1/ and alert on SOAPAction headers paired with payloads exceeding expected size thresholds
  • Baseline normal HNAP usage from administrative hosts and flag HNAP requests originating from user workstations, IoT devices, or guest networks
  • Correlate router syslog or remote logging events that indicate httpd or HNAP daemon crashes with surrounding network traffic

Monitoring Recommendations

  • Forward router logs to a centralized logging or SIEM platform and monitor for repeated HNAP errors and unexpected reboots
  • Monitor DNS and outbound flow data from the router itself for beaconing behavior indicative of post-exploitation persistence
  • Track firmware versions across managed network equipment and alert when EOL or vulnerable builds remain in production

How to Mitigate CVE-2024-25331

Immediate Actions Required

  • Apply the firmware update referenced in the D-Link Security Announcement SAP10372 for DIR-822 Rev. B and DIR-822-CA Rev. B
  • Restrict LAN access to the router's management interface to a dedicated administrative VLAN or host
  • Replace the device if it has reached end-of-support and no fixed firmware is available for your hardware revision

Patch Information

D-Link published advisory SAP10372 covering DIR-822 Rev. B and DIR-822-CA Rev. B. Administrators should download the latest firmware build for their exact hardware revision from D-Link's regional support portal and verify the installed firmware no longer reports v2.02KRB09 or v2.03WWb01. Where the model is listed as end-of-life, D-Link's guidance is replacement rather than patching.

Workarounds

  • Segment the router's management plane onto a separate VLAN and block HNAP (/HNAP1/) access from user and IoT subnets using upstream firewall rules
  • Disable remote management features and ensure the WAN interface does not expose HNAP
  • Enforce WPA2/WPA3 with strong credentials to limit which devices can reach the LAN-side HNAP endpoint
  • Remove untrusted devices from the LAN until firmware is updated or the device is replaced
bash
# Example upstream firewall rule to block HNAP from a user VLAN to the router management IP
# Replace 10.0.10.0/24 with the user VLAN and 10.0.0.1 with the router management IP
iptables -I FORWARD -s 10.0.10.0/24 -d 10.0.0.1 -p tcp --dport 80 \
  -m string --string "/HNAP1/" --algo bm -j DROP

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.