Skip to content

Conversation

@nikiwycherley
Copy link

@nikiwycherley nikiwycherley commented Jan 30, 2026

Description

Updates Docker guidance to address SonarCloud security vulnerability related to file permissions in COPY commands.

Problem

SonarCloud flags COPY --chown=node:node commands with the error: "Make sure no write permissions are assigned to the copied resource." This occurs because giving the running user ownership of files grants write permissions, creating an unnecessary security risk - see https://rules.sonarsource.com/docker/type/Security%20Hotspot/RSPEC-6504/

Solution

Changed all COPY commands from --chown=node:node to --chown=root:root in Dockerfile examples. This ensures:

  • Files are owned by root:root
  • Container runs as non-root user (node)
  • Running user has no write permissions to application files
  • Satisfies security scanning requirements without additional chmod commands

Changes Made

  • Added new "Security best practices" section explaining file ownership in COPY commands
  • Updated multi-stage build example to use --chown=root:root in both development and production stages
  • Documented why this approach is more secure than alternatives

Files Changed

  • docs/guides/docker_guidance.md

Security Impact

This change improves security posture by ensuring containerized applications follow the principle of least privilege - the running user cannot modify its own application files.

@nikiwycherley nikiwycherley self-assigned this Jan 30, 2026
@pmshaw15 pmshaw15 changed the base branch from master to main February 2, 2026 09:03
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.

3 participants