-
Notifications
You must be signed in to change notification settings - Fork 794
CMP-4040, CMP-4041: Add support for CEL based rules and profiles #14597
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
Changes from all commits
5c7c725
9ec0ffe
1b24d30
f5ae297
3223dd7
d3e1455
a6fa372
3d28f8e
840d405
f2fda3a
68a64e2
56c18e2
58619f0
14e70cb
751a5cc
39147cb
4744db9
34ffc88
c9f98a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| documentation_complete: true | ||
|
|
||
| title: 'OpenShift Virtualization' | ||
|
|
||
| description: |- | ||
| This section contains security recommendations for OpenShift Virtualization | ||
| (KubeVirt) configuration and virtual machine management. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| check_type: Platform | ||
|
|
||
| failure_reason: |- | ||
| There are registries not using TLS in '.spec.storageImport.insecureRegistries' in | ||
| the 'kubevirt-hyperconverged' resource. | ||
|
|
||
| inputs: | ||
| - name: hco | ||
| kubernetes_input_spec: | ||
| api_version: hco.kubevirt.io/v1beta1 | ||
| resource: hyperconvergeds | ||
| resource_name: kubevirt-hyperconverged | ||
| resource_namespace: openshift-cnv | ||
|
|
||
| expression: |- | ||
| !has(hco.spec.storageImport) || | ||
| hco.spec.storageImport.insecureRegistries.size() == 0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| documentation_complete: true | ||
|
|
||
| title: 'Only Trusted Registries Using TLS Can Be Used' | ||
|
|
||
| description: |- | ||
| By only pulling container images from trusted registries using TLS, organizations | ||
| can reduce the risk of introducing unknown vulnerabilities or malicious | ||
| software into their systems. This helps ensure that their applications and systems | ||
| remain secure and stable. All container image registries used by KubeVirt should | ||
| require TLS connections to protect the integrity and authenticity of images. | ||
|
|
||
| rationale: |- | ||
| When the <tt>.spec.storageImport.insecureRegistries</tt> field contains entries in | ||
| the <tt>kubevirt-hyperconverged</tt> resource, KubeVirt is configured to allow | ||
| connections to container registries that do not use TLS encryption. This creates | ||
| a significant security risk as images could be intercepted or tampered with during | ||
| transit. Man-in-the-middle attacks could result in malicious images being pulled | ||
| and executed within virtual machines. To maintain security, only registries using | ||
| TLS should be permitted, and the insecureRegistries list should be empty. | ||
|
|
||
| severity: medium | ||
|
|
||
| ocil_clause: 'insecure registries are configured' | ||
|
|
||
| ocil: |- | ||
|
Comment on lines
+23
to
+25
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the benefit of having OCIL in a CEL rule? Should the OCIL be present in CEL rules?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When consuming the data stream, Compliance Operator exposes the OCIL as I just used the same input field |
||
| Run the following command to check for insecure registries: | ||
| <pre>$ oc get hyperconverged kubevirt-hyperconverged -n openshift-cnv -o jsonpath='{.spec.storageImport.insecureRegistries}'</pre> | ||
| The output should be empty or the field should not exist. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| check_type: Platform | ||
|
|
||
| failure_reason: |- | ||
| The '.spec.permittedHostDevices' field is set in the 'kubevirt-hyperconverged' | ||
| resource, allowing host devices to be used by virtualization workloads. | ||
|
|
||
| inputs: | ||
| - name: hcoList | ||
| kubernetes_input_spec: | ||
| api_version: hco.kubevirt.io/v1beta1 | ||
| resource: hyperconvergeds | ||
|
rhmdnd marked this conversation as resolved.
|
||
|
|
||
| expression: | | ||
| hcoList.items.filter(h, | ||
| h.metadata.name == 'kubevirt-hyperconverged' && | ||
| h.metadata.namespace == 'openshift-cnv' | ||
| ).size() == 1 && | ||
| hcoList.items.filter(h, | ||
| h.metadata.name == 'kubevirt-hyperconverged' && | ||
| h.metadata.namespace == 'openshift-cnv' | ||
| ).all(h, | ||
| !has(h.spec.permittedHostDevices) || | ||
| h.spec.permittedHostDevices == null || | ||
| (has(h.spec.permittedHostDevices.pciHostDevices) && size(h.spec.permittedHostDevices.pciHostDevices) == 0) && | ||
|
Mab879 marked this conversation as resolved.
|
||
| (has(h.spec.permittedHostDevices.mediatedDevices) && size(h.spec.permittedHostDevices.mediatedDevices) == 0) | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| documentation_complete: true | ||
|
|
||
| title: 'KubeVirt Must Not Permit Host Devices' | ||
|
|
||
| description: |- | ||
| Host devices should not be permitted to virtualization workloads unless | ||
| absolutely necessary for workload execution. Allowing host devices provides | ||
| direct access to host hardware, which can introduce security risks including | ||
| unauthorized access to sensitive hardware resources, potential for privilege | ||
| escalation, and bypass of virtualization security boundaries. | ||
|
|
||
| By default, no host devices should be trusted or permitted for use by | ||
| virtualization workloads. | ||
|
|
||
| rationale: |- | ||
| The <tt>.spec.permittedHostDevices</tt> field in the <tt>kubevirt-hyperconverged</tt> | ||
| resource controls which host devices can be used by virtualization workloads. | ||
| Permitting host devices allows virtual machines to bypass virtualization boundaries | ||
| and directly access host hardware, which introduces significant security risks. | ||
| This can lead to unauthorized access to sensitive hardware resources, privilege | ||
| escalation opportunities, and potential compromise of the host system. Unless | ||
| explicitly required, no host devices should be permitted. | ||
|
|
||
| severity: medium | ||
|
|
||
| ocil_clause: 'permittedHostDevices are configured in kubevirt-hyperconverged' | ||
|
|
||
| ocil: |- | ||
| Run the following command to check the HyperConverged configuration: | ||
| <pre>$ oc get hyperconverged kubevirt-hyperconverged -n openshift-cnv -o jsonpath='{.spec.permittedHostDevices}'</pre> | ||
| The output should be empty or show empty lists for both <tt>pciHostDevices</tt> and <tt>mediatedDevices</tt>. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| check_type: Platform | ||
|
|
||
| failure_reason: |- | ||
| The '.spec.template.spec.domain.resources.overcommitGuestOverhead' field exists and is | ||
| set to "true" in the 'VirtualMachine' resource, allowing VMs to | ||
| overcommit KubeVirt's memory which may lead to guests crashing and | ||
| interrupting workloads causing malfunctions. | ||
|
|
||
| inputs: | ||
| - name: vms | ||
| kubernetes_input_spec: | ||
| api_version: kubevirt.io/v1 | ||
| resource: VirtualMachine | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. followup: |
||
|
|
||
| expression: | | ||
| vms.all(h, | ||
| !has(h.spec.template.spec.domain.resources) || | ||
| !has(h.spec.template.spec.domain.resources.overcommitGuestOverhead) || | ||
| (has(h.spec.template.spec.domain.resources.overcommitGuestOverhead) && | ||
| h.spec.template.spec.domain.resources.overcommitGuestOverhead == 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.
What determines if a rule is included in CEL and if it's included in XCCDF? Is that determined by rule presence in profiles?
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.
All CEL rules loaded are included in the cel-content.yaml.
https://github.com/ComplianceAsCode/content/pull/14597/changes#diff-ce6393057aed5d58cf51f7e13532a07ec0063429a773d3e177e5eabfefe305a7R364