Skip to content

Commit 2aa8550

Browse files
MegaManSeccron2
authored andcommitted
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> (cherry picked from commit c0d96fd)
1 parent 12a2e88 commit 2aa8550

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/openvpn/socket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,7 @@ socket_do_accept(socket_descriptor_t sd,
12701270
{
12711271
/* set socket file descriptor to not pass across execs, so that
12721272
* scripts don't have access to it */
1273-
set_cloexec(sd);
1273+
set_cloexec(new_sd);
12741274
}
12751275
return new_sd;
12761276
}

0 commit comments

Comments
 (0)