Severity:

HIGH RISK

(7.2)

OS Command Injection in D-Link DIR-823X set_upnp Handler

CVE-2026-2175

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-77, CWE-78

Impact:

Remote Code Execution on Network Device

Severity:

HIGH RISK

(7.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

D-Link DIR-823X routers contain an OS command injection weakness in the /goform/set_upnp endpoint, specifically within the sub_420618 function that processes the upnp_enable parameter.

When this endpoint is exposed to untrusted networks, a remote attacker can inject system commands through crafted requests, potentially taking control of the device and using it as a pivot for further attacks.

Affected context

This vulnerability occurs in D-Link DIR-823X firmware 250416 within the HTTP management interface that handles UPnP configuration via /goform/set_upnp.

It is relevant in environments where:

  • The web management interface is reachable from an attacker-controlled network segment (e.g., WAN, guest network, or compromised internal host)
  • The router processes the upnp_enable parameter and passes its value into OS-level commands without adequate sanitization
  • Default or weak access controls may allow unauthenticated or easily authenticated access to configuration endpoints

Exploit preconditions

  • Attack surface: HTTP management interface of the router at /goform/set_upnp
  • Required access: Network-level access to the router's web interface; authentication requirements depend on the specific configuration and access control settings
  • Trigger point: Submission of a crafted request containing a malicious upnp_enable parameter value that is later used within sub_420618
  • Why exploitation is possible: The implementation passes user-controlled data from upnp_enable into an OS command construction routine without proper validation or escaping, allowing the attacker to break out of expected arguments and append arbitrary commands

Why this happens

The core issue is improper handling of external input when composing shell commands in the router firmware.

Within the vulnerable function (sub_420618), the upnp_enable parameter appears to be concatenated or interpolated directly into a command string executed by the underlying operating system.

This behavior matches CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') and may also intersect with CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection').

Instead of limiting the input to a controlled set of values (e.g., strict boolean), the code path trusts and forwards the user-supplied value, allowing shell metacharacters and additional tokens to alter the command's structure and behavior.

Potential impact

  • Remote execution of arbitrary system commands on the router
  • Installation of persistent malware or backdoors on the device
  • Use of the compromised router as a pivot point to attack internal network hosts
  • Interception, modification, or redirection of network traffic passing through the device
  • Enrollment of the router into botnets for DDoS, scanning, or brute-force campaigns
  • Disruption of network availability by altering configuration or crashing critical services

General mitigation guidance

Effective mitigation focuses on removing direct command construction from user input and constraining configuration operations:

  • Replace shell-based command construction with direct API calls, system libraries, or configuration interfaces that do not require invoking a shell
  • Enforce strict validation on configuration parameters like upnp_enable, reducing them to a fixed set of allowed values (e.g., 0/1, true/false) and rejecting anything else
  • Avoid passing user-controlled data into system(), popen(), or similar APIs; where commands are unavoidable, avoid using the shell and use safe argument arrays
  • Run web management components with least privilege and restrict what they are permitted to modify on the underlying OS
  • Limit exposure of the management interface to trusted networks only, using firewall rules and management VLANs to reduce reachable attack surface

How teams detect issues like this

Detection typically combines firmware analysis, configuration review, and monitoring:

  • Static analysis: Scan router source or extracted firmware for patterns where HTTP parameters are concatenated into shell commands, especially around system(), popen(), or equivalent calls
  • Code review signals: Look for string-based command construction using user input, lack of whitelist validation, and presence of shell metacharacters in allowed inputs
  • Runtime monitoring: Observe the device for unusual child processes, unexpected outbound connections, or repeated invocations of shell interpreters originating from the HTTP service
  • Policy enforcement: Apply secure coding standards that prohibit direct shell invocation with untrusted data, supported by automated checks in build pipelines and firmware QA processes

Sources

SourceLink
github.comgithub.com/master-abc/cve/issues/31
vuldb.comvuldb.com/?ctiid.344876
vuldb.comvuldb.com/?id.344876
vuldb.comvuldb.com/?submit.749263
dlink.comdlink.com/

Frequently asked

questions

It can be, if the router's management interface or the /goform/set_upnp endpoint is exposed beyond trusted networks. Many deployments restrict management to internal segments, but misconfigurations or remote management features can make it reachable from the internet.

That depends on the device's authentication and access control configuration. If the endpoint is protected by authentication, the attacker would first need to obtain or bypass credentials; if misconfigurations or other issues expose it without proper protection, unauthenticated exploitation may be possible.

Remove shell-based command execution for configuration changes and replace it with direct, parameterized system calls or API invocations. Combine this with strict whitelisting of input values so that only known-good, minimal options are accepted.

Adopt secure coding practices that forbid passing user input into shell commands, enforce rigorous input validation on all HTTP parameters, and integrate static analysis and security-focused code reviews into the firmware development pipeline to catch command construction patterns early.

Find out what's already
exploitable in your codebase.