jetty/jetty.project

jetty-unixsocket: No ability to set permissions on unix domain socket - other services cannot connect

Open

#10860 opened on Nov 6, 2023

View on GitHub
 (16 comments) (0 reactions) (0 assignees)Java (3,701 stars) (1,913 forks)batch import
BugHelp Wanted

Description

Jetty version(s)

Jetty 10+

Jetty Environment

Java version/vendor (use: java -version)

openjdk version "17.0.9" 2023-10-17 LTS OpenJDK Runtime Environment (Red_Hat-17.0.9.0.9-1) (build 17.0.9+9-LTS) OpenJDK 64-Bit Server VM (Red_Hat-17.0.9.0.9-1) (build 17.0.9+9-LTS, mixed mode, sharing)

OS type/version

RHEL9

Description

When a unix domain socket is created, the socket is created given the umask of the server. This in almost all cases creates a socket that can only be connected to by the same user that runs jetty.

[root@seawitch ~]# ls -al /tmp/jenkins.socket 
srwxr-xr-x. 1 jenkins jenkins 0 Nov  6 22:08 /tmp/jenkins.socket

This breaks the privilege separation between components.

The workaround is to change the umask to 0002 or 0007, but this has the side effect that it gives full application write access to the entity connecting to the socket.

The permissions on the socket need to be configurable. No need to overthink the difference between unix and windows, if "allow anyone to connect" is allowed, the admin is given the option to put the sock in a directory protected as they need it.

How to reproduce?

Create a jenkins instance with unix domain socket support. See the permissions on the socket.

Contributor guide