Summary
A command injection vulnerability in the GL-iNet GL-MT3000 router allows attacker-controlled data in the port parameter of the s2s.enable_echo_server function to be executed as system commands.
When the router processes crafted requests to /cgi-bin/glc in the s2s.so native plugin, an unauthenticated remote attacker may execute arbitrary code with the device's privileges.
Affected context
This vulnerability arises in GL-iNet GL-MT3000 devices (firmware up to 4.4.5) within the web management interface that exposes /cgi-bin/glc.
The affected s2s.enable_echo_server function processes a port argument originating from HTTP requests and passes it into backend logic implemented by the s2s.so native plugin.
In deployments where the router's administration interface is reachable over the local network or internet, and where this endpoint is exposed, the vulnerable code path can be reached.
Exploit preconditions
- Attack surface: HTTP interface on the GL-MT3000 router, specifically the
/cgi-bin/glcendpoint. - Required access: Network access to the router's management HTTP port; depending on configuration, this may be LAN-only or internet-exposed.
- Trigger point: Invocation of
s2s.enable_echo_serverwith a craftedportparameter that injects shell metacharacters or additional commands. - Why exploitation is possible: The
portvalue is incorporated into a shell or command-line context without strict validation, sanitization, or proper parameterization, allowing the attacker's input to break out of the intended argument boundary.
Why this happens
The root cause is improper handling of externally supplied input that is used to construct operating system commands, matching CWE-77: Command Injection and CWE-74: Improper Neutralization of Data in Output.
Instead of treating the port parameter as untrusted data and strictly constraining it to a validated numeric range or using safe system call interfaces, the implementation appears to interpolate the value directly into a shell command or similar execution context.
This pattern allows attacker-controlled characters (such as shell metacharacters, pipes, or command separators) to alter the structure of the command, resulting in arbitrary command execution under the privileges of the web process on the router.
Potential impact
- Remote execution of arbitrary commands on the router's operating system.
- Installation of persistent malware, backdoors, or proxy services on the device.
- Interception, modification, or redirection of network traffic passing through the router.
- Retrieval or manipulation of configuration data, including Wi-Fi and VPN credentials.
- Use of the compromised router as a pivot point for further attacks inside the local network.
General mitigation guidance
Effective mitigation focuses on eliminating direct command construction from user input and reducing the trust boundary of exposed management interfaces.
Pattern-based mitigation strategies include:
- Constraining parameters such as
portto strict, validated formats (e.g., numeric-only, within allowed ranges) before use. - Replacing shell-based command execution with safer APIs that perform argument separation (for example, direct system calls, libraries, or framework abstractions that avoid shell interpretation).
- Encapsulating native plugin functions behind hardened input-validation layers, ensuring all CGI parameters are validated centrally.
- Applying least-privilege principles to web and plugin processes, so that even if a command is executed, its ability to modify the system is minimized.
- Limiting exposure of the administrative web interface to trusted networks, and disabling unnecessary remote management features to narrow the attack surface.
How teams detect issues like this
Detection often combines code-level analysis with runtime monitoring.
High-level approaches include:
- Static analysis rules that flag string concatenation or interpolation of HTTP parameters into command execution APIs (e.g.,
system,popen, shell calls) within CGI handlers and native plugins. - Manual code review focusing on CGI endpoints such as
/cgi-bin/glc, ensuring all parameters that reachs2s.soare validated and not used directly in shell contexts. - Configuration and policy checks that require all router firmware components to route external inputs through centralized validation frameworks.
- Runtime monitoring or logging of unusual commands invoked by web-facing processes, correlating them with HTTP requests to identify exploitation attempts.
- Use of automated firmware analysis tools that scan embedded web interfaces for command injection patterns and unsafe native plugin usage.

