-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
render policies Signed-off-by: Chip Zoller <[email protected]>
- Loading branch information
1 parent
bc05bcb
commit 1c4f8b3
Showing
10 changed files
with
402 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...licies/pod-security-cel/baseline/disallow-capabilities/disallow-capabilities.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
title: "Disallow Capabilities in CEL expressions" | ||
category: Pod Security Standards (Baseline) in CEL | ||
version: 1.11.0 | ||
subject: Pod | ||
policyType: "validate" | ||
description: > | ||
Adding capabilities beyond those listed in the policy must be disallowed. | ||
--- | ||
|
||
## Policy Definition | ||
<a href="https://github.com/kyverno/policies/raw/main//pod-security-cel/baseline/disallow-capabilities/disallow-capabilities.yaml" target="-blank">/pod-security-cel/baseline/disallow-capabilities/disallow-capabilities.yaml</a> | ||
|
||
```yaml | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: disallow-capabilities | ||
annotations: | ||
policies.kyverno.io/title: Disallow Capabilities in CEL expressions | ||
policies.kyverno.io/category: Pod Security Standards (Baseline) in CEL | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/minversion: 1.11.0 | ||
kyverno.io/kubernetes-version: "1.26-1.27" | ||
policies.kyverno.io/subject: Pod | ||
policies.kyverno.io/description: >- | ||
Adding capabilities beyond those listed in the policy must be disallowed. | ||
spec: | ||
validationFailureAction: Audit | ||
background: true | ||
rules: | ||
- name: adding-capabilities | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Pod | ||
validate: | ||
cel: | ||
expressions: | ||
- expression: >- | ||
object.spec.containers.all(container, | ||
!has(container.securityContext) || | ||
!has(container.securityContext.capabilities) || | ||
!has(container.securityContext.capabilities.add) || | ||
container.securityContext.capabilities.add.all(capability, | ||
['AUDIT_WRITE','CHOWN','DAC_OVERRIDE','FOWNER','FSETID','KILL','MKNOD','NET_BIND_SERVICE','SETFCAP','SETGID','SETPCAP','SETUID','SYS_CHROOT'].exists(secureCapability, secureCapability == capability))) | ||
message: >- | ||
Any capabilities added beyond the allowed list (AUDIT_WRITE, CHOWN, DAC_OVERRIDE, FOWNER, | ||
FSETID, KILL, MKNOD, NET_BIND_SERVICE, SETFCAP, SETGID, SETPCAP, SETUID, SYS_CHROOT) | ||
are disallowed. | ||
- expression: >- | ||
!has(object.spec.initContainers) || | ||
object.spec.initContainers.all(container, !has(container.securityContext) || | ||
!has(container.securityContext.capabilities) || | ||
!has(container.securityContext.capabilities.add) || | ||
container.securityContext.capabilities.add.all(capability, | ||
['AUDIT_WRITE','CHOWN','DAC_OVERRIDE','FOWNER','FSETID','KILL','MKNOD','NET_BIND_SERVICE','SETFCAP','SETGID','SETPCAP','SETUID','SYS_CHROOT'].exists(secureCapability, secureCapability == capability))) | ||
message: >- | ||
Any capabilities added beyond the allowed list (AUDIT_WRITE, CHOWN, DAC_OVERRIDE, FOWNER, | ||
FSETID, KILL, MKNOD, NET_BIND_SERVICE, SETFCAP, SETGID, SETPCAP, SETUID, SYS_CHROOT) | ||
are disallowed. | ||
- expression: >- | ||
!has(object.spec.ephemeralContainers) || | ||
object.spec.ephemeralContainers.all(container, !has(container.securityContext) || | ||
!has(container.securityContext.capabilities) || | ||
!has(container.securityContext.capabilities.add) || | ||
container.securityContext.capabilities.add.all(capability, | ||
['AUDIT_WRITE','CHOWN','DAC_OVERRIDE','FOWNER','FSETID','KILL','MKNOD','NET_BIND_SERVICE','SETFCAP','SETGID','SETPCAP','SETUID','SYS_CHROOT'].exists(secureCapability, secureCapability == capability))) | ||
message: >- | ||
Any capabilities added beyond the allowed list (AUDIT_WRITE, CHOWN, DAC_OVERRIDE, FOWNER, | ||
FSETID, KILL, MKNOD, NET_BIND_SERVICE, SETFCAP, SETGID, SETPCAP, SETUID, SYS_CHROOT) | ||
are disallowed. | ||
``` |
52 changes: 52 additions & 0 deletions
52
.../pod-security-cel/baseline/disallow-host-namespaces/disallow-host-namespaces.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
title: "Disallow Host Namespaces in CEL expressions" | ||
category: Pod Security Standards (Baseline) in CEL | ||
version: 1.11.0 | ||
subject: Pod | ||
policyType: "validate" | ||
description: > | ||
Host namespaces (Process ID namespace, Inter-Process Communication namespace, and network namespace) allow access to shared information and can be used to elevate privileges. Pods should not be allowed access to host namespaces. This policy ensures fields which make use of these host namespaces are unset or set to `false`. | ||
--- | ||
|
||
## Policy Definition | ||
<a href="https://github.com/kyverno/policies/raw/main//pod-security-cel/baseline/disallow-host-namespaces/disallow-host-namespaces.yaml" target="-blank">/pod-security-cel/baseline/disallow-host-namespaces/disallow-host-namespaces.yaml</a> | ||
|
||
```yaml | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: disallow-host-namespaces | ||
annotations: | ||
policies.kyverno.io/title: Disallow Host Namespaces in CEL expressions | ||
policies.kyverno.io/category: Pod Security Standards (Baseline) in CEL | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/minversion: 1.11.0 | ||
kyverno.io/kubernetes-version: "1.26-1.27" | ||
policies.kyverno.io/subject: Pod | ||
policies.kyverno.io/description: >- | ||
Host namespaces (Process ID namespace, Inter-Process Communication namespace, and | ||
network namespace) allow access to shared information and can be used to elevate | ||
privileges. Pods should not be allowed access to host namespaces. This policy ensures | ||
fields which make use of these host namespaces are unset or set to `false`. | ||
spec: | ||
validationFailureAction: Audit | ||
background: true | ||
rules: | ||
- name: host-namespaces | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Pod | ||
validate: | ||
cel: | ||
expressions: | ||
- expression: >- | ||
(!has(object.spec.hostNetwork) || object.spec.hostNetwork == false) && | ||
(!has(object.spec.hostIPC) || object.spec.hostIPC == false) && | ||
(!has(object.spec.hostPID) || object.spec.hostPID == false) | ||
message: >- | ||
Sharing the host namespaces is disallowed. The fields spec.hostNetwork, | ||
spec.hostIPC, and spec.hostPID must be unset or set to `false`. | ||
``` |
46 changes: 46 additions & 0 deletions
46
.../en/policies/pod-security-cel/baseline/disallow-host-path/disallow-host-path.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
title: "Disallow hostPath in CEL expressions" | ||
category: Pod Security Standards (Baseline) in CEL | ||
version: 1.11.0 | ||
subject: Pod,Volume | ||
policyType: "validate" | ||
description: > | ||
HostPath volumes let Pods use host directories and volumes in containers. Using host resources can be used to access shared data or escalate privileges and should not be allowed. This policy ensures no hostPath volumes are in use. | ||
--- | ||
|
||
## Policy Definition | ||
<a href="https://github.com/kyverno/policies/raw/main//pod-security-cel/baseline/disallow-host-path/disallow-host-path.yaml" target="-blank">/pod-security-cel/baseline/disallow-host-path/disallow-host-path.yaml</a> | ||
|
||
```yaml | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: disallow-host-path | ||
annotations: | ||
policies.kyverno.io/title: Disallow hostPath in CEL expressions | ||
policies.kyverno.io/category: Pod Security Standards (Baseline) in CEL | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/subject: Pod,Volume | ||
policies.kyverno.io/minversion: 1.11.0 | ||
kyverno.io/kubernetes-version: "1.26-1.27" | ||
policies.kyverno.io/description: >- | ||
HostPath volumes let Pods use host directories and volumes in containers. | ||
Using host resources can be used to access shared data or escalate privileges | ||
and should not be allowed. This policy ensures no hostPath volumes are in use. | ||
spec: | ||
validationFailureAction: Audit | ||
background: true | ||
rules: | ||
- name: host-path | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Pod | ||
validate: | ||
cel: | ||
expressions: | ||
- expression: "!has(object.spec.volumes) || object.spec.volumes.all(volume, !has(volume.hostPath))" | ||
message: "HostPath volumes are forbidden. The field spec.volumes[*].hostPath must be unset" | ||
|
||
``` |
63 changes: 63 additions & 0 deletions
63
...od-security-cel/baseline/disallow-host-ports-range/disallow-host-ports-range.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
title: "Disallow hostPorts Range (Alternate) in CEL expressions" | ||
category: Pod Security Standards (Baseline) in CEL | ||
version: 1.11.0 | ||
subject: Pod | ||
policyType: "validate" | ||
description: > | ||
Access to host ports allows potential snooping of network traffic and should not be allowed, or at minimum restricted to a known list. This policy ensures the `hostPort` field is set to one in the designated list. | ||
--- | ||
|
||
## Policy Definition | ||
<a href="https://github.com/kyverno/policies/raw/main//pod-security-cel/baseline/disallow-host-ports-range/disallow-host-ports-range.yaml" target="-blank">/pod-security-cel/baseline/disallow-host-ports-range/disallow-host-ports-range.yaml</a> | ||
|
||
```yaml | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: disallow-host-ports-range | ||
annotations: | ||
policies.kyverno.io/title: Disallow hostPorts Range (Alternate) in CEL expressions | ||
policies.kyverno.io/category: Pod Security Standards (Baseline) in CEL | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/subject: Pod | ||
policies.kyverno.io/minversion: 1.11.0 | ||
kyverno.io/kubernetes-version: "1.26-1.27" | ||
policies.kyverno.io/description: >- | ||
Access to host ports allows potential snooping of network traffic and should not be | ||
allowed, or at minimum restricted to a known list. This policy ensures the `hostPort` | ||
field is set to one in the designated list. | ||
spec: | ||
validationFailureAction: Audit | ||
background: true | ||
rules: | ||
- name: host-port-range | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Pod | ||
validate: | ||
cel: | ||
expressions: | ||
- expression: >- | ||
object.spec.containers.all(container, !has(container.ports) || | ||
container.ports.all(port, !has(port.hostPort) || (port.hostPort >= 5000 && port.hostPort <= 6000))) | ||
message: >- | ||
The only permitted hostPorts are in the range 5000-6000. | ||
- expression: >- | ||
!has(object.spec.initContainers) || | ||
object.spec.initContainers.all(container, !has(container.ports) || | ||
container.ports.all(port, !has(port.hostPort) || (port.hostPort >= 5000 && port.hostPort <= 6000))) | ||
message: >- | ||
The only permitted hostPorts are in the range 5000-6000. | ||
- expression: >- | ||
!has(object.spec.ephemeralContainers) || | ||
object.spec.ephemeralContainers.all(container, !has(container.ports) || | ||
container.ports.all(port, !has(port.hostPort) || (port.hostPort >= 5000 && port.hostPort <= 6000))) | ||
message: >- | ||
The only permitted hostPorts are in the range 5000-6000. | ||
``` |
66 changes: 66 additions & 0 deletions
66
...n/policies/pod-security-cel/baseline/disallow-host-ports/disallow-host-ports.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
title: "Disallow hostPorts in CEL expressions" | ||
category: Pod Security Standards (Baseline) in CEL | ||
version: 1.11.0 | ||
subject: Pod | ||
policyType: "validate" | ||
description: > | ||
Access to host ports allows potential snooping of network traffic and should not be allowed, or at minimum restricted to a known list. This policy ensures the `hostPort` field is unset or set to `0`. | ||
--- | ||
|
||
## Policy Definition | ||
<a href="https://github.com/kyverno/policies/raw/main//pod-security-cel/baseline/disallow-host-ports/disallow-host-ports.yaml" target="-blank">/pod-security-cel/baseline/disallow-host-ports/disallow-host-ports.yaml</a> | ||
|
||
```yaml | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: disallow-host-ports | ||
annotations: | ||
policies.kyverno.io/title: Disallow hostPorts in CEL expressions | ||
policies.kyverno.io/category: Pod Security Standards (Baseline) in CEL | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/subject: Pod | ||
policies.kyverno.io/minversion: 1.11.0 | ||
kyverno.io/kubernetes-version: "1.26-1.27" | ||
policies.kyverno.io/description: >- | ||
Access to host ports allows potential snooping of network traffic and should not be | ||
allowed, or at minimum restricted to a known list. This policy ensures the `hostPort` | ||
field is unset or set to `0`. | ||
spec: | ||
validationFailureAction: Audit | ||
background: true | ||
rules: | ||
- name: host-ports-none | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Pod | ||
validate: | ||
cel: | ||
expressions: | ||
- expression: >- | ||
object.spec.containers.all(container, !has(container.ports) || | ||
container.ports.all(port, !has(port.hostPort) || port.hostPort == 0)) | ||
message: >- | ||
Use of host ports is disallowed. The field spec.containers[*].ports[*].hostPort | ||
must either be unset or set to `0`. | ||
- expression: >- | ||
!has(object.spec.initContainers) || | ||
object.spec.initContainers.all(container, !has(container.ports) || | ||
container.ports.all(port, !has(port.hostPort) || port.hostPort == 0)) | ||
message: >- | ||
Use of host ports is disallowed. The field spec.initContainers[*].ports[*].hostPort | ||
must either be unset or set to `0`. | ||
- expression: >- | ||
!has(object.spec.ephemeralContainers) || | ||
object.spec.ephemeralContainers.all(container, !has(container.ports) || | ||
container.ports.all(port, !has(port.hostPort) || port.hostPort == 0)) | ||
message: >- | ||
Use of host ports is disallowed. The field spec.ephemeralContainers[*].ports[*].hostPort | ||
must either be unset or set to `0`. | ||
``` |
Oops, something went wrong.