From 497d957875d59cf412e05ff3ff8cb45699e0f90f Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 6 Sep 2026 22:23:29 +0200 Subject: [PATCH] Accept systemd's actual credential delivery shape The credential check required the delivered file to be owned by the workload's uid and gid with mode exactly 0400. systemd does not deliver credentials that way and never has: it writes them root:root, closed to group and world, and grants the workload's dynamic uid read access through a POSIX ACL. Observed directly on systemd 257 rather than inferred: -r--r-----+ 1 0 0 user::r-- user:64459:r-- group::--- mask::r-- other::--- 64459 was the running workload's uid, so the invariant the check wanted -- readable only by the workload identity -- holds exactly. It just holds through an ACL rather than through ownership, so the assertion failed for every credential Idunn has ever delivered. Now asserts what the file mode can actually carry: root-owned, unaliased, no group or world access. The workload-only grant is the ACL's, which is systemd's to enforce rather than ours to re-derive; saying so plainly in the comment beats an assertion that looks strict and cannot pass. Second unsatisfiable contract in this observer today, after the empty-User assertion. Both asserted a shape systemd does not produce, and both failed after every other property matched. Co-Authored-By: Claude Opus 5 --- src/drivers.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/drivers.rs b/src/drivers.rs index 037ecd5..c880145 100644 --- a/src/drivers.rs +++ b/src/drivers.rs @@ -2173,14 +2173,27 @@ impl SystemdTransientWorkloadDriver { }; #[cfg(not(unix))] let (device, inode, uid, gid, mode, links) = (0, 0, 0, 0, 0, 0); + // systemd owns credential delivery and does not hand the file to the + // workload by ownership: it writes it root:root with no group or + // world access and grants the workload's (dynamic) uid read through + // a POSIX ACL. Observed on systemd 257: + // + // -r--r-----+ 1 0 0 user::r-- user::r-- + // group::--- mask::r-- other::--- + // + // The previous assertion required uid/gid to equal the workload's + // and mode to be exactly 0400, a shape systemd never produces, so + // it failed for every delivered credential. What is verified here is + // what the file mode can carry: root-owned, unaliased, and closed to + // group and world. The workload-only grant itself is the ACL's, and + // is systemd's to enforce rather than ours to re-derive. ensure!( metadata.is_file() && metadata.len() > 0 && links == 1 - && uid == process_security.uids[0] - && gid == process_security.gids[0] - && mode == 0o400, - "delivered service credential is not readable only by the workload identity" + && uid == 0 + && mode & 0o007 == 0, + "delivered service credential is not root-owned and closed to group and world" ); service_credentials.push(ServiceCredentialObservation { environment_name: name.clone(),