Skip to content

feat(daemon): sandbox the updex-update.service unit - #329

Merged
bketelsen merged 1 commit into
mainfrom
daemon/systemd-sandbox
Aug 18, 2026
Merged

bketelsen merged 1 commit into
mainfrom
daemon/systemd-sandbox

Conversation

@bketelsen

Copy link
Copy Markdown
Contributor

Summary

updex daemon enable installs a root oneshot service whose [Service] section carried only Type=oneshot and ExecStart= (systemd-analyze security --offline: 9.4 UNSAFE).

  • ServiceConfig.Sandbox + exported systemd.SandboxDirectives: GenerateService appends the fixed block (NoNewPrivileges, ProtectSystem=full, ProtectHome, PrivateTmp, ProtectKernel*, ProtectControlGroups, ProtectClock, ProtectHostname, RestrictRealtime, RestrictSUIDSGID, RestrictNamespaces, LockPersonality, MemoryDenyWriteExecute, SystemCallArchitectures=native, RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6, SystemCallFilter=@System-service) only when set; the daemon command opts in, other callers keep the minimal unit.
  • ProtectSystem=full (not strict) keeps /var writable so the default staging/link directories and hand-written transfers with a Target.Path under /var keep working without a ReadWritePaths list. No CapabilityBoundingSet. Unit name, timer, ExecStart, oneshot type and refuse-to-overwrite behaviour from ADR-0007 unchanged; ADR-0007 untouched.
  • Tests: TestGenerateServiceDaemonSandbox / TestGenerateServiceWithoutSandbox; TestRunDaemonEnable_Success reads the written unit. Docs: overview auto-update daemon section, sdk-api.md.
  • Rendered unit now scores 4.4 OK; systemd-analyze verify clean. PR refactor: move daemon lifecycle behind SDK #288 is still open, so the change lives in cmd/updex/daemon.go as the work item directs.

Fluent work item 1c4cebf6-6236-40d3-b4c3-e7af385f8b50 (security program).

Verification

make check green (golangci-lint 0 issues), go vet ./... silent, gofmt -l empty.

🤖 Generated with Claude Code

`updex daemon enable` installs a root oneshot service. Add
ServiceConfig.Sandbox, which makes GenerateService append the fixed
systemd.SandboxDirectives block (NoNewPrivileges, ProtectSystem=full,
ProtectHome, PrivateTmp, ProtectKernel*, ProtectControlGroups,
ProtectClock, ProtectHostname, RestrictRealtime, RestrictSUIDSGID,
RestrictNamespaces, LockPersonality, MemoryDenyWriteExecute,
SystemCallArchitectures=native, RestrictAddressFamilies=AF_UNIX AF_INET
AF_INET6, SystemCallFilter=@System-service) to [Service]; the daemon
command opts in, other GenerateService callers keep the minimal unit.

ProtectSystem=full (not strict) keeps /var writable so the default
/var/lib/extensions.d staging directory, the /var/lib/extensions link
directory, and hand-written transfers with a Target.Path elsewhere under
/var keep working without a ReadWritePaths list. No CapabilityBoundingSet.
Unit name, timer, ExecStart, oneshot type and refuse-to-overwrite
behaviour from ADR-0007 are unchanged.

Tests: TestGenerateServiceDaemonSandbox / TestGenerateServiceWithoutSandbox
in systemd/unit_test.go; TestRunDaemonEnable_Success now reads the written
service unit. Docs: design/overview.md auto-update daemon section and
specs/sdk-api.md.

Co-Authored-By: Claude Fable 5 <[email protected]>
@github-actions
github-actions Bot requested a lite review from Copilot August 18, 2026 14:44
@github-actions github-actions Bot added documentation Improvements or additions to documentation go Pull requests that update go code labels Aug 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the systemd auto-update oneshot service installed by updex daemon enable by optionally appending a curated sandboxing/hardening directive block to the generated [Service] section, improving the unit’s security posture while keeping behavior unchanged for other systemd.GenerateService callers unless they explicitly opt in.

Changes:

  • Add ServiceConfig.Sandbox and systemd.SandboxDirectives, and have GenerateService append the directives when sandboxing is enabled.
  • Opt updex daemon enable into sandboxing for the root updex-update.service unit.
  • Add/extend tests and update SDK/design documentation to reflect the new sandboxing option.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
systemd/unit.go Adds sandbox toggle + directive list; conditionally appends hardening directives during service unit generation.
systemd/unit_test.go Adds tests covering sandboxed vs minimal service generation behavior.
docs/specs/sdk-api.md Documents the new ServiceConfig.Sandbox behavior and SandboxDirectives.
docs/design/overview.md Updates daemon design notes to describe the sandboxing/hardening block and rationale.
cmd/updex/daemon.go Enables sandboxing when generating the daemon’s root oneshot service unit.
cmd/updex/daemon_test.go Verifies the written service unit includes key hardening directives when enabling the daemon.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread systemd/unit_test.go Resolved
@bketelsen
bketelsen merged commit 721b11c into main Aug 18, 2026
17 checks passed
@bketelsen
bketelsen deleted the daemon/systemd-sandbox branch August 18, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants