Last User Is 'root'

  • Query id: 67fd0c4a-68cf-46d7-8c41-bc9fba7e40ae
  • Query name: Last User Is 'root'
  • Platform: Dockerfile
  • Severity: Medium
  • Category: Best Practices
  • URL: Github

Description

Leaving the last user as root can cause security risks. Change to another user after running the commands the need privileges
Documentation

Code samples

Code samples with security vulnerabilities

Positive test num. 1 - dockerfile file
FROM alpine:2.6
USER root
RUN npm install

Code samples without security vulnerabilities

Negative test num. 1 - dockerfile file
FROM alpine:2.6
USER root
RUN npm install
USER guest