HIGH 8.1

CVE-2026-56123: socat SOCKS5 Heap Buffer Overflow (8.1 HIGH)

socat, a utility for establishing two-way network data streams, has a critical flaw in how it parses SOCKS5 proxy responses. When connecting through a malicious SOCKS5 proxy, an attacker can craft a specially formed response that causes socat to write arbitrary data into its own memory beyond the intended boundaries. This memory corruption could allow the attacker to crash the application or potentially execute code on the affected system. The vulnerability affects socat versions 1.8.0.0 through 1.8.1.1.

Source data · NVD / CISA · public domain

CVSS
3.1 · 8.1 HIGH · CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H
Weaknesses (CWE)
CWE-122
Affected products
1 configuration(s)
Published / Modified
2026-06-25 / 2026-06-26

NVD description (verbatim)

socat versions 1.8.0.0 through 1.8.1.1 contain a heap-based buffer overflow vulnerability that allows a malicious SOCKS5 proxy server to overwrite adjacent heap memory by exploiting a sign-extension flaw in the DOMAINNAME reply parser. During connection setup, the domain name length byte is read through a signed char field causing a negative bytes_to_read value that is implicitly converted to size_t, resulting in an unbounded heap write into the 262-byte reply buffer with attacker-controlled size and content.

2 reference(s) · View on NVD →

SEC.co analysis · AI-assisted, reviewed against source

Technical summary

The vulnerability stems from a sign-extension error in the DOMAINNAME reply parser of socat's SOCKS5 implementation. The domain name length field is read into a signed char variable, and when this value is negative (high bit set), it undergoes implicit conversion to size_t for a heap write operation. This conversion produces a very large unsigned integer, causing an unbounded write to a 262-byte buffer. An attacker controlling a SOCKS5 proxy server can exploit this by sending a crafted response with a domain length byte interpreted as a negative signed value, triggering a heap-based buffer overflow that corrupts adjacent heap memory with attacker-supplied content.

Business impact

Organizations using socat as a proxy client or in network automation pipelines face risk of service disruption and potential code execution if their traffic is routed through compromised or attacker-controlled SOCKS5 proxies. This is particularly concerning in environments where socat bridges untrusted networks or where proxy infrastructure cannot be fully validated. Exploitation could lead to unauthorized access to systems running socat, data exfiltration, or lateral movement within connected networks.

Affected systems

The vulnerability affects socat versions 1.8.0.0 through 1.8.1.1 from dest-unreach. Any deployment using these versions to establish SOCKS5 connections is at risk, especially those relying on third-party or external proxy servers. Systems where socat runs with elevated privileges or handles sensitive data are of highest concern.

Exploitability

Exploitation requires that a victim's socat instance connect through an attacker-controlled or compromised SOCKS5 proxy server. The attack vector is network-based with no authentication required from the proxy perspective, but successful exploitation depends on the victim initiating a connection and the attacker being positioned to intercept or host the proxy endpoint. The CVSS vector reflects high complexity, suggesting the attack requires specific conditions but poses significant impact once achieved.

Remediation

Upgrade socat to a patched version released after 1.8.1.1. Verify the specific patched version number in the official dest-unreach advisory. Until patching is possible, restrict socat's use to trusted SOCKS5 proxies only, ideally those running on the same network segment with network controls in place. Consider replacing SOCKS5-based connections with alternative transport mechanisms where feasible.

Patch guidance

Check the dest-unreach project repository and advisory page for the next stable release after version 1.8.1.1. Apply patches to all instances of socat in production. Test patched versions in a staging environment before deploying to production, particularly in environments where socat is chained with other critical processes.

Detection guidance

Monitor for unusual memory access patterns or crashes of socat processes, particularly when connected to external SOCKS5 proxies. Inspect network traffic for DOMAINNAME replies in SOCKS5 handshakes with suspiciously large or negative length fields. Use memory sanitizers (ASan, MSan) in development and testing environments to catch heap corruption. Log all SOCKS5 proxy connections and validate that proxies are from approved, internal sources.

Why prioritize this

This vulnerability merits rapid attention due to its HIGH CVSS score (8.1), the potential for remote code execution, and the breadth of possible attack scenarios in networked environments. Although it requires an attacker to control or compromise a SOCKS5 proxy, the impact is severe. Organizations should prioritize patching production instances within one to two weeks, with higher urgency for systems exposed to untrusted networks.

Risk score, explained

The CVSS 3.1 score of 8.1 reflects high impact across confidentiality, integrity, and availability, combined with a network attack vector and no authentication requirement. The high complexity factor reflects the need for specific conditions (malicious proxy) rather than widespread exposure. This score appropriately captures the severity of heap corruption leading to potential code execution.

Frequently asked questions

Can socat be exploited if I only use trusted, internal SOCKS5 proxies?

If your SOCKS5 proxies are genuinely internal and air-gapped from untrusted networks, the risk is substantially reduced. However, upgrading remains prudent as a defense-in-depth measure, especially if any proxy infrastructure could be compromised or accessed by insiders.

Does this vulnerability affect socat when not using SOCKS5?

No. This specific vulnerability is limited to the SOCKS5 DOMAINNAME reply parser. If your socat deployments do not use SOCKS5 proxies, they are not affected by this issue. Verify your socat configuration to confirm whether SOCKS5 proxy functionality is in use.

What is the difference between a heap buffer overflow and other memory corruption bugs?

A heap buffer overflow occurs when data is written beyond the bounds of a buffer on the heap (dynamically allocated memory). Unlike stack overflows, heap corruption is harder to detect and may affect the integrity of other heap-allocated structures. In this case, it can corrupt adjacent memory used by the application, potentially allowing an attacker to influence program behavior or achieve code execution.

Is there a workaround if I cannot patch immediately?

The most practical workaround is to avoid SOCKS5 proxy connections or restrict them to proxies you fully control and trust. You may also consider isolating socat processes with security containers or running them with minimal privileges. These measures reduce but do not eliminate risk; patching should be prioritized as soon as feasible.

This analysis is provided for informational purposes to help organizations assess and prioritize security responses. It is not a substitute for official vendor advisories or professional security assessments. Always verify patch availability and compatibility with your environment before deploying. SEC.co makes no warranty regarding the completeness or accuracy of this information and recommends consulting official dest-unreach documentation and your organization's security team for definitive guidance. Source: NVD (public-domain), retrieved 2026-08-03. Analysis generated by SEC.co (claude-haiku-4-5).