Replies: 9 comments
-
The policy must be in enforce mode as it's not possible for an audit-mode policy to produce this result. You could have multiple policies in play here. Check across the entire cluster with the command |
Beta Was this translation helpful? Give feedback.
-
@chipzoller -- absolutely agree. I saw that they were audits but had to re-apply via source control since I had removed them temporarily to get through the current install. clusterpolicy.kyverno.io/disallow-privilege-escalation true Audit true 16s 1 0 0 0 But had the same result on the install. Was being blocked on privileged-containers, check-for-labels, require-drop-all, check-seccomp-strict, run-as-non-root, and require-ro-rootfs. We don't have all of the policies enabled, but everything is in audit for now. I verified in source control. I verified by the command you provided. Strange, I know, but SonarQube certainly will not run the init pods with those policies applied in Audit. Here's the default one "described" but includes the excludes for kube-system and kyverno which we secure differently: The policy:
The described result:
So, even though it only shows Warning. The failed actions could not continue until the policy was removed. Which I thought was strange. |
Beta Was this translation helpful? Give feedback.
-
How do I reproduce this on my end? |
Beta Was this translation helpful? Give feedback.
-
Strange if I'm the only one seeing this--perhaps I'll rebuild on another machine to duplicate... |
Beta Was this translation helpful? Give feedback.
-
Followed instructions as provided, the chart was successfully installed and Sonarqube came into a running state. As expected, violations were produced from the installation not being compliant with the policy. Here's the Policy Report for that policy and in the apiVersion: wgpolicyk8s.io/v1alpha2
kind: PolicyReport
metadata:
creationTimestamp: "2023-08-04T16:33:47Z"
generation: 1
labels:
app.kubernetes.io/managed-by: kyverno
cpol.kyverno.io/disallow-privilege-escalation: "17169075"
name: cpol-disallow-privilege-escalation
namespace: sonarqube
resourceVersion: "17169445"
uid: 159bc772-aa9c-4575-9dbd-61741ce0b6a5
results:
- category: Pod Security Standards (Restricted)
message: 'validation error: Privilege escalation is disallowed. The fields spec.containers[*].securityContext.allowPrivilegeEscalation,
spec.initContainers[*].securityContext.allowPrivilegeEscalation, and spec.ephemeralContainers[*].securityContext.allowPrivilegeEscalation
must be set to false. rule autogen-privilege-escalation failed at path /spec/template/spec/containers/0/securityContext/allowPrivilegeEscalation/'
policy: disallow-privilege-escalation
resources:
- apiVersion: apps/v1
kind: StatefulSet
name: sonarqube-postgresql
namespace: sonarqube
uid: 331db20f-1ec8-4384-a0cd-6bb20fc662dc
result: fail
rule: autogen-privilege-escalation
scored: true
severity: medium
source: kyverno
timestamp:
nanos: 0
seconds: 1691166827
- category: Pod Security Standards (Restricted)
message: 'validation error: Privilege escalation is disallowed. The fields spec.containers[*].securityContext.allowPrivilegeEscalation,
spec.initContainers[*].securityContext.allowPrivilegeEscalation, and spec.ephemeralContainers[*].securityContext.allowPrivilegeEscalation
must be set to false. rule autogen-privilege-escalation failed at path /spec/template/spec/initContainers/0/securityContext/'
policy: disallow-privilege-escalation
resources:
- apiVersion: apps/v1
kind: StatefulSet
name: sonarqube-sonarqube
namespace: sonarqube
uid: 6fb41240-b9a1-4612-be70-053ae9fd51e2
result: fail
rule: autogen-privilege-escalation
scored: true
severity: medium
source: kyverno
timestamp:
nanos: 0
seconds: 1691166827
- category: Pod Security Standards (Restricted)
message: 'validation error: Privilege escalation is disallowed. The fields spec.containers[*].securityContext.allowPrivilegeEscalation,
spec.initContainers[*].securityContext.allowPrivilegeEscalation, and spec.ephemeralContainers[*].securityContext.allowPrivilegeEscalation
must be set to false. rule privilege-escalation failed at path /spec/containers/0/securityContext/allowPrivilegeEscalation/'
policy: disallow-privilege-escalation
resources:
- apiVersion: v1
kind: Pod
name: sonarqube-postgresql-0
namespace: sonarqube
uid: d6d93d14-2492-4fd7-961d-53e6b33d74c9
result: fail
rule: privilege-escalation
scored: true
severity: medium
source: kyverno
timestamp:
nanos: 0
seconds: 1691166797
- category: Pod Security Standards (Restricted)
message: 'validation error: Privilege escalation is disallowed. The fields spec.containers[*].securityContext.allowPrivilegeEscalation,
spec.initContainers[*].securityContext.allowPrivilegeEscalation, and spec.ephemeralContainers[*].securityContext.allowPrivilegeEscalation
must be set to false. rule privilege-escalation failed at path /spec/initContainers/0/securityContext/'
policy: disallow-privilege-escalation
resources:
- apiVersion: v1
kind: Pod
name: sonarqube-sonarqube-0
namespace: sonarqube
uid: f375d1de-4c2c-43d1-93ef-972b543c6e99
result: fail
rule: privilege-escalation
scored: true
severity: medium
source: kyverno
timestamp:
nanos: 0
seconds: 1691166797
summary:
error: 0
fail: 4
pass: 0
skip: 0
warn: 0 |
Beta Was this translation helpful? Give feedback.
-
Hey @chipzoller, thanks for taking the time to double-check. Something must be skewed on my side. While I get the fail, I SonarQube fails to go into the running state until the policies are removed. I'll keep looking. The only thing I can point to this is a breaking change in 1.9.2 in regards to K8S 1.22. So, in order to go further (confirm), I may have to move down to 1.7.0... which really bugs me. Do you have additional insight on this? Confirm/Deny sort of answer? Thanks again! |
Beta Was this translation helpful? Give feedback.
-
From what you've told me, no, and for what it's worth, you are the only person who has ever reported some sort of "phantom enforcement" behavior despite matching validate policies in |
Beta Was this translation helpful? Give feedback.
-
Converted to discussion as this is not a policy issue. |
Beta Was this translation helpful? Give feedback.
-
Is this question resolved? |
Beta Was this translation helpful? Give feedback.
-
Kyverno Version
1.9.x
Kubernetes Version
1.22.x
Kubernetes Platform
K3d
Description
Understanding that 1.9.2 is not fully "supported", would there be any reason to cause a basic Audit only policy from your default kyverno/policies samples to be Enforced? In other words, it seems that policies set to Audit are Enforced regardless. Example: disallow-privilege-escalation
Steps to reproduce
Expected behavior
Allowed action, but showing the warning.
Screenshots
No response
Kyverno logs
No response
Slack discussion
No response
Troubleshooting
Beta Was this translation helpful? Give feedback.
All reactions