-
Notifications
You must be signed in to change notification settings - Fork 321
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
fix(query): Extend containers_running_as_root k8s rule to work if no securityContext is defined #4886
fix(query): Extend containers_running_as_root k8s rule to work if no securityContext is defined #4886
Conversation
…securityContext is defined
Scan submitted to Checkmarx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Churro, everything looks good to me, the only thing I would like to request here is the use of the searchLine
Thank you for your great contributions
Hi @joaoReigota1, are you sure My understanding is that |
Hi @Churro, 1: apiVersion: v1
2: kind: Pod
3: metadata:
4: name: security-context-demo-2
5: spec:
6: containers:
7: - name: sec-ctx-demo-1
8: image: gcr.io/google-samples/node-hello:1.0
9: - name: sec-ctx-demo-2
10: image: gcr.io/google-samples/node-hello:1.0
11: securityContext:
12: runAsUser: 0
13: allowPrivilegeEscalation: false
14: runAsNonRoot: false Having this
The issue is in the first container, following our |
Hi @joaoReigota1, thank you for coming up with a concrete example to demonstrate the benefit of using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀 Thank you so much, @Churro!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Problem
pod.securityContext.runAsNonRoot == false
andpod.securityContext.runAsUser undefined
, is missing. This leads to false positives.checkRootParent
is evaluated. The same applies tocheckUserContainer
. Patching the rule such thatsecurityContext
may or may not be specified is tricky and would potentially break the rule logic.Proposed Changes
checkRootContainer
), the opposite is now looked upI submit this contribution under the Apache-2.0 license.