Skip to content

security: default to non-privileged chainlink user in Dockerfile#21348

Closed
R-Panic wants to merge 1 commit intosmartcontractkit:developfrom
R-Panic:feature/issue-21005
Closed

security: default to non-privileged chainlink user in Dockerfile#21348
R-Panic wants to merge 1 commit intosmartcontractkit:developfrom
R-Panic:feature/issue-21005

Conversation

@R-Panic
Copy link

@R-Panic R-Panic commented Mar 1, 2026

Fixes #21005

Summary

Improved Docker security by defaulting to a non-privileged chainlink user instead of root. This follows the principle of least privilege and represents secure-by-default configuration for container deployments.

Changes

Updated both official Chainlink Dockerfiles:

  1. core/chainlink.Dockerfile - main production Dockerfile
  2. plugins/chainlink.Dockerfile - experimental/testing Dockerfile

Changed default CHAINLINK_USER argument from:

ARG CHAINLINK_USER=root

To:

ARG CHAINLINK_USER=chainlink

Impact

  • Security: Containers now run as non-root by default
  • Compatibility: Users who need root can still override with --build-arg CHAINLINK_USER=root
  • Minimal: No other changes needed - existing logic already handles user creation when CHAINLINK_USER != root

Testing

The existing Dockerfile logic handles this change correctly:

RUN if [ ${CHAINLINK_USER} != root ]; then useradd --uid 14933 --create-home ${CHAINLINK_USER}; fi

When CHAINLINK_USER=chainlink, the container will:

  1. Create a new chainlink user with UID 14933
  2. Switch to that user via USER ${CHAINLINK_USER}
  3. Set appropriate working directory and environment variables

Security Rationale

Running containers as root by default violates security best practices:

  • Privilege escalation: Root processes can exploit container escape vulnerabilities
  • Host filesystem access: Root can potentially access host resources
  • Kernel vulnerabilities: Root can exploit kernel bugs more easily
  • Industry standard: Most production containers run as non-root users

- Changed default CHAINLINK_USER from 'root' to 'chainlink' in core/chainlink.Dockerfile
- Changed default CHAINLINK_USER from 'root' to 'chainlink' in plugins/chainlink.Dockerfile
- Users who need root can still override the ARG
- Follows security best practice of principle of least privilege
- Secure by default for container deployments

Fixes smartcontractkit#21005
@Moses-main
Copy link

Hi team,

I'll update the Dockerfile to use a non-privileged chainlink user for better security. This follows security best practices.

Please assign!

@erikburt
Copy link
Collaborator

erikburt commented Mar 2, 2026

The official images that we publish run as non-root, as we pass an appropriate parameter for the CHAINLINK_USER arg to the docker build context.

For example:

docker-build-args: |
CHAINLINK_USER=chainlink

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Use non-privileged 'chainlink' user by default in Dockerfile

3 participants