Skip to main content
Menu
Advisories

Netty io_uring Unix-domain SCM_RIGHTS receive still leaks extra file descriptors (incomplete fix for CVE-2026-45536)

GHSA-79Q2-MHF4-2J6JPublished Updated GitHub

Description

io.netty:netty-transport-classes-io_uring / netty-transport-native-io_uring implement Unix-domain recvmsg in Java. CVE-2026-45536 taught epoll/kqueue to reject truncated cmsgs, compute nfds from cmsg_len, and close surplus fds in netty_unix_socket_recvFd(). io_uring never calls that function. IoUringDomainSocketChannel.readComplete0() on IORING_OP_RECVMSG takes readMsgHdrMemory.getScmRightsFd() → CmsgHdr.readScmRights(), which is a single ByteBuffer.getInt at the data offset. There is no MSG_CTRUNC check, no nfds, no close of extras, no cmsg_level/cmsg_type check. On 64-bit Linux the control buffer sized CMSG_SPACE(sizeof(int)) is 24 bytes — identical to CMSG_SPACE(2*sizeof(int)) after 8-byte align — so two fds fit without MSG_CTRUNC and the second stays open in the receiver.

Details

CVE-2026-45536 (epoll/kqueue native path) added:

  1. MSG_CTRUNC → error;
  2. nfds = (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int);
  3. if nfds > 1, close extras (and revoke an already-accepted fd).

io_uring fd-pass receive is:

  • IoUringDomainSocketChannel.readComplete0() for IORING_OP_RECVMSG;
  • MsgHdrMemory.getScmRightsFd() → MsgHdr.getCmsgData() → CmsgHdr.readScmRights();
  • cmsghdr.getInt(cmsghdr.position() + cmsgHdrDataOffset) only.

MSGHDR_OFFSETOF_MSG_FLAGS exists but is unused on this path.

64-bit Linux layout: sizeof(struct cmsghdr) = 16; CMSG_LEN(4) = 20; CMSG_SPACE(4) = CMSG_ALIGN(20) = 24; CMSG_LEN(8) = 24; CMSG_SPACE(8) = 24. Two packed int fds occupy the same control buffer Netty allocated for one. Kernel does not set MSG_CTRUNC. The second fd is duplicated into the process and never closed.

Trigger: a peer of an IoUringDomainSocketChannel in DomainSocketReadMode.FILE_DESCRIPTORS sends one SCM_RIGHTS cmsg with two fds. Each such message leaks one fd. Repeating hits RLIMIT_NOFILE (often 1024). Leaked fds remain in /proc/self/fd.

Vulnerable code

src/transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringDomainSocketChannel.java (lines 216–236) — RECVMSG completion takes one fd and fires it; no surplus close:

        protected void readComplete0(byte op, int res, int flags, short data, int outstanding) {
            if (op == Native.IORING_OP_RECVMSG) {
                ...
                try {
                    int nativeCallResult = res >= 0 ? res : Errors.ioResult("io_uring recvmsg", res);
                    int nativeFd = readMsgHdrMemory.getScmRightsFd();
                    allocHandle.lastBytesRead(nativeFd);
                    allocHandle.incMessagesRead(1);
                    pipeline.fireChannelRead(new FileDescriptor(nativeFd));
                } catch (Throwable throwable) {
                    handleReadException(pipeline, null, throwable, false, allocHandle);
                } finally {
                    allocHandle.readComplete();
                    pipeline.fireChannelReadComplete();
                }
                return;
            }

src/transport-classes-io_uring/src/main/java/io/netty/channel/uring/CmsgHdr.java (lines 61–63) — only the first SCM_RIGHTS int:

    static int readScmRights(ByteBuffer cmsghdr, int cmsgHdrDataOffset) {
        return cmsghdr.getInt(cmsghdr.position() + cmsgHdrDataOffset);
    }

Contrast: src/transport-native-unix-common/src/main/c/netty_unix_socket.c netty_unix_socket_recvFd() (CVE-2026-45536) checks MSG_CTRUNC, computes nfds, and closes extras — never called from io_uring.

PoC

API recipe (Linux; Unix-domain peer of a Netty io_uring channel in FILE_DESCRIPTORS mode — the same control-buffer size Netty uses):

# Create Unix domain socket pair
sock_a, sock_b = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM)

# Open 2 files to get fds
fds_to_send = [os.open("/dev/null", os.O_RDONLY) for _ in range(2)]

# Send 2 fds in one SCM_RIGHTS cmsg
sock_a.sendmsg([b'\x00'], [(socket.SOL_SOCKET, 1, struct.pack("2i", *fds_to_send))])

# Close sender's copies
for fd in fds_to_send:
    os.close(fd)

# Receive with control buffer = CMSG_SPACE(sizeof(int)) = 24 bytes (same as Netty io_uring)
msg, ancdata, flags, addr = sock_b.recvmsg(1, 24)

# MSG_CTRUNC is NOT set (flags & MSG_CTRUNC == 0)
# SCM_RIGHTS cmsg contains 2 fds
# CmsgHdr.readScmRights() reads only the first fd
# Second fd is leaked (still open, never closed)

On the Netty side the first fd becomes pipeline.fireChannelRead(new FileDescriptor(nativeFd)); the second is never returned and never closed.

Impact

Denial of service by file-descriptor exhaustion: a local (or otherwise connected) peer of an io_uring domain-socket channel in DomainSocketReadMode.FILE_DESCRIPTORS can leak one fd per two-fd SCM_RIGHTS send until the process cannot open files, sockets, or devices. Leftover fds may also be reachable via /proc/self/fd. epoll/kqueue no longer have this hole after CVE-2026-45536; io_uring still does. No extra credentials beyond the ability to send on that Unix socket.

Affected versions

References

GitHub · netty/netty