/

CVE-2026-31178

Severity:

CRITICAL RISK

(9.8)

OS Command Injection in ToToLink A3300R STUN Configuration

CVE-2026-31178

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Remote Code Execution on Router Firmware

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

ToToLink A3300R firmware v17.0.0cu.557_B20221024 contains an OS command injection vulnerability in the handling of the stunMaxAlive parameter on the /cgi-bin/cstecgi.cgi endpoint.

When attacker-controlled input is passed to this parameter, it can be executed as part of system commands on the router, enabling full remote compromise under the right network conditions.

Affected context

This vulnerability affects ToToLink A3300R routers running firmware v17.0.0cu.557_B20221024 where the /cgi-bin/cstecgi.cgi endpoint is reachable (e.g., from the LAN or, if misconfigured, from the WAN/Internet).

The issue is tied to request processing for configuration-related parameters, specifically stunMaxAlive, which is likely used for STUN/VoIP or connectivity keep-alive settings.

The flaw manifests when the backend CGI handler builds or forwards shell commands using this parameter without sufficient validation or escaping, allowing input to cross the boundary from data to executable instructions.

Exploit preconditions

  • Attack surface: HTTP interface exposed by the router at /cgi-bin/cstecgi.cgi
  • Required access: Ability to send crafted HTTP requests to the management interface (LAN by default; potentially WAN if remote admin is enabled or access controls are weak)
  • Trigger point: Submission of a malicious stunMaxAlive parameter value in a request processed by the vulnerable CGI script
  • Why exploitation is possible: The application constructs and executes OS-level commands incorporating stunMaxAlive without proper sanitization, quoting, or use of safe process-spawning APIs, leading to direct command injection (CWE-78)

Why this happens

The underlying bug class is OS command injection, where user-controlled input is concatenated into a shell command string.

In the CGI handler for /cgi-bin/cstecgi.cgi, the stunMaxAlive parameter appears to be treated as a trusted numeric or configuration value but is passed into a command execution context (such as system(), popen(), or equivalent) without strict validation and encoding.

This maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, in which meta-characters (e.g., ;, &&, |) within attacker-controlled data are interpreted by the shell as separate commands or arguments, breaking the intended command structure.

Abstractly, the insecure pattern is: "build a shell command string using request parameters and execute it" instead of using parameterized, non-shell APIs or enforcing a strict whitelist and type constraints.

Potential impact

  • Remote execution of arbitrary system commands on the router
  • Full compromise of router configuration (DNS, routing, firewall rules)
  • Installation of persistent malware or backdoors on the device
  • Interception, redirection, or degradation of user network traffic
  • Use of the compromised router as part of a botnet or platform for further attacks
  • Potential lateral movement to other devices on the internal network

General mitigation guidance

Effective mitigation focuses on eliminating direct shell command construction with user input and constraining how configuration parameters are processed:

  • Treat all HTTP parameters, including stunMaxAlive, as untrusted, regardless of expected type (e.g., numeric) and enforce strict input validation and normalization.
  • Replace shell-based command execution with safer system APIs that accept arguments as arrays, avoiding shell parsing and meta-character interpretation.
  • Apply strong allowlists for acceptable values and ranges (e.g., numeric bounds) and reject any input that falls outside tightly defined constraints.
  • Avoid passing configuration fields directly into command lines; instead, map validated values to pre-defined options or configuration files handled by privileged services.
  • Run router management processes with least privilege and separate responsibilities so that compromise of the CGI handler does not automatically imply full system compromise.
  • Disable unnecessary remote management exposure by default and encourage deployment configurations that restrict the management interface to trusted networks.

How teams detect issues like this

Detection typically combines code-centric and behavior-centric approaches:

  • Static analysis: Scan firmware source (or decompiled binaries where feasible) for calls to system, popen, exec*, or equivalent functions that directly incorporate HTTP parameters or query string/body data.
  • Code review signals: Flag CGI handlers and web management components that:
  • Build shell command strings using string concatenation or formatting.
  • Do not enforce strict validation, typing, and bounds on configuration parameters like stunMaxAlive.
  • Contain comments or logic indicating direct interaction with system binaries or scripts.
  • Policy enforcement: Introduce secure coding guidelines that prohibit shell invocation with untrusted data and enforce mandatory reviews for any new code that interacts with the system shell.
  • Runtime monitoring: Where supported, inspect router logs or network telemetry for anomalous requests to /cgi-bin/cstecgi.cgi containing shell meta-characters, excessively long parameter values, or unusual patterns that may indicate exploit attempts.
  • Automated tooling: Apply firmware security scanners or SAST tools configured with rules for command-injection sinks and tainted data propagation to identify similar patterns systematically.

Sources

SourceLink
github.comgithub.com/Svigo-o/TOTOLINK-Vul/tree/main/totolink-a3300r-stun-max-alive-cmd-injection

Frequently asked

questions

It can be, depending on how the router is deployed. If the management interface or /cgi-bin/cstecgi.cgi is exposed to the WAN (e.g., via remote administration, port forwarding, or misconfiguration), an external attacker may be able to exploit it; otherwise, exploitation is typically limited to attackers on the local network.

The available information does not clearly state whether authentication is required. However, many similar firmware vulnerabilities are exposed on endpoints with weak or missing access control. Security teams should assume that if an attacker can reach the endpoint and there is no robust authentication and authorization check around it, exploitation may be possible without credentials.

The most robust fix is to remove any dependency on shell command interpretation for user-supplied data. Replace shell invocations with direct, parameterized system calls or configuration APIs, and enforce strict validation and whitelisting on every parameter that influences system behavior.

Adopt a defensive design approach where web-facing components never construct shell commands from request data, enforce input validation at both the framework and application layers, and subject all management-plane code to security review and automated static analysis focused on injection sinks. Combining these practices with least-privilege process isolation and minimal exposure of management interfaces significantly reduces the risk of command injection issues.

Find out what's already
exploitable in your codebase.