Summary
GL-iNet GL-AR300M16 routers running firmware v4.3.11 contain an OS command injection flaw in the M.get_system_log function, where the module parameter is unsafely incorporated into system-level commands.
A remote attacker who can reach the router's management interface can send crafted input in this parameter to execute arbitrary commands with the router's privileges, potentially fully compromising the device and its network role.
Affected context
The vulnerability exists in the web or RPC management logic of GL-iNet GL-AR300M16 routers, specifically in the M.get_system_log functionality that retrieves system log data.
The issue arises when the module parameter is used to build shell commands without proper neutralization of special characters.
It is most relevant in deployments where the management API or web interface is reachable from untrusted networks (e.g., WAN exposure, VPN access, or compromised local clients), and where default or weak management protections are in place.
Exploit preconditions
- Attack surface: Router management interface or associated API exposing
M.get_system_log - Required access: Ability to invoke the log retrieval function (e.g., HTTP/JSON-RPC request); may depend on authentication configuration
- Trigger point: Submission of a crafted
moduleparameter value that is passed into a shell command - Why exploitation is possible: User-controlled data is concatenated or interpolated into a shell command without proper quoting, escaping, or use of safe command invocation APIs, enabling injection of additional commands
Why this happens
The underlying bug is a classic OS command injection issue.
The M.get_system_log function appears to construct shell commands by embedding the module parameter directly into a command string.
Without rigorous input neutralization, quoting, or use of safe process-spawning APIs that avoid the shell, the router interprets attacker-supplied metacharacters (such as command separators or redirection operators) as part of the command syntax.
This behavior aligns with CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection'), where untrusted input is allowed to alter the structure of an executed command instead of being treated as pure data.
Potential impact
- Execution of arbitrary OS commands with the privileges of the web/management service
- Complete takeover of the router, including persistent malware installation
- Interception, modification, or redirection of network traffic through the device
- Extraction of configuration data, including Wi-Fi credentials and VPN keys
- Use of the router as a pivot point for attacks against internal network hosts
- Enrollment of the device into botnets for DDoS or other malicious activity
General mitigation guidance
Effective mitigation focuses on preventing untrusted input from influencing shell command structure and reducing the privileges of components that must run commands:
- Replace shell-based command construction with safe process invocation APIs (e.g., exec family with argument arrays, libraries that bypass the shell).
- Treat all external parameters (like
module) as untrusted and enforce strict allowlists of expected values instead of passing arbitrary strings to commands. - Apply rigorous input validation that rejects characters and patterns that are not valid in log module identifiers, combined with robust encoding/quoting when interaction with the shell is unavoidable.
- Design the logging and diagnostic subsystem so that user-selectable options map to predefined internal actions rather than free-form commands.
- Run the management interface and any helper processes with the least privileges required and restrict filesystem and network capabilities to limit impact if compromise occurs.
How teams detect issues like this
Organizations can detect and manage command injection risks in embedded firmware and web management interfaces using a combination of static and dynamic approaches:
- Static analysis: Configure rules to flag dynamic shell command construction, such as string concatenation passed to
system(),popen(), backticks, or similar APIs, especially when parameters derive from HTTP/query inputs. - Code review: Treat any shell invocation in request-handling paths as a high-risk pattern; reviewers should verify the presence of strict validation and the use of argument arrays instead of shell strings.
- Firmware and configuration scanning: Use automated tools to inspect router firmware for common command execution APIs and map them back to externally reachable endpoints.
- Runtime monitoring: Where possible, monitor router logs for anomalous command execution, unexpected process spawning, or unusual outbound connections that may indicate exploitation attempts.

