Fix and harden the deploy pipeline after the app-user move#2
Merged
Conversation
- Deploy step runs a single root-owned finitum-deploy script on the
server via a deploy user restricted by sudoers to exactly that
command; no paths, users, or registry logins in the workflow.
- docker-compose.prod.yml consumes the immutable sha tag via
${IMAGE_TAG:-latest} instead of always deploying mutable latest.
- Document the security model in docs/deployment.md.
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.
What
The deploy job broke when the app moved from the SSH user's home to a dedicated
nologinapp user's directory. Instead of patching paths, this hardens the whole deploy boundary:sudo /usr/local/sbin/finitum-deploy "$IMAGE_TAG". No paths, usernames, or registry logins appear in the (public) workflow file. The broken GHCR login (nonexistentGHCR_PULL_TOKENsecret; package is public anyway) is gone.finitum-deployscript holds all environment detail -- it validates the image tag against a whitelist (blocks argument injection across the sudo boundary), doesgit pull --ff-onlyas the app user, runs compose as root (the app user's.envfiles are 0600 and it has no docker access), and prunes only this repo's images. CI authenticates as a new low-privilegedeployuser whose sudoers permits exactly that one script, with a forwarding-restricted SSH key. A leaked deploy key can deploy and nothing else.docker-compose.prod.ymlnow consumes${IMAGE_TAG:-latest}, so the queued-deploy concurrency actually ships the sha that triggered it; thelatestfallback keeps manualdocker composeruns on the box unchanged.HOST_USER/HOST_SSH_KEYnow point at the deploy user with a fresh ed25519 key; the unusedDEPLOY_PATHvariable was deleted. The server repo'soriginwas switched to HTTPS (anonymous read-only; no GitHub credentials on the box).docs/deployment.mddocuments the pipeline and security model.Verification
deploywith the new key: works;sudo whoamicorrectly denied; injection attempt ("latest; rm -rf /") correctly rejected by tag validation.sudo finitum-deploy latest --check(read-only: git fetch as app user + compose config): passes on the VPS.visudo -cfvalidates the sudoers entry; workflow YAML parses.🤖 Generated with Claude Code