GHSA-6c57-xfhw-j26x: Use-after-free in Zephyr native TCP `net_tcp_foreach()` due to dropping `tcp_lock` during the callback

Published Jun 15, 2026
·
Updated

Zephyr's native TCP stack iterates the global connection list in nettcpforeach() (subsys/net/ip/tcp.c) using the SYSSLISTFOREACHCONTAINERSAFE macro, which caches a pointer to the next list node. Prior to this fix the function released tcplock while invoking the per-connection callback and re-acquired it afterwards.

During that window a concurrent tcpconnrelease(), running on the dedicated TCP work-queue thread when a connection's reference count drops to zero (e.g. a remote peer closing or resetting the connection), can remove and kmemslabfree() the cached next connection. When the iterator advances it dereferences the freed (and possibly reallocated) slab memory — a use-after-free that can crash the system (denial of service) and, if the slot has been reused, cause the callback to operate on an attacker-influenced object (potential information disclosure or further fault).

nettcpforeach() is reached in production via the net conn network shell command and via nettcpcloseallforiface() on interface-down; the freeing side is driven by ordinary TCP traffic.

The fix moves the connection/context teardown in tcpconnrelease() inside the tcplock critical section and keeps tcplock held across the callback in nettcpforeach(). The defect was introduced with the modern (TCP2) stack in 2020 and affects releases up to and including v4.4.0.

Affected Software

1 affected component
Zephyr Zephyr<=4.4.0

Event History

Jun 15, 2026
CVE Published
via OSV·02:16 PM
Data Sourced
via OSV·02:16 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

Which systems are most exposed to this issue?

Systems using Zephyr's native TCP stack are exposed when net_tcp_foreach() can run concurrently with TCP connection teardown. The affected iterator is reached by the net conn network shell command and when an interface is brought down through net_tcp_close_all_for_iface().

2

What conditions are needed to trigger the use-after-free?

A local user or component must invoke a path that calls net_tcp_foreach(), while concurrent TCP traffic causes a connection reference count to reach zero and tcp_conn_release() frees a connection on the dedicated TCP work-queue thread. A remote peer closing or resetting a connection is an example of traffic that can drive the freeing side.

3

What is the practical impact?

The stale cached list entry can be dereferenced after its slab memory has been freed, causing a system crash and denial of service. If that slab slot is reused, the callback may instead process an attacker-influenced object, potentially leading to information disclosure or another fault.

4

What is the relevant remediation?

The fix keeps connection and context teardown in tcp_conn_release() inside the tcp_lock critical section. This prevents the iterator from advancing through a cached next connection that was removed and freed while the callback ran.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203