Netty: Unix-socket fd receive leaks descriptors when peer sends two at once
netty
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| io.netty:netty-transport-native-epoll Maven |
|
|
| io.netty:netty-transport-native-kqueue Maven |
|
netty
| Product | Affected | Fixed in |
|---|---|---|
| io.netty:netty-transport-native-epoll Maven |
|
|
| io.netty:netty-transport-native-kqueue Maven |
|
< 4.1.135.Final
|
Netty is a network application framework for development of protocol servers and clients. Prior to versions 4.1.135.Final and 4.2.15.Final, netty_unix_socket_recvFd sets msg_control to `char control[CMSG_SPACE(sizeof(int))]` (line 940) — 24 bytes on 64-bit Linux. A peer-sent SCM_RIGHTS cmsg carrying two ints has cmsg_len = CMSG_LEN(8) = 24, which fits exactly with no MSG_CTRUNC, so the kernel installs both fds in the receiving process. The subsequent check `cmsg->cmsg_len == CMSG_LEN(sizeof(int))` (line 972, expected 20) fails, the branch that would read the fd is skipped, and neither installed fd is closed. The for(;;) loop calls recvmsg again (non-blocking → EAGAIN → Java maps to 0 → read loop exits normally), leaving two leaked fds per message. There is no MSG_CTRUNC handling. Reachable via Epoll/KQueue DomainSocketChannel when the application opts into DomainSocketReadMode.FILE_DESCRIPTORS (non-default). Versions 4.1.135.Final and 4.2.15.Final patch the issue.
From the CVE record · GitHub_M
Netty’s Epoll and KQueue domain socket transports can leak file descriptors when a peer sends multiple descriptors in one message. This is reachable through a local domain socket when the application enables the non-default DomainSocketReadMode.FILE_DESCRIPTORS setting; the affected receive path leaves the descriptors open.
Engineers using Maven io.netty:netty-transport-native-epoll or io.netty:netty-transport-native-kqueue before 4.1.135.Final, or from 4.2.0.Final through versions before 4.2.15.Final, should check their deployments.