Skip to content

Commit 3ccb54c

Browse files
committed
📝 zb: Add security documentation and warnings to system methods
Closes dbus2#1275 by adding basic and sufficient, but attention-grabbing, documentation to all `system*` methods in the crate which either are or utilize the result of zbus::Address::system to describe their security properties. I took the approach to centralize the details/important parts on zbus::Address::system and then use interdoc links to redirect all of the other "affected" callsites there to reduce duplication.
1 parent e5f811b commit 3ccb54c

File tree

5 files changed

+43
-0
lines changed

5 files changed

+43
-0
lines changed

zbus/src/address/mod.rs

+11
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ impl Address {
8787
/// Get the address for the system bus respecting the `DBUS_SYSTEM_BUS_ADDRESS` environment
8888
/// variable. If we don't recognize the value (or it's not set) we fall back to
8989
/// `/var/run/dbus/system_bus_socket`.
90+
///
91+
/// # Security
92+
///
93+
/// <div class="warning">
94+
///
95+
/// `zbus` does not perform any security checks or trust validation on the address (path)
96+
/// returned by this method.
97+
///
98+
/// Users in security-sensitive contexts (ex: authentication) are responsible for validating
99+
/// if the address is truly controlled by the system and trustworthy for the intended purpose.
100+
/// </div>
90101
pub fn system() -> Result<Self> {
91102
match env::var("DBUS_SYSTEM_BUS_ADDRESS") {
92103
Ok(val) => Self::from_str(&val),

zbus/src/blocking/connection/builder.rs

+8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ impl<'a> Builder<'a> {
3030
}
3131

3232
/// Create a builder for the system-wide message bus connection.
33+
///
34+
/// # Security
35+
///
36+
/// <div class="warning">
37+
///
38+
/// `zbus` does not validate the address used by this builder's connection.
39+
/// See [zbus::Address::system] for more details.
40+
/// </div>
3341
pub fn system() -> Result<Self> {
3442
crate::connection::Builder::system().map(Self)
3543
}

zbus/src/blocking/connection/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ impl Connection {
3333
}
3434

3535
/// Create a `Connection` to the system-wide message bus.
36+
///
37+
/// # Security
38+
///
39+
/// <div class="warning">
40+
///
41+
/// `zbus` does not validate the address used by this connection.
42+
/// See [zbus::Address::system] for more details.
43+
/// </div>
3644
pub fn system() -> Result<Self> {
3745
block_on(crate::Connection::system()).map(Self::from)
3846
}

zbus/src/connection/builder.rs

+8
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ impl<'a> Builder<'a> {
7878
}
7979

8080
/// Create a builder for the system-wide message bus connection.
81+
///
82+
/// # Security
83+
///
84+
/// <div class="warning">
85+
///
86+
/// `zbus` does not validate the address used by this builder's connection.
87+
/// See [zbus::Address::system] for more details.
88+
/// </div>
8189
pub fn system() -> Result<Self> {
8290
Ok(Self::new(Target::Address(Address::system()?)))
8391
}

zbus/src/connection/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,14 @@ impl Connection {
11931193
}
11941194

11951195
/// Create a `Connection` to the system-wide message bus.
1196+
///
1197+
/// # Security
1198+
///
1199+
/// <div class="warning">
1200+
///
1201+
/// `zbus` does not validate the address used by this connection.
1202+
/// See [zbus::Address::system] for more details.
1203+
/// </div>
11961204
pub async fn system() -> Result<Self> {
11971205
Builder::system()?.build().await
11981206
}

0 commit comments

Comments
 (0)