-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Run queue proxy with restricted profile #13376
Conversation
@@ -230,6 +230,12 @@ func makeContainer(container corev1.Container, rev *v1.Revision) corev1.Containe | |||
container.Lifecycle = userLifecycle | |||
container.Env = append(container.Env, getKnativeEnvVar(rev)...) | |||
|
|||
// Set PSP requirements explicitly to avoid failures in case `pod-security.kubernetes.io/enforce=restricted` is used | |||
// at the user workload namespace | |||
container.SecurityContext.AllowPrivilegeEscalation = ptr.Bool(false) |
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.
We don't allow the user to set the following two properties. So we enforce the defaults here to make it pass the PSP auditing.
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.
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.
I sent #13401 to allow setting this in the Revision Spec (e.g. in Service).
Codecov ReportBase: 86.47% // Head: 86.47% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## main #13376 +/- ##
=======================================
Coverage 86.47% 86.47%
=======================================
Files 196 196
Lines 14551 14551
=======================================
Hits 12583 12583
Misses 1669 1669
Partials 299 299
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
Couple of minor things, but otherwise this looks good to me:
- could you add a release note?
- this won't work with kourier (it doesn't set runAsNotRoot = true)... don't think that blocks us here, just wanted to make a note of it
If you mean the gateway yes. I will take a look to fix it. Downstream we already run without root. |
@psschwei gentle ping, added the release note and created knative-extensions/net-kourier#934. |
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
/approve
/hold
to give @dprotaso a chance to weigh in
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: psschwei, skonto The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
I think we may want to pass-through the allowPrivilegeEscalation
and seccompProfile
fields, and then add a feature flag to default them to safe values if not provided.
I hadn't hit on this until the other day seeming @mattmoor 's #13395 , but I think I'd feel most happy long term with "didn't set anything" meaning secure, but allowing people to explicitly be insecure when needed (maybe with warnings)
@@ -230,6 +230,12 @@ func makeContainer(container corev1.Container, rev *v1.Revision) corev1.Containe | |||
container.Lifecycle = userLifecycle | |||
container.Env = append(container.Env, getKnativeEnvVar(rev)...) | |||
|
|||
// Set PSP requirements explicitly to avoid failures in case `pod-security.kubernetes.io/enforce=restricted` is used | |||
// at the user workload namespace | |||
container.SecurityContext.AllowPrivilegeEscalation = ptr.Bool(false) |
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.
@evankanderson I also mentioned on slack that allowing users to configure stuff on their own was more user friendly than having everything explicitly set without ability to change on demand. Also as you said users can choose their security level. For some properties though you can be opinionated and set explicitly the defaults instead of optionally applying them as in #13398 as long as users can remove them. This can be done, given our experience of what users need in practice eg. usually you dont want a service to escalate privileges. Another approach is to define security application as a downstream issue only. We have options depending on the strategy, do we want to be secure by default? My understanding is that this concept applies to other features like internal-encryption etc. Btw I am not sure if @mattmoor was aware of this PR or discussion. Should I close this PR and enable all stuff in #13398 or keep this PR with the queue proxy changes only?
You get the warning anyways from psp no need to add more imho. |
Drop: []corev1.Capability{"all"}, | ||
Drop: []corev1.Capability{"ALL"}, | ||
}, | ||
SeccompProfile: &corev1.SeccompProfile{ |
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.
I guess this takes precedence compared to podsecurityContext.SeccompProfile
.
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.
Yes, it does.
Can users see the PSP / PSA warnings when they apply a Knative Service? If so, then I'd agree about not needing a second set of warnings that settings are possibly dangerous. In #13399, I tried to add a warning because our future behavior might change, which could break a small number of applications. Upon reflection, I think giving the defaulting of security properties time to sit rather than rushing it for release is probably the right idea, particularly given the issues hit by #13399. |
I'm still willing to approve the |
/test istio-latest-no-mesh |
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.
FYI @skonto I updated the PR title / release note since these changes are just on QP now.
/lgtm
@psschwei thank you, ok to unhold? |
/hold cancel |
* allow user workloads to run with restricted profile * only change queue proxy
* Run queue proxy with restricted profile (knative#13376) * allow user workloads to run with restricted profile * only change queue proxy * remove seccomp
…ve#1283) * Run queue proxy with restricted profile (knative#13376) * allow user workloads to run with restricted profile * only change queue proxy * remove seccomp
…ve#1283) (#13) * Run queue proxy with restricted profile (knative#13376) * allow user workloads to run with restricted profile * only change queue proxy * remove seccomp
…hift#1283) * Run queue proxy with restricted profile (knative#13376) * allow user workloads to run with restricted profile * only change queue proxy * remove seccomp
…ve#1283) (#19) * Run queue proxy with restricted profile (knative#13376) * allow user workloads to run with restricted profile * only change queue proxy * remove seccomp Co-authored-by: Stavros Kontopoulos <skontopo@redhat.com>
Fixes partially #13308
Proposed Changes
Release Note