Repository navigation
Security: stop the container cleanly and harden its runtime - #369
Merged
Merged
Conversation
- Keep the entrypoint waiting while supervisord shuts down; set -e exited on the interrupted wait. - Add the KILL capability to the Compose file so supervisord can signal the API. - Copy the API source into the image owned by root. - Write the fatal marker and supervisord pid file under /run instead of /tmp. - Send a locked-down Content-Security-Policy on every /api/ response. - Apply the Compose hardening to the Unraid template.
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
docker-entrypoint.sh: wait with|| status=$?and loop while supervisord is alive. Underset -euthe wait interrupted by the TERM trap returned 143 and exited PID 1, so the kernel killed supervisord, nginx and the API mid-shutdown (02-1).docker-compose.yml: add theKILLcapability. Root supervisord cannot signal the API, which runs asnode, without it; a stop loggedunknown problem killing api ... Operation not permittedand the API died by SIGKILL.Dockerfile: copyapi/and the sharedui/jsmodules without--chown=node:node, so the API cannot rewrite its own code (02-5).exit-on-fatal.py,docker-entrypoint.sh,supervisord.conf: the fatal marker and supervisord's pid file move from/tmpto root-owned/run(02-6).nginx/csp-api.conf:default-src 'none'; frame-ancestors 'none'; sandbox, included by the three/api/locations, which did not inherit the server policy (02-7).templates/stackyard.xml:ExtraParamswith the Compose capabilities,no-new-privileges,--init, PID, memory and CPU limits (02-9), and the ComposeNODE_OPTIONSheap cap so the memory limit does not kill the API.Testing
All green, including the homelab Docker build and a throwaway container (clean stop exits 0, fatal path exits 1,
/api/CSP, root-owned/app). Added 5 entrypoint shutdown tests that run the real script (4 fail without the fix, under sh and dash) and tests for the/runpaths, source ownership, the API policy, the template flags and theKILLcapability.Changelog
Fixed
docker stopinstead of killing the dashboard mid-shutdown.Security
Checklist