-
Notifications
You must be signed in to change notification settings - Fork 1k
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
NO-JIRA fix Dockerfile security #736
NO-JIRA fix Dockerfile security #736
Conversation
@jCOTINEAU kind ping just to know whether the PR is seen or not :-) |
hello @Ant0wan, thanks a lot for the time you took to participate and enhance our product. Nonetheless the current UID/GID "state" of our Dockerfiles is expected, we decided to follow OpenShift bestpractices described here. We discussed that a lot internally, and we think Openshift made good tradeoffs, the best still would be to use full user-mapping as every other solution has downsides. The current setup already allow for this securityContext:
Nonetheless there are still interesting findings in your comments/changes and i'll take some more time to review it (probably not in the upcoming days, but in a week). Hope this clarify a bit the situation. Thanks again a lot for participating in the community, this means a lot to us. |
[Suggestion] Align with Kubernetes Security StandardsRunning an App with Elevated Privileges (
|
Hello again, The root group 0 on its own is not a major security problem in the docker/kubernetes context. This current setup has also been validated by Docker hub official images maintainers, and they check and enforce best security practices. Nonetheless it has been a long running discussion, and what we will be providing soon is a way to user either a fix UID or gid=0 You can find more details here as this should acommodate for other use cases. Thanks a lot for taking the time to participate in the community and provide interesting discussions. I'll be closing the PR and discuss that internally with PMs |
Hi @jCOTINEAU, Thank you for your response. The purpose of this change was to ensure the application does not run with root group privileges, as the current setup uses the root group. It would be preferable to configure it to run with a non-root group. Could you let me know if this change might be implemented soon? Unfortunately, I don’t have visibility into the backlog, roadmap, or the internal discussions you mentioned. At my company, we are unable to use OpenShift and, like many organizations, we rely on Kubernetes. Running workloads with root group privileges is not an option for us due to the significant security risks it poses. I must admit, I am surprised by this approach, especially considering it comes from a security-focused company. Looking forward to your thoughts! |
To be honest we were also really surprised seing how they were doing it. After researching a bit, we figured out that in a modern cloud era, root group alone does not pose any security risk. But still i am surprised as openshift could have picked a very high fixed number and thats it. The changes that we are implementing right now will allow to either do:
Hope this will solve your issues |
Description
This PR introduces updates to the Dockerfile for improved runtime security of the SonarQube container. The changes ensure the application can run as a non-root user and avoid writing to the root filesystem, which enhances isolation and security, particularly in Kubernetes environments.
Changes Made
Shell Directive:
SHELL
directive with flagserrexit
,nounset
, andxtrace
to ensure robust error handling and debugging across the Dockerfile directives. This change prevents common scripting pitfalls and ensures more predictable behavior in the container build process.User and Group Management:
useradd
command to create a dedicatedsonarqube
group with GID 3000, and assigned thesonarqube
user to this group. This ensures that thesonarqube
user does not run with a GID of 0 (root group), enhancing security.File Ownership:
/opt/sonarqube
to thesonarqube
user and group usingchown
. This ensures that the application does not attempt to write to root-owned directories, avoiding potential privilege escalations.Reordered Dockerfile Instructions:
USER sonarqube
declaration closer to where the user is set up to improve readability and maintain consistency.Motives and Benefits
Improved Security:
Kubernetes Compatibility:
Filesystem Isolation:
sonarqube
does not write to the root filesystem enhances container isolation and data integrity.It allows such Kubernetes directives in deployment manifest (non-mandatory):
Checklist
run-tests.sh imagedir.
.Many thanks for reviewing this PR and for your time!