fix: add non-root USER to Dockerfile#84
Merged
colindean merged 1 commit intoJun 29, 2026
Merged
Conversation
Closes target#68 Run the container as a dedicated system user (diffpoetrylock) instead of root. This reduces the blast radius of any runtime compromise by removing root-level privileges from the container process. Changes: - RUN useradd --system --shell /usr/sbin/nologin diffpoetrylock Creates a passwordless system account with no interactive login shell. - RUN chmod 0755 entrypoint.sh && chown -R diffpoetrylock:diffpoetrylock /src Ensures /src and entrypoint.sh are owned and executable by the new user. - USER diffpoetrylock Switches runtime execution to the non-root account. Validated locally by building the image and confirming: docker run --entrypoint id => uid=999(diffpoetrylock) gid=999(diffpoetrylock) docker run --entrypoint /bin/sh -c 'whoami && ls -l /src/entrypoint.sh' => diffpoetrylock / -rwxr-xr-x 1 diffpoetrylock diffpoetrylock Signed-off-by: Sydney Lyon <sydney.lyon@target.com>
colindean
approved these changes
Jun 29, 2026
colindean
left a comment
Collaborator
There was a problem hiding this comment.
LGTM!
@sydneylyon1 Thank for this contribution! You're awesome for taking the time to improve this.
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.
Closes #68
What changed
Run the container as a dedicated system user (
diffpoetrylock) instead of root. This reduces the blast radius of any runtime compromise by removing root-level privileges from the container process.RUN useradd --system --shell /usr/sbin/nologin diffpoetrylock/usr/sbin/nologinprevents interactive access even if the account is somehow targeted).chown -R diffpoetrylock:diffpoetrylock /src— ensures runtime files are owned by the new user so the process can read/execute them.USER diffpoetrylock— switches execution to the non-root account for the container's lifetime.No home directory is created — the runtime path uses
/tmpfor temporary files and/srcfor app files, so noHOME-based paths are needed.Validation
Built the image locally and confirmed non-root runtime: