Repository navigation
feat(daemon): sandbox the updex-update.service unit - #329
Merged
Merged
Conversation
`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]>
Contributor
There was a problem hiding this comment.
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.Sandboxandsystemd.SandboxDirectives, and haveGenerateServiceappend the directives when sandboxing is enabled. - Opt
updex daemon enableinto sandboxing for the rootupdex-update.serviceunit. - 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.
This was referenced Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
updex daemon enableinstalls a root oneshot service whose[Service]section carried onlyType=oneshotandExecStart=(systemd-analyze security --offline: 9.4 UNSAFE).ServiceConfig.Sandbox+ exportedsystemd.SandboxDirectives:GenerateServiceappends 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/varwritable so the default staging/link directories and hand-written transfers with aTarget.Pathunder/varkeep working without aReadWritePathslist. NoCapabilityBoundingSet. Unit name, timer, ExecStart, oneshot type and refuse-to-overwrite behaviour from ADR-0007 unchanged; ADR-0007 untouched.TestGenerateServiceDaemonSandbox/TestGenerateServiceWithoutSandbox;TestRunDaemonEnable_Successreads the written unit. Docs: overview auto-update daemon section,sdk-api.md.systemd-analyze verifyclean. PR refactor: move daemon lifecycle behind SDK #288 is still open, so the change lives incmd/updex/daemon.goas the work item directs.Fluent work item
1c4cebf6-6236-40d3-b4c3-e7af385f8b50(security program).Verification
make checkgreen (golangci-lint 0 issues),go vet ./...silent,gofmt -lempty.🤖 Generated with Claude Code