/

CVE-2026-12197

Severity:

HIGH RISK

(7.2)

Command Injection (CWE-77) in Ruijie EG105G-P Router

CVE-2026-12197

Deferred

Vulnerability type

Category:

Command Injection

CWE:

CWE-74, CWE-77

Impact:

Remote Command Execution on Network Appliance

Severity:

HIGH RISK

(7.2)

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

Ruijie EG105G-P 2.340 contains a command injection vulnerability in the JSON-RPC diagnose endpoint, specifically within the nslookup function.

By manipulating the params.target argument, a remote attacker can inject system commands through the web interface and execute them with the router's backend privileges.

Affected context

The vulnerability exists in the web-based management interface of the Ruijie EG105G-P 2.340 firmware, within the /cgi-bin/luci/api/diagnose JSON-RPC endpoint that exposes diagnostic functionality such as nslookup.

It becomes relevant when the device's management interface is reachable over the network (typically LAN, but sometimes WAN if exposed) and the endpoint processes user-supplied parameters without adequate sanitization or command separation.

This issue is tied to the way user input is incorporated into shell commands, not to any specific deployment topology, though exposure is higher when the interface is accessible from untrusted networks.

Exploit preconditions

  • Attack surface: HTTP/HTTPS access to the router's web management API at /cgi-bin/luci/api/diagnose.
  • Required access: Network reachability to the management interface; depending on configuration, this may require local network access or, if exposed, be reachable from the internet.
  • Trigger point: Invocation of the nslookup JSON-RPC method with a crafted params.target value that introduces shell metacharacters or injected command segments.
  • Why exploitation is possible: User-controlled data is inserted into a shell command line without proper validation, encoding, or argument separation, allowing the attacker to break out of the intended command and execute arbitrary system commands under the router's backend context.

Why this happens

The flaw stems from constructing shell commands by concatenating user-controlled input into a command string and delegating execution to the system shell.

Instead of treating params.target as a strict, validated hostname or IP address, the implementation likely passes it directly to an underlying command such as nslookup via a shell, enabling interpretation of metacharacters (;, &&, |, etc.).

This behavior maps to CWE-77: Improper Neutralization of Special Elements used in a Command, and also relates to CWE-74, where special characters are insufficiently neutralized in the generated command-line context.

At an abstract level, the pattern is: user input → string concatenation into a shell command → execution with elevated privileges and no robust input normalization or confinement.

Potential impact

  • Remote attackers may execute arbitrary system commands on the router.
  • Attackers could modify or exfiltrate router configuration and sensitive network information.
  • The device could be converted into a foothold for further attacks on internal network hosts.
  • Malicious actors can install persistent malware or participate in botnets and DDoS campaigns.
  • Network traffic routing, DNS, or firewall rules may be altered, impacting availability and integrity.

General mitigation guidance

Effective mitigation focuses on removing the dependency on shell interpretation for user-supplied parameters and constraining diagnostic features.

Recommended defensive patterns include:

  • Avoid building shell command strings from user input; instead, call diagnostic utilities via safe APIs or libraries that pass arguments as arrays without invoking a shell.
  • Apply strict allow-list validation to target parameters, accepting only valid hostnames or IP addresses and rejecting any unexpected characters or formats.
  • Normalize and encode input before use in any system interaction, ensuring special shell metacharacters are never interpreted.
  • Run web and diagnostic components with least-privilege accounts and restrict system capabilities so that, even if command execution occurs, the impact is narrowed.
  • Minimize exposure of management endpoints by placing them behind VPNs or management networks and disabling unnecessary diagnostic APIs when not needed.

How teams detect issues like this

Detection involves a combination of code-centric and operational approaches:

  • Static analysis: Flag any occurrence where HTTP/JSON-RPC parameters are concatenated into strings passed to system(), popen(), backticks, or similar shell-executing primitives, especially around diagnostic utilities like nslookup, ping, and traceroute.
  • Code review: During manual review, pay special attention to diagnose or "test connectivity" endpoints, checking that all user inputs are strictly validated and passed as safe arguments rather than raw shell fragments.
  • Runtime monitoring: Implement logging and anomaly detection for unusual command-line invocations originating from web processes, including commands containing unexpected separators, redirections, or chained utilities.
  • Security testing: Use automated web security scanners and fuzzers to probe diagnostic endpoints for signs of command injection, supported by internal CI pipelines that include these tests on each firmware or software build.

Sources

SourceLink
github.comgithub.com/ictrun/java/issues/6
vuldb.comvuldb.com/cve/CVE-2026-12197
vuldb.comvuldb.com/submit/829253
vuldb.comvuldb.com/vuln/370840
vuldb.comvuldb.com/vuln/370840/cti

Frequently asked

questions

Exploitability depends on how the router's management interface is exposed. If the /cgi-bin/luci/api/diagnose endpoint is reachable from untrusted networks, attackers can exploit it remotely; if it is restricted to internal or management networks, exploitation is limited to those with network access to that segment.

The underlying description does not clearly specify authentication requirements. In many router interfaces, diagnostic APIs may be behind authentication, but misconfiguration or implementation choices can expose them without login. In practice, assume that any reachable, insufficiently protected management endpoint can be targeted.

The robust fix is to avoid passing user input through a shell at all. Instead, use parameterized process execution APIs or native libraries for DNS lookups, combined with strict allow-list validation of target values, and ensure the web handler runs with minimal privileges.

Prevention rests on secure design patterns: never construct shell commands from user input, enforce strong input validation and normalization, isolate diagnostic features from untrusted users, and incorporate security-focused code review and automated static analysis into the development lifecycle.

Find out what's already
exploitable in your codebase.