Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider warning about trusting Address::system #1275

Open
complexspaces opened this issue Mar 1, 2025 · 1 comment
Open

Consider warning about trusting Address::system #1275

complexspaces opened this issue Mar 1, 2025 · 1 comment

Comments

@complexspaces
Copy link

complexspaces commented Mar 1, 2025

Good afternoon,

Today zbus::Address has a convenient system() function on it which attempts to resolve where the socket for system-level services on the current platform/host are. However, this is primarily reliant on reading an environment variable:

pub fn system() -> Result<Self> {
match env::var("DBUS_SYSTEM_BUS_ADDRESS") {

As you probably know, environment variables can be manipulated in a lot of ways by software running even with same user privileges and attempting to start other apps in weird ways. For example this resulted in CVE-2012-3524 for libdbus back in 2012. This case was primarily about attacking setuid programs but the general concern of handling untrusted data in sensitive contexts remains.

I would primarily recommend adding an obvious warning to the documentation of the aforementioned function, but also all of the other public methods that return something from the "system" to note that zbus doesn't do any kind of security checks on the returned connection, and that individual users are responsible for validating if it is actually owned by the "system" or not. As a secondary recommendation, you could also detect specifically running in a "privileged" binary at runtime and use a well-known hardcoded path instead of an untrusted environment read.

@zeenix
Copy link
Contributor

zeenix commented Mar 2, 2025

For example this resulted in CVE-2012-3524 for libdbus back in 2012.

But the CVE summary says:

libdbus maintainers state that this is a vulnerability in the applications that do not cleanse environment variables, not in libdbus itself: "we do not support use of libdbus in setuid binaries that do not sanitize their environment before their first call into libdbus."

However, I don't have any objections to what you're proposing. It should be noted that this is not a security issue in zbus and any changes resulting from this issue will purely to save users from making dangerous mistakes.

As a secondary recommendation, you could also detect specifically running in a "privileged" binary at runtime and use a well-known hardcoded path instead of an untrusted environment read.

Sure but I think this should be part of the spec then. If this makes sense, it makes sense for all D-Bus libraries out there. If we just do this on our own, we'll actually be going against the spec, which says that:

The address of the system message bus is given in the DBUS_SYSTEM_BUS_ADDRESS environment variable. If that variable is not set, applications should try to connect to the well-known address unix:path=/var/run/dbus/system_bus_socket

My interpretation here is that if the env is set, applications should use it. So that would be another reason I'd like this to be part of the spec before we implement it in zbus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants