PT-2026-161689

CVE-2026-95821

·

Published

2026-11-29

·

Updated

2026-11-29

Description by

CVSS 3.1
6.5
Medium
MetricsAV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L
The SOCKS5 client in subsys/net/lib/socks/socks.c passes the addresses of two of socks5 tcp connect()'s own stack variables, method rsp and cmd rsp, to net context recv() as the user data for the negotiation and CONNECT response callbacks. For a TCP context net context recv() reaches net tcp recv(), which only stores context->recv cb and conn->recv user data and never removes them. On the success path zsock connect ctx() immediately replaces them with zsock received cb(), but on every error path nothing did, so the network context was left holding a pointer into a stack frame that had already been destroyed.
Any remote peer acting as the proxy can arm this with a protocol-legal response: answering the method negotiation with NO ACCEPTABLE METHODS (0xFF), sending a bad version byte, returning a non-success REP in the CONNECT reply, or simply stalling until CONFIG NET SOCKETS CONNECT TIMEOUT expires all make socks5 tcp connect() return an error while the callbacks stay installed. The dangling pointer is then dereferenced asynchronously from the networking threads: tcp conn close() in subsys/net/ip/tcp.c invokes context->recv cb() on FIN, RST or timeout, and the callback memset()s through the stale pointer, while any further data on the socket reaches net context packet received() and makes net pkt read() write peer-supplied bytes there.
The result is a write of two to four bytes (zeroes on the teardown path, peer-chosen bytes on the data path) into a stack region of the thread that called connect(), at a moment when that thread may have reused the memory for a live frame. The write address is not attacker-controlled, so the practical impact is limited corruption or a crash rather than a directed memory-write primitive; the author observed it as a SEGV in tcp conn close() under CONFIG ASAN. Only configurations with CONFIG SOCKS enabled and a SOCKS5 proxy configured on the socket are affected.
The fix routes the error returns through a common exit that calls net context recv(ctx, NULL, K NO WAIT, NULL), uninstalling the callback and the user-data pointer before the stack frame goes away.
Exploitability
Exploit
Fix
Researchers
Vendors
Affected products
Related identifiers
Found an issue in the description? Have something to add? Feel free to write us 👾