Summary
Totolink A7100RU firmware 7.4cu.2313_b20191024 contains an OS command injection vulnerability in the setIpv6LanCfg function of /cgi-bin/cstecgi.cgi, where the addrPrefixLen parameter is not safely handled.
A remote attacker can inject arbitrary system commands through this parameter, potentially achieving full compromise of the router when the vulnerable CGI endpoint is reachable.
Affected context
This vulnerability occurs in the web management interface of the Totolink A7100RU router, specifically within the CGI-based configuration handler that processes IPv6 LAN settings.
It is relevant when:
- The device is running firmware version 7.4cu.2313_b20191024 (or other builds with the same CGI logic),
- The /cgi-bin/cstecgi.cgi endpoint is accessible over the network (LAN or WAN, depending on configuration),
- The setIpv6LanCfg action is callable and accepts user-controlled input for addrPrefixLen without strict server-side validation or sanitization.
Exploit preconditions
- Attack surface: HTTP(S) interface exposed by the router's web management service.
- Required access: Network-level access to the management interface; authentication requirements depend on how the interface is configured (e.g., whether the endpoint is behind login or not).
- Trigger point: An HTTP request invoking /cgi-bin/cstecgi.cgi with action setIpv6LanCfg (or equivalent) where addrPrefixLen is supplied with crafted content.
- Why exploitation is possible: The addrPrefixLen parameter is incorporated into an underlying shell command or script without adequate input validation, escaping, or use of safe command-building APIs. As a result, shell metacharacters embedded in the parameter can break out of the intended context and execute arbitrary OS-level commands.
Why this happens
The underlying bug aligns with CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), often grouped with CWE-77: Command Injection.
The CGI handler for setIpv6LanCfg takes the addrPrefixLen value directly from the HTTP request and passes it into a shell command or shell-evaluated script.
Because the code relies on string concatenation or similar unsafe mechanisms without strict filtering or proper quoting, shell metacharacters and additional tokens supplied by an attacker are interpreted by the system shell as new commands or arguments.
This insecure pattern treats user input as trusted command content instead of data, allowing the attacker to influence command structure and behavior.
Potential impact
- Remote execution of arbitrary operating system commands on the router.
- Complete compromise of the device, including configuration, routing behavior, and administrative credentials.
- Installation of persistent malware or backdoors on the router.
- Use of the compromised router as part of a botnet for DDoS attacks or further network intrusions.
- Interception, modification, or redirection of network traffic passing through the device.
- Lateral movement into internal networks by pivoting from the compromised router.
General mitigation guidance
Effective mitigation generally focuses on removing the ability for user-controlled input to shape shell commands and on tightening the device's attack surface:
- Replace shell-based command construction with safer APIs that directly configure system parameters (e.g., system libraries, APIs, or configuration interfaces instead of invoking /bin/sh).
- If commands must be invoked, treat user input strictly as data: validate against a whitelist of allowed formats and ranges (e.g., numeric prefix lengths), and avoid passing any untrusted string directly to a shell.
- Use parameterized command execution or APIs that do not invoke a shell and automatically escape arguments.
- Enforce minimal exposure of the management interface: disable WAN access to the admin panel by default, restrict access to trusted networks, and require strong authentication.
- Apply least privilege to the process executing CGI handlers so that, even if command execution occurs, its ability to alter the system is limited.
How teams detect issues like this
High-level strategies to detect this class of vulnerability include:
- Static analysis: Search code for shell invocation functions (e.g., system, popen, exec*, shell scripts) that concatenate or interpolate request parameters like addrPrefixLen into command strings. Flag any patterns where CGI parameters reach shell APIs without strict validation.
- Code review: Inspect CGI handlers and router web UI code for:
- Direct use of HTTP parameters in shell commands or configuration scripts.
- Lack of type checking and range validation on numeric parameters.
- Reliance on blacklisting of special characters instead of strict whitelists.
- Dynamic testing: Use fuzzing and security testing tools to send crafted inputs to the setIpv6LanCfg endpoint and observe irregular command execution, response timing anomalies, or error messages indicative of shell parsing.
- Policy and build checks: Incorporate automated checks in the build pipeline to disallow direct shell invocation with untrusted data and to enforce coding standards for configuration handlers.

