Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Develop into Release #3035

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions dockerfile/security/no-sudo-in-dockerfile.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Use an official Ubuntu 20.04 as base image
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND noninteractive

# ok: no-sudo-in-dockerfile
RUN apt-get update && apt-get upgrade -y

# ok: no-sudo-in-dockerfile
RUN apt-get install -y sudo

RUN useradd -ms /bin/bash newuser

RUN echo "newuser ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers

USER newuser

# ruleid: no-sudo-in-dockerfile
RUN sudo apt-get install -y curl

CMD ["echo", "Hello, Docker!"]
27 changes: 27 additions & 0 deletions dockerfile/security/no-sudo-in-dockerfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
rules:
- id: no-sudo-in-dockerfile
patterns:
- pattern: |
RUN sudo ...
message: >-
Avoid using sudo in Dockerfiles. Running processes as a non-root user can help
reduce the potential impact of configuration errors and security vulnerabilities.
metadata:
category: security
technology:
- dockerfile
cwe:
- 'CWE-250: Execution with Unnecessary Privileges'
owasp:
- A05:2021 - Security Misconfiguration
references:
- https://cwe.mitre.org/data/definitions/250.html
- https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
subcategory:
- audit
likelihood: LOW
impact: LOW
confidence: HIGH
languages:
- dockerfile
severity: WARNING
Loading