Skip to content

Commit 7bbb95d

Browse files
feat(backend-ssh): run remote units with NoNewPrivileges
A remote agent runs arbitrary code by design, so the SSH user's own privileges are the intended ceiling. Without NoNewPrivileges the harness can climb past them through any setuid/setgid binary on the host, or through passwordless sudo granted to that user. A VPS pilot exercised the harness, the Buzz CLI, NIP-OA owner-reviewed draft creation and repository branch pushes with it set; all remained functional. Deliberately the whole hardening delta. ProtectSystem/ProtectHome belong in this unit too, but an agent has no modeled workspace yet, so until writable paths are something the protocol states those directives would be guessing at which of the user's home an agent legitimately needs. Signed-off-by: Troy Hoffman <[email protected]>
1 parent 9bc0f62 commit 7bbb95d

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎crates/buzz-backend-ssh/assets/[email protected]‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ StartLimitIntervalSec=0
99

1010
[Service]
1111
Type=simple
12+
# The agent runs arbitrary code by design, so the SSH user's own privileges are
13+
# the intended ceiling — but without this the harness can climb past them
14+
# through any setuid/setgid binary on the host, or through passwordless sudo
15+
# granted to that user. A VPS pilot exercised the harness, the Buzz CLI,
16+
# NIP-OA owner-reviewed draft creation and repository branch pushes with this
17+
# set; all remained functional.
18+
#
19+
# Deliberately the whole hardening delta. ProtectSystem/ProtectHome would also
20+
# apply here, but the agent has no modeled workspace yet (see the REPOS /
21+
# working-directory limitation in docs/remote-agents.md) — so until writable
22+
# paths are something the protocol states, those directives would be guessing
23+
# at which of the user's home an agent legitimately needs.
24+
NoNewPrivileges=true
1225
# Holds the agent's minted nsec. Written by the provider with umask 077 and
1326
# chmod 600; systemd reads it as the owning user.
1427
EnvironmentFile=%h/.config/buzz-acp/%i.env

‎crates/buzz-backend-ssh/src/deploy.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,12 @@ mod tests {
11511151
let script = deploy_script(&agent, &config(), UNIT_TEMPLATE, &Pushes::default()).unwrap();
11521152
assert!(UNIT_TEMPLATE.contains("ExecStart=@BUZZ_ACP_BIN@"));
11531153
assert!(UNIT_TEMPLATE.contains("EnvironmentFile=%h/.config/buzz-acp/%i.env"));
1154+
// The SSH user's own privileges are the intended ceiling for an agent
1155+
// that runs arbitrary code. Without this it can climb past them through
1156+
// a setuid binary or passwordless sudo granted to that user, and the
1157+
// unit — not the deploy script — is the only place that can say so.
1158+
assert!(UNIT_TEMPLATE.contains("\nNoNewPrivileges=true\n"));
1159+
assert!(script.contains("NoNewPrivileges=true"));
11541160
// Substitution is parameter expansion, not `sed -i`: in-place editing
11551161
// is a GNU extension that BSD and macOS hosts reject.
11561162
assert!(!script.contains("sed -i"));

‎docs/remote-agents.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ StartLimitIntervalSec=0
395395

396396
[Service]
397397
Type=simple
398+
NoNewPrivileges=true
398399
EnvironmentFile=%h/.config/buzz-acp/%i.env
399400
ExecStart=@BUZZ_ACP_BIN@
400401
Restart=always
@@ -407,6 +408,12 @@ WantedBy=default.target
407408
- `StartLimitIntervalSec=0` — a long-running agent must never be rate-limited into staying down. A
408409
unit held by the start limiter looks exactly like an agent that silently died, and only
409410
`systemctl reset-failed` clears it.
411+
- `NoNewPrivileges=true` — the agent runs arbitrary code by design, so the SSH user's own privileges
412+
are the intended ceiling. Without this the harness can climb past them through any setuid/setgid
413+
binary on the host, or through passwordless `sudo` granted to that user. It is deliberately the
414+
whole hardening delta: `ProtectSystem`/`ProtectHome` belong here too, but an agent has no modeled
415+
workspace yet (see Known limitations), so until writable paths are something the protocol states
416+
those directives would be guessing at which of the user's home an agent legitimately needs.
410417
- `EnvironmentFile` — holds the minted nsec; systemd reads it as the owning user.
411418
- `ExecStart` is an absolute path, substituted at install time from the host's resolved `buzz-acp`.
412419
systemd does not expand environment variables in the program position, and the shell indirection

0 commit comments

Comments
 (0)