Summary
Multiple ipTIME router models contain a command injection flaw in the upnp_relay() function, where the controlURL parameter used for UPNP port-forwarding is passed directly to system() without proper validation.
An attacker who can influence the controlURL value may be able to inject arbitrary operating system commands, leading to full takeover of the router and its network traffic.
Affected context
This vulnerability occurs within the UPNP port-forwarding relay logic of certain ipTIME router firmware builds, specifically in the upnp_relay() function.
The risk is present when the router:
- Exposes or processes UPNP control requests from local or upstream networks
- Uses the controlURL value directly when building shell commands
- Executes those commands via system() or similar OS interfaces
The issue is most critical in deployments where UPNP is enabled and reachable by untrusted or partially trusted clients.
Exploit preconditions
- Attack surface: UPNP control interface / port-forwarding relay path on the router
- Required access: Ability to send or influence UPNP requests that determine the controlURL value (often from the local network, and in some misconfigurations from external networks)
- Trigger point: Invocation of upnp_relay() when processing port-forwarding information, where the crafted controlURL is incorporated into a system() call
- Why exploitation is possible: User-controlled data (controlURL) is concatenated into a shell command string without validation, sanitization, or parameterization, allowing shell metacharacters to break out of the intended command context
Why this happens
The core issue is the unsafe construction and execution of shell commands with untrusted input inside router firmware.
In upnp_relay(), the controlURL value—derived from UPNP control messages—is treated as trusted and embedded directly into a command string passed to system().
This pattern maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), manifesting as OS command injection: attacker-supplied data is interpreted by the command processor as executable syntax instead of inert data.
The lack of input normalization, character whitelisting, or safe command-building APIs makes it possible for crafted controlURL values to inject and execute arbitrary commands with the privileges of the router process.
Potential impact
- Arbitrary command execution on the router's underlying operating system
- Complete compromise of router configuration (DNS settings, routing, firewall rules)
- Persistent malware installation or backdoors on the device
- Traffic interception, redirection, or man-in-the-middle attacks against connected clients
- Use of the router as a node in botnets or for launching further attacks within the local network
- Loss of confidentiality for network topology and connected device information
General mitigation guidance
Mitigations generally focus on treating all UPNP-derived values as untrusted and removing direct shell interpretation of user-controlled data.
Defensive patterns include:
- Replacing raw system() calls with safer APIs that avoid the shell (e.g., direct system calls, library functions, or parameterized command execution)
- Enforcing strict validation and canonicalization of UPNP parameters, including controlURL, using allowlists of expected formats and characters
- Normalizing and constraining user input to fixed, well-defined tokens or IDs instead of arbitrary strings
- Applying least-privilege principles to the process handling UPNP so that, if compromised, it has minimal ability to alter system-wide configuration
- Providing configuration options to disable UPNP or limit it to known-safe network segments, reducing exposure if unsafe handling remains
How teams detect issues like this
Detection approaches can combine code-level and behavior-level analysis:
- Static analysis: Search for uses of system(), popen(), or equivalent OS execution APIs where arguments are built from UPNP or other network-derived inputs; flag dynamic string concatenation patterns
- Code review: Examine the UPNP handling and upnp_relay() logic for direct interpolation of controlURL and other user-controlled fields into shell commands; ensure all such paths are either removed or strictly sanitized
- Firmware scanning: Use automated firmware analysis tools to identify command injection sinks and tainted data flows from network input to OS command execution
- Runtime monitoring: Observe router logs and network activity for anomalous or unexpected command invocations originating from UPNP request handling, as well as unusual outbound connections from the router
Policy-based checks in CI/CD for embedded firmware source can enforce rules against unparameterized shell command execution with external input.

