Products › lamco-dbus-tools › Docs
D-Bus policy evaluation on dbus-daemon and dbus-broker
D-Bus policy evaluation: How lamco-dbus-tools reads bus policy files as dbus-daemon and dbus-broker do, decides each message, and holds it to both real daemons.
Describes version 0.4.1. The source of truth is src/policy/: grammar.rs reads the files,
eval.rs decides, probe.rs holds both to the real daemons. Written from dbus-daemon 1.16's
bus/config-parser.c and bus/policy.c and dbus-broker 37's src/launch/ and src/bus/policy.c, as the
project's research read them, and checked against both daemons by the oracle cases.
Reading
A configuration is read from its root file (/usr/share/dbus-1/system.conf, or /etc/dbus-1/ when that's
missing), following <include> and <includedir> in document order. Each implementation gets its own
reading:
| dbus-daemon | dbus-broker | |
|---|---|---|
<includedir> order |
As the directory lists it, which its manual calls undefined | Sorted |
| A member with no interface or path | Refuses to start | Takes the rule |
send_destination_prefix |
Used | Not known: Dropped from the rule, which then applies without it; a rule with only it is dropped |
send_error, receive_error, log |
Used | Dropped from the rule |
Rules on method_return or error |
Used | Dropped |
A deny with eavesdrop="true" |
Applies to eavesdroppers | Dropped |
<policy user=> or group= naming no account |
Dropped whole, its rules with it | The same |
Each rule keeps its file and line, and the reading keeps a note for each rule dropped or changed.
Deciding
The rules that apply to a peer are consulted in this order: The default context, its groups, its user, the console context, the mandatory context. The last rule that matches decides; when none does, the answer is deny. dbus-daemon takes groups in the order of the user's group list, dbus-broker in the order they're written.
| Rule part | Matches |
|---|---|
send_destination="X" |
A recipient that owns X, primary or queued, whatever name the call was addressed by; to the bus or for activation, a destination header of X |
send_destination_prefix="X" |
A recipient owning X or a name below it, by dot-separated words |
send_interface="X" |
A message whose interface is X. With no interface: On dbus-daemon a deny applies and an allow doesn't; on dbus-broker neither |
send_member, send_path, send_error |
Equal when the message has the field; a message without it matches |
send_type, send_broadcast, min_fds, max_fds |
As written |
own="X" |
X; on dbus-broker also the names below it |
own_prefix="X" |
X and the names below it |
own="*", send_destination="*" and the like |
Everything |
An at_console block depends on whether a user has a seat, which isn't in the files. A verdict that
could depend on one says so instead of guessing.
The oracle
dbusdo policy probe gives a file to each daemon on a private bus, after a base of rules (open: Every
send and receive allowed; system: The stock system bus's), with stand-ins owning the call probes'
destinations, and holds each answer to the evaluator. The cases are in tests/oracle/; each daemon
version's answers are kept in tests/fixtures/oracle/<version>/, and the library's tests hold the
evaluator to them with no daemon running. docs/measurements/stage-8/README.md has the cases and the
answers.
Rules using send_requested_reply, eavesdrop, min_fds, max_fds or send_broadcast have no oracle
case yet. A probe names them, so a verdict that rests on one is known to be the evaluator's reading only.
SARIF
dbustell audit --sarif writes SARIF 2.1.0: One result for each finding, level error for a problem
and note for a notice, the file and line where the finding has them, a partialFingerprints entry
lamcoDbusTools/v1 built from what the finding is about and never from a line number, and with
--baseline a baselineState of new, unchanged or absent. The rules are the POL- and AUD-
entries of the findings catalog.