Repository navigation
install: harden the systemd unit the installer writes - #237
Merged
Merged
Conversation
Add defense-in-depth sandboxing directives to install/consolebook.service (CapabilityBoundingSet=, ProtectClock, ProtectHostname, ProtectKernelLogs, ProtectProc=invisible, RestrictNamespaces, RestrictRealtime, MemoryDenyWriteExecute, RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX, SystemCallArchitectures=native, SystemCallFilter=@System-service / ~@PRIVILEGED @resources), keeping UMask=0027 aligned with ADR 0023's 0750 directories. Lowers systemd-analyze security exposure from 6.8 MEDIUM to 1.3 OK. Closes #125
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Primary Issue
Closes #125
Problem And Outcome
install/consolebook.servicescored 6.8 MEDIUM onsystemd-analyze security, leaving capabilities, kernel logs, clock/hostname, namespaces, realtime scheduling, W+X memory, exotic address families, and unrestricted syscalls open even though the service runs as an unprivileged static Rust binary serving HTTP over TCP and writing only to its configured SQLite data and backup-copy directories.Hardening
install/consolebook.servicebrings the exposure score down to 1.3 OK (well below the 4.0 target).Changes
install/consolebook.service[Service]directives matched to Consolebook's runtime needs (SQLite WAL, TCP HTTP listener, journal logging,paths.confdrop-in for data and backup-copy directories):CapabilityBoundingSet=ProtectClock=true,ProtectHostname=true,ProtectKernelLogs=trueProtectProc=invisibleRestrictNamespaces=true,RestrictRealtime=trueMemoryDenyWriteExecute=trueRestrictAddressFamilies=AF_INET AF_INET6 AF_UNIXSystemCallArchitectures=nativeSystemCallFilter=@system-serviceandSystemCallFilter=~@privileged @resourcesUMask=0027deliberately to match ADR 0023's0750consolebook:consolebookdirectories (nootherpermissions; group-readable only if an operator grants group access to a backup/restore reader).PrivateUsers=trueandProcSubset=pidso network backup shares and container/older systemd environments do not break while still reaching 1.3 OK.crates/consolebook-server/tests/install_command.rsthe_systemd_unit_carries_its_hardening_directivesasserting every required[Service]hardening directive ininstall/consolebook.service, with negative controls verifying that dropping, commenting out, or moving a directive outside[Service]fails the check.Verification
systemd-analyze security(systemd 260,--offline=yes)mainfb86d20): 6.8 MEDIUMd8ba19d): 1.3 OKRed-first check (before editing
install/consolebook.service)Running
cargo test -p consolebook-server --test install_commandfailed as expected, listing all 12 missing hardening directives. After editinginstall/consolebook.service,install_commandpassed 3/3 (including all per-directive negative controls).Local proof receipt — partial (steps 1–6 passed; step 7 hit 2 unrelated host-load timeouts)
d8ba19d5dc78a1bac50dd2e9de4fdb6b23046a66tree7180c3f075d811a8e84b8ae0f16084bdd1130733; unchanged during run: truepr-gateandreleasesystemd install runs are separate evidence)cargo xtask proofin/data/dev/src/consolebooke2e/drafts.spec.ts:11360s timeout as tracked in test(e2e): drafts.spec.ts daily-evaluation flow exceeds its 60s timeout under host load #199, ande2e/installation-export.spec.ts:745s sign-in visibility timeout under CPU starvation; this PR touches no Rust server or web code).scripts/check-guidance-names.sh2b172a8e66c87574(cd web && npm ci && npm run check && npm run build)3ae53a1d1bfcf5dacargo fmt --checke3b0c44298fc1c14cargo clippy --workspace --all-targets -- -D warnings1a3a0558ce717aadcargo test --workspace9260e04339310674cargo build -p consolebook-server7b89f9d8b45896e6(cd web && npx playwright install chromium && npm run e2e)b9775f89bf376db7Hosted CI (
fmt-clippy-test,build-x86_64,build-aarch64real systemd install/backup/copy/doctor jobs, andcheck / check) must pass before merge.Review And Merge Notes
tests/install_command.rs.