Summary
A command injection vulnerability in the GL.iNet GL-MT3000 router's /cgi-bin/glc SET_USER_PWD handler allows attacker-controlled password input to be incorporated into a shell command.
When exposed over the network, this flaw can let a remote attacker execute arbitrary system commands with the privileges of the web service, depending on how the device is deployed and authenticated.
Affected context
The vulnerability occurs in the GL-MT3000 firmware (up to version 4.4.5) within the CGI endpoint /cgi-bin/glc, specifically in the SET_USER_PWD handler function (FUN_0042e200).
The handler constructs a shell command that includes the Password argument, and although single quotes are escaped and the input is placed inside a single-quoted shell context, the overall design still pipes user-controlled data into a shell.
In deployments where this CGI is reachable over the LAN or exposed externally, and where authentication is weak, attackers may be able to submit crafted Password values to influence command execution.
Exploit preconditions
- Attack surface: HTTP-based management interface on the GL-MT3000, specifically the
/cgi-bin/glcendpoint using theSET_USER_PWDaction. - Required access: Ability to send HTTP requests to the router's management interface; depending on configuration, this may require valid credentials or network proximity (e.g., being on the same LAN or Wi-Fi).
- Trigger point: The vulnerable code path is invoked when the router processes a request that sets or changes the user password and passes the supplied
Passwordparameter into a shell command. - Why exploitation is possible: The implementation uses shell command construction with embedded user data instead of a safer, parameterized system call, leaving room for command injection patterns, even though single quotes are escaped and the parameter is placed in a single-quote context. This maps to CWE-77 (Improper Neutralization of Special Elements used in a Command) and CWE-74 (Improper Neutralization of Data within Output Used by a Downstream Component).
Why this happens
The root cause is reliance on shell command composition that directly embeds user-controlled input, rather than using APIs that separate code and data.
In the SET_USER_PWD handler, the Password parameter is sanitized only for single quotes and then interpolated into a shell single-quoted context. While this mitigates some trivial injections, the design still treats user input as part of a shell command, which is inherently risky.
This pattern fits CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection'), because the neutralization strategy is incomplete and fragile, and CWE-74: Improper Neutralization of Data within Output Used by a Downstream Component, as untrusted data is passed into a shell (a downstream interpreter) without robust isolation.
Potential impact
- Remote execution of arbitrary shell commands within the router's firmware environment.
- Complete compromise of the device's configuration and stored credentials.
- Use of the router as a foothold for lateral movement inside the local network.
- Deployment of persistent malware or participation in botnets (e.g., for DDoS).
- Disruption of network connectivity or denial of service by manipulating system settings.
General mitigation guidance
Mitigations focus on removing the need to invoke a shell with user-controlled data and ensuring strict separation between user input and command logic:
- Replace shell-based command construction with direct system or library calls that accept structured parameters (e.g., using dedicated APIs for user management instead of invoking
/bin/shor similar). - If shell invocation is unavoidable, construct commands as fixed templates and pass user data via safe channels (such as environment variables or argument arrays) without allowing it to affect the shell's parsing.
- Apply strict input validation and normalization for fields like passwords, limiting allowed characters and length to what is operationally necessary and rejecting anything outside a defined whitelist.
- Run web-facing components and associated scripts with least-privilege accounts, so that even if an injection occurs, the impact is constrained.
- Restrict management interface exposure to trusted networks and enforce strong authentication mechanisms, reducing the number of potential attackers who can reach vulnerable handlers.
How teams detect issues like this
Detection is typically achieved by combining code-level review with behavioral monitoring:
- Static analysis: Configure rules to flag any use of shell execution functions (e.g.,
system,popen,exec*, or equivalent) that include variables derived from HTTP parameters such asPassword, especially in CGI handlers. - Code review signals: During manual reviews, look for string concatenation or formatting operations that build shell commands from request parameters; pay special attention to "escape and embed" patterns that attempt to sanitize but still rely on the shell.
- Policy enforcement: Enforce coding standards that prohibit shelling out from web handlers unless an explicit security exception is granted and documented, and require security review for any such cases.
- Runtime monitoring: Use logging or intrusion detection to track anomalous command executions originating from web endpoints, correlating unusual shell invocations with HTTP requests that contain suspicious characters or patterns in parameters like
Password.

