Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 817812 - sys-apps/dbus - /usr/share/dbus-1/session.conf: <listen>unix:tmpdir=/tmp</listen> is insecure.
Summary: sys-apps/dbus - /usr/share/dbus-1/session.conf: <listen>unix:tmpdir=/tmp</lis...
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Freedesktop bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-12 03:02 UTC by anonymous
Modified: 2021-10-15 02:19 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description anonymous 2021-10-12 03:02:19 UTC
<listen>unix:tmpdir=/tmp</listen> should be changed to

<listen>unix:dir=/tmp</listen> because

<listen>unix:tmpdir=/tmp</listen> creates an abstract unix socket, the access to which cannot be restricted by file system permissions or linux mount namespace.

The only way I know to restrict access to abstract unix socket is to execute applications in a new linux network namespace.

I think linux distributions that use systemd already changed

<listen>unix:tmpdir=/tmp</listen> to <listen>unix:dir=/tmp</listen>
Comment 2 Mike Gilbert gentoo-dev 2021-10-12 14:40:33 UTC
On systemd, the session bus listens on /run/user/$UID/bus.

This possibly security issue would mainly affect users running OpenRC, with multiple users logged in simultaneously.

It might also affect applications that start ad-hoc private session busses.

The downside to reverting back to path-based sockets is that /tmp becomes cluttered with stale directories as users log in/out.
Comment 3 Mike Gilbert gentoo-dev 2021-10-12 14:44:22 UTC
I don't see a strong reason to deviate from the upstream default setting. Users can override the behavior via the config file if they desire.

If you can convince upstream to change the default, we will pick up that change in a version bump.
Comment 4 anonymous 2021-10-15 00:41:59 UTC
Cluterring /tmp is better than reducing security and privacy with abstract unix sockets.

Abstract unix domain sockets don't have filesystem permissions which are the first line of defense.

I also use firejail to sandbox applications. A path-based unix domain socket can be easily whitelisted in a firejail sandbox.

I don't want to directly edit /usr/share/dbus-1/session.conf because it will be overwritten whenever I install dbus or upgrade dbus.

Specifying <listen>unix:dir=/tmp</listen> in /etc/dbus-1/session.d/listen.conf doesn't eliminate abstract unix domain socket but just adds a path-based unix domain socket.

It really doesn't take much to replace <listen>unix:dir=/tmp</listen> with <listen>unix:dir=/tmp</listen> in /usr/share/dbus-1/session.conf, and this simple trick immediately increases privacy and security.
Comment 5 anonymous 2021-10-15 00:42:55 UTC
Typo

replace <listen>unix:dir=/tmp</listen> with <listen>unix:dir=/tmp</listen>

--->

replace <listen>unix:tmpdir=/tmp</listen> with <listen>unix:dir=/tmp</listen>
Comment 6 anonymous 2021-10-15 00:53:51 UTC
You can change the default session bus listen address by passing something like

--with-dbus-session-bus-listen-address=unix:dir=/tmp

to autogen.sh or configure. Cmake build also can configure default session bus listen address.
Comment 7 Mike Gilbert gentoo-dev 2021-10-15 01:07:29 UTC
You should really argue with upstream about this.
Comment 8 Mike Gilbert gentoo-dev 2021-10-15 02:04:03 UTC
It looks dbus-daemon sets the mode on path-based unix sockets to 0777.

https://gitlab.freedesktop.org/dbus/dbus/-/blob/dbus-1.12.20/dbus/dbus-sysdeps-unix.c#L1249

Given that the socket is created in /tmp with mode 0777, any user could connect to the socket anyway.
Comment 9 Mike Gilbert gentoo-dev 2021-10-15 02:19:30 UTC
If you want to change this locally, you could set EXTRA_ECONF="--with-dbus-session-bus-listen-address=unix:dir=/tmp" via portage's package.env feature.