Summary
D-Link DWR-M921 firmware 1.1.50 contains a command injection vulnerability in the USSD configuration endpoint, where user-controlled input is passed into system commands without proper sanitization.
A remote attacker can exploit the ussdValue parameter in /boafrm/formUSSDSetup to execute arbitrary commands on the device, potentially gaining full control of the router.
Affected context
The vulnerability occurs in the web management interface of D-Link DWR-M921 routers running firmware version 1.1.50, specifically in the sub_419F20 function of /boafrm/formUSSDSetup.
It is exposed when the USSD configuration feature is reachable over the network and accepts user-supplied ussdValue input that is later incorporated into shell commands.
The issue is more impactful in deployments where the router's administration interface is accessible from untrusted networks or where default/weak credentials remain in use.
Exploit preconditions
- Attack surface: HTTP(S) interface of the router's web management panel.
- Required access: Ability to send crafted requests to
/boafrm/formUSSDSetup; in many setups this requires access to the admin interface, but misconfigurations may expose it more broadly. - Trigger point: Submission of the
ussdValueparameter containing crafted command sequences as part of USSD configuration actions. - Why exploitation is possible: The
ussdValueargument is concatenated or interpolated into an OS-level command without robust validation, sanitization, or safe command-building APIs, allowing attacker-controlled metacharacters to alter command structure.
Why this happens
This vulnerability stems from unsafe construction of shell commands using untrusted input in the sub_419F20 function.
Rather than treating ussdValue as opaque data, the implementation allows it to influence the structure of commands sent to the underlying operating system, aligning with CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection') and CWE-74: Improper Neutralization of Special Elements in Output.
The core bug class is failure to neutralize shell metacharacters and to separate command logic from user data, enabling attackers to break out of the intended USSD handling and execute arbitrary instructions.
Potential impact
- Execution of arbitrary system commands on the router.
- Complete compromise of the device's configuration and management plane.
- Installation of persistent malware or backdoors on the router.
- Interception, modification, or redirection of network traffic passing through the device.
- Use of the router as a pivot point for further attacks inside the local network.
- Enrollment of the device into botnets for DDoS or other malicious activities.
General mitigation guidance
Mitigation typically focuses on isolating shell invocation from user input and enforcing strict validation of configuration parameters:
- Treat all web-supplied parameters as untrusted and apply allowlist-based validation for
ussdValue(e.g., permitted characters, length, and format aligned with valid USSD codes). - Avoid building shell commands through string concatenation; instead, use APIs that separate command and arguments, or dedicated libraries that do not invoke a shell.
- Neutralize or reject input containing shell metacharacters, control characters, or unexpected tokens that are not valid in legitimate USSD requests.
- Run web management processes and any helper utilities with least privilege to limit the blast radius if input validation fails.
- Restrict network exposure of the management interface (e.g., disable WAN access, require VPN or management VLAN) and enforce strong authentication to reduce reachable attack surface.
How teams detect issues like this
Detection efforts can center on both code-level review and runtime monitoring:
- Static analysis: Define rules that flag string concatenation or formatting of shell commands using request parameters (such as
ussdValue), particularly in functions handling system orpopencalls. - Code review: Look for handlers in
/boafrm/formUSSDSetupand similar endpoints where user input is passed to shell utilities, checking for absence of allowlist validation and unsafe use of metacharacters. - Configuration and policy checks: Enforce internal development policies that prohibit direct shell invocation with unsanitized input and require the use of safe command-execution wrappers.
- Runtime monitoring: Inspect router logs and network telemetry for anomalous USSD requests containing shell control characters (
;,&&,|, backticks, etc.) and unusual command patterns. - Automated SAST and firmware analysis tools may help surface these patterns early, especially when integrated into product development or firmware security review workflows.

