Summary
The Tenda HG series firmware contains a command injection flaw in the /boaform/admin/formLogin login interface, where the checkUserFromLanOrWan function unsafely processes the Host parameter.
A remote attacker can inject operating system commands via the Host header/argument, potentially gaining control over the affected device when the vulnerable login path is reachable.
Affected context
This vulnerability occurs in Tenda HG10 US_HG7_HG9_HG10re_300001138_en_xpon firmware within the web-based management interface.
It is specifically tied to the login handler at /boaform/admin/formLogin, where the checkUserFromLanOrWan function inspects the request's Host value.
The issue is present when:
- The device's HTTP/administration interface is exposed (LAN or WAN, depending on configuration),
- The login endpoint is accessible without additional proxy or WAF sanitization,
- And the backend logic passes the Host input into shell or OS-level commands without robust sanitization or safe APIs.
Exploit preconditions
- Attack surface: HTTP(S) interface of the router/modem, particularly requests reaching
/boaform/admin/formLogin. - Required access: Network reachability to the management web interface (from LAN by default; from WAN if remote management or port forwarding is enabled).
- User interaction: None required beyond the attacker sending crafted HTTP requests.
- Trigger point: Processing of a login request where the Host argument/header is parsed by
checkUserFromLanOrWan. - Why exploitation is possible: The Host value is incorporated into a command execution context without strict validation, encoding, or use of parameterized/safe system APIs, enabling attacker-controlled command fragments to be executed by the underlying shell.
Why this happens
The root cause is unsafe construction of OS-level commands using untrusted input from the Host parameter within the checkUserFromLanOrWan function.
Instead of using safe, parameterized system APIs or fully separating data from command logic, the implementation likely concatenates the Host value into a shell command string or uses an API that invokes a shell for convenience.
This aligns with:
- CWE-77: Command Injection, where shell metacharacters or injected arguments modify the intended command behavior.
- CWE-74: Improper Neutralization of Special Elements in Output, since the user-controlled data is not correctly sanitized or encoded before being passed into an execution context.
In abstract terms, the pattern is: "Untrusted request parameter is embedded into a command line without strict validation or escaping, letting user input control part of the command."
Potential impact
- Remote execution of arbitrary OS commands on the affected Tenda device.
- Full compromise of the router's configuration and administrative interface.
- Installation of persistent malware or backdoors on the device.
- Interception, modification, or redirection of network traffic passing through the device.
- Use of the compromised device as part of a botnet for further attacks (DDoS, scanning, etc.).
- Lateral movement attempts into the internal network behind the router.
General mitigation guidance
Mitigation focuses on eliminating direct command construction from untrusted input and tightening the management interface exposure:
- Replace shell-based invocation patterns (e.g., string-constructed commands) with direct system APIs that do not invoke a shell and treat all parameters as data.
- Apply strict allowlisting for the Host value or any network-originated inputs used in control paths; reject or normalize unexpected characters and formats.
- Neutralize shell metacharacters and control characters if legacy code must still interface with command-line utilities.
- Enforce principle of least privilege for processes that handle HTTP login logic so that even if a command is executed, its capabilities are constrained.
- Limit exposure of the management interface to trusted networks only, disabling WAN administration unless strictly necessary and protected by additional controls (VPN, IP filters).
- Adopt secure-by-default templates and helper functions for running external programs, preventing developers from falling back to raw shell execution.
How teams detect issues like this
Detection can rely on both code-centric and operational techniques:
- Static analysis: Scan firmware or source for patterns like
system(),popen(), backtick execution, or shell-invoking wrappers where request parameters (notably Host or other headers) are concatenated into command strings. - Code review signals: Pay attention to login and access-control handlers that inspect LAN/WAN or Host values and then call external utilities or scripts; ensure inputs are validated and not used to build shell commands.
- Config and policy enforcement: Establish coding standards that forbid direct shell command construction with user input and require wrappers or libraries that enforce parameterization.
- Runtime monitoring: Use logging or IDS/IPS/WAF signatures to detect anomalous Host headers containing shell metacharacters, pipelines, or obvious command fragments indicative of injection attempts.
- Automated tooling: Employ firmware analysis platforms and SAST tools capable of tracking data flow from HTTP request parsing to command-execution APIs, flagging untrusted-to-command paths.

