]> git.ipfire.org Git - thirdparty/openvpn.git/commit
tcp: apply CLOEXEC to accepted socket, not listener
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Tue, 21 Oct 2025 17:20:52 +0000 (01:20 +0800)
committerGert Doering <gert@greenie.muc.de>
Tue, 28 Oct 2025 16:50:59 +0000 (17:50 +0100)
commitc0d96fd8732bd903ab390bb5047a13880cdcac9b
tree61e44725dda3bda2a68d07b577f1db969cdf1e6c
parentb9b5470521294209146c7253a97012d399978d72
tcp: apply CLOEXEC to accepted socket, not listener

The accept path calls set_cloexec(sd) after accept(). That re-flags the
listening socket, which is already CLOEXEC from create_socket_tcp(), and
leaves new_sd inheritable. As a result, client-connect and auth scripts
spawned after accept can inherit the connected socket and read or write
the raw TCP stream. This defeats the stated intent to prevent scripts from
accessing the client socket.

This bug was found using ZeroPath.

Signed-off-by: Joshua Rogers <MegaManSec@users.noreply.github.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <-MNw5Hu8h0rHV18x36ISt7V0UHchIO4i-JoAeV_wlxS1AmDIAe7YVYNput3_r2hiu3HhwxkhGyUhv4-iH_E7mf7nGjvocmGXlDq7Tjly5cE=@joshua.hu>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg33823.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/socket.c