Ngày 62 - Compliance và quét lỗ hổng trong OpenShift
Thực hành Compliance Operator và xem kết quả quét image với Quay Container Security Operator.
Nội dung khóa học
- 90 Ngày DevOps v2 ♾️
- Ngày 1 - Nhìn lại
- Ngày 2 - Bức Tranh Toàn Cảnh: DevSecOps
- Ngày 3 - Tư Duy Như Một Kẻ Tấn Công
- Ngày 4 - Đội Đỏ và Đội Xanh
- Ngày 5 - Bảo Mật Mã Nguồn Mở
- Ngày 6 - Thực Hành Xây Dựng Một Ứng Dụng Có Lỗ Hổng
- Ngày 7: Tổng quan về Lập trình an toàn
- Ngày 8: Tổng quan về SAST
- Ngày 9: Triển khai SAST với SonarCloud
- Ngày 10: Tổng quan về Phân tích Thành phần Phần mềm
- Ngày 11: Triển khai SCA với OWASP Dependency Check
- Ngày 12: Các nguyên tắc lập trình an toàn
- Ngày 13: Các nguyên tắc lập trình an toàn bổ sung
- Ngày 14: Quét container image
- Ngày 15: Quét container image nâng cao
- Ngày 16: Kiểm thử Fuzzing
- Ngày 17: Kiểm thử Fuzzing nâng cao
- Ngày 18: DAST
- Ngày 19: IAST
- Ngày 20: Thực hành với IAST và DAST
- Ngày 21 - Tự động rà quét image repository
- Ngày 22 - Tích hợp rà quét Container Registry
- Ngày 23 - Tích hợp rà quét Artifacts
- Ngày 24 - Ký xác thực (Signing)
- Ngày 25 - Quét lỗ hổng hệ thống
- Ngày 26 - Quét lỗ hổng container
- Ngày 27 - Quét lỗ hổng mạng
- Ngày 28 - Giám sát và kiểm toán hệ thống
- Ngày 29 - Giám sát cấp ứng dụng
- Ngày 30 - Phát hiện hành vi ứng dụng đáng ngờ
- Ngày 31 - Bảo vệ và chính sách mạng runtime
- Ngày 32 - Quản lý lỗ hổng và bản vá
- Ngày 33 - Chính sách runtime cho ứng dụng và mạng
- Ngày 34 - Kiểm soát truy cập runtime
- Ngày 35 - Tầm quan trọng của quản lý secrets
- Ngày 36 - Bảo vệ secrets với HashiCorp Vault
- Ngày 37 - Làm việc với secrets engine của Vault
- Ngày 38 - Tăng cường bảo mật với credential động
- Ngày 39 - Thực hành HashiCorp Vault trên Kubernetes
- Ngày 40 - Tìm hiểu Kubernetes Secrets
- Ngày 41 - Thực hành Kubernetes Secrets
- Ngày 42 - Giới thiệu Python
- Ngày 43 - Vòng lặp, hàm và module trong Python
- Ngày 44 - Cấu trúc dữ liệu và OOP trong Python
- Ngày 45 - Debug, kiểm thử và biểu thức chính quy trong Python
- Ngày 46 - Phát triển web với Python
- Ngày 47 - Tự động hóa với Python
- Ngày 48 - Xây dựng ứng dụng Python
- Ngày 49 - Tổng quan AWS Cloud
- Ngày 50 - Tạo tài khoản AWS và cảnh báo chi phí
- Ngày 51 - Infrastructure as Code và CloudFormation
- Ngày 52 - Identity and Access Management (IAM)
- Ngày 53 - AWS Systems Manager
- Ngày 54 - AWS CodeCommit
- Ngày 55 - AWS CodePipeline
- Ngày 56 - Tổng quan Red Hat OpenShift
- Ngày 57 - Kiến trúc và cài đặt OpenShift
- Ngày 58 - Cài đặt OpenShift trên VMware vSphere
- Ngày 59 - Triển khai ứng dụng và Security Context Constraints
- Ngày 60 - Tạo, cấu hình và quản trị OpenShift Project
- Ngày 61 - Xác thực, RBAC và audit trong OpenShift
- Ngày 62 - Compliance và quét lỗ hổng trong OpenShift
- Ngày 63 - Giới thiệu cơ sở dữ liệu
- Ngày 64 - Truy vấn dữ liệu trong database
- Ngày 65 - Backup và restore database
- Ngày 66 - High availability và disaster recovery
- Ngày 67 - Tối ưu hiệu năng database
- Ngày 68 - Bảo mật database
- Ngày 69 - Monitoring và troubleshooting database
- Ngày 70 - Serverless là gì?
- Ngày 71 - Serverless compute
- Ngày 72 - Serverless storage
- Ngày 73 - Serverless API
- Ngày 74 - Điều phối serverless
- Ngày 75 - Serverless và Well-Architected
- Ngày 76 - Serverless: kiến thức tiếp theo
- Ngày 77 - Tìm hiểu service mesh
- Ngày 78 - Cài đặt và kiểm thử service mesh
- Ngày 79 - So sánh các service mesh
- Ngày 80 - Cơ bản về quản lý lưu lượng Istio
- Ngày 81 - Observability trong service mesh
- Ngày 82 - Bảo mật microservices với Istio
- Ngày 83 - Istio Ambient Mesh
- Ngày 84 - Viết một API
- Ngày 85 - Queue và kiến trúc bất đồng bộ
- Ngày 86 - Thiết kế resilience, redundancy và reliability
- Ngày 87 - Triển khai không gián đoạn
- Ngày 88 - Monitoring, alerting và on-call
- Ngày 89 - Văn hóa blameless và postmortem
- Ngày 90 - Tổng kết 90 ngày DevOps 2023

Mục lục
Compliance và quét lỗ hổng
Sau AAA và audit ở Ngày 61, chúng ta xem hai phần trong bảo mật OpenShift: đánh giá compliance và quét lỗ hổng image. Bài gốc dùng OpenShift 4.12 và dữ liệu năm 2023; tên channel, API và kết quả quét có thể thay đổi.
Không một công cụ hay scan đơn lẻ tự đảm bảo tuân thủ quy định. Cần kết hợp kiểm soát truy cập, audit, mã hóa, đánh giá phát hiện và quy trình xử lý phù hợp với tổ chức.
Compliance Operator
Compliance Operator dùng nội dung OpenSCAP để đánh giá tài nguyên API OpenShift và node theo các profile được hỗ trợ, báo cáo kết quả và có thể cung cấp remediation. Xem các profile OpenShift 4.12.
Cài đặt
Tạo namespace openshift-compliance bằng file openshift-compliance-namespace.yaml:
apiVersion: v1
kind: Namespace
metadata:
labels:
openshift.io/cluster-monitoring: "true"
pod-security.kubernetes.io/enforce: privileged
name: openshift-compliance
Tạo OperatorGroup bằng openshift-compliance-operator-group.yaml:
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: compliance-operator
namespace: openshift-compliance
spec:
targetNamespaces:
- openshift-compliance
Tạo Subscription bằng openshift-compliance-operator-subscription.yaml:
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: compliance-operator-sub
namespace: openshift-compliance
spec:
channel: "release-0.1"
installPlanApproval: Automatic
name: compliance-operator
source: redhat-operators
sourceNamespace: openshift-marketplace
Áp dụng từng file bằng oc apply -f <tên-file>, rồi kiểm tra:
$ oc get csv -n openshift-compliance
$ oc get deploy -n openshift-compliance
Bối cảnh và phạm vi: Namespace trong ví dụ đặt PSA
privilegedvà Subscription tự phê duyệt. Kiểm tra yêu cầu cài đặt, channel và tác động của phiên bản Operator hiện tại; chỉ áp dụng sau khi đánh giá quyền, cập nhật và môi trường đích.
Xem profile và rule
Liệt kê profile:
$ oc get -n openshift-compliance profiles.compliance
NAME AGE
ocp4-cis 107m
ocp4-cis-node 107m
ocp4-e8 107m
ocp4-high 107m
ocp4-high-node 107m
ocp4-moderate 107m
ocp4-moderate-node 107m
ocp4-nerc-cip 107m
ocp4-nerc-cip-node 107m
ocp4-pci-dss 107m
ocp4-pci-dss-node 107m
rhcos4-e8 107m
rhcos4-high 107m
rhcos4-moderate 107m
rhcos4-nerc-cip 107m
Tiền tố ocp4 chỉ profile cho OpenShift, còn rhcos4 cho RHCOS. Ví dụ xem profile CIS:
$ oc get -n openshift-compliance -oyaml profiles.compliance ocp4-cis
apiVersion: compliance.openshift.io/v1alpha1
description: This profile defines a baseline that aligns to the Center for Internet
Security® Red Hat OpenShift Container Platform 4 Benchmark™, V1.1. This profile
includes Center for Internet Security® Red Hat OpenShift Container Platform 4 CIS
Benchmarks™ content. Note that this part of the profile is meant to run on the Platform
that Red Hat OpenShift Container Platform 4 runs on top of. This profile is applicable
to OpenShift versions 4.6 and greater.
id: xccdf_org.ssgproject.content_profile_cis
kind: Profile
metadata:
annotations:
compliance.openshift.io/image-digest: pb-ocp477wpm
compliance.openshift.io/product: redhat_openshift_container_platform_4.1
compliance.openshift.io/product-type: Platform
creationTimestamp: "2023-03-31T09:09:52Z"
generation: 1
labels:
compliance.openshift.io/profile-bundle: ocp4
name: ocp4-cis
namespace: openshift-compliance
ownerReferences:
- apiVersion: compliance.openshift.io/v1alpha1
blockOwnerDeletion: true
controller: true
kind: ProfileBundle
name: ocp4
uid: 19c2e4a5-094f-416a-a06b-eb0598e39618
resourceVersion: "12971302"
uid: 6dc3cca4-5649-43ae-8c46-614f82fd6744
rules:
- ocp4-accounts-restrict-service-account-tokens
- ocp4-accounts-unique-service-account
- ocp4-api-server-admission-control-plugin-alwaysadmit
- ocp4-api-server-admission-control-plugin-alwayspullimages
- ocp4-api-server-admission-control-plugin-namespacelifecycle
- ocp4-api-server-admission-control-plugin-noderestriction
- ocp4-api-server-admission-control-plugin-scc
- ocp4-api-server-admission-control-plugin-securitycontextdeny
- ocp4-api-server-admission-control-plugin-service-account
- ocp4-api-server-anonymous-auth
- ocp4-api-server-api-priority-flowschema-catch-all
- ocp4-api-server-api-priority-gate-enabled
- ocp4-api-server-audit-log-maxbackup
- ocp4-api-server-audit-log-maxsize
- ocp4-api-server-audit-log-path
- ocp4-api-server-auth-mode-no-aa
- ocp4-api-server-auth-mode-node
- ocp4-api-server-auth-mode-rbac
- ocp4-api-server-basic-auth
- ocp4-api-server-bind-address
...
- ocp4-scc-limit-privileged-containers
- ocp4-scc-limit-process-id-namespace
- ocp4-scc-limit-root-containers
- ocp4-scheduler-no-bind-address
- ocp4-secrets-consider-external-storage
- ocp4-secrets-no-environment-variables
- ocp4-version-detect-in-hypershift
- ocp4-version-detect-in-ocp
title: CIS Red Hat OpenShift Container Platform 4 Benchmark
Xem rule cụ thể:
$ oc get -n openshift-compliance rules ocp4-api-server-anonymous-auth -oyaml
apiVersion: compliance.openshift.io/v1alpha1
checkType: Platform
description: |-
By default, anonymous access to the OpenShift API is enabled, but at the same time, all requests must be authorized. If no authentication mechanism is used, the request is assigned the system:anonymous virtual user and the system:unauthenticated virtual group. This allows the authorization layer to determin which requests, if any, is an anonymous user authorized to make. To verify the authorization rules for anonymous requests run the following:
$ oc describe clusterrolebindings
and inspect the bidnings of the system:anonymous virtual user and the system:unauthenticated virtual group. To test that an anonymous request is authorized to access the readyz endpoint, run:
$ oc get --as="system:anonymous" --raw='/readyz?verbose'
In contrast, a request to list all projects should not be authorized:
$ oc get --as="system:anonymous" projects
id: xccdf_org.ssgproject.content_rule_api_server_anonymous_auth
instructions: |-
Run the following command to view the authorization rules for anonymous requests:
$ oc describe clusterrolebindings
Make sure that there exists at least one clusterrolebinding that binds
either the system:unauthenticated group or the system:anonymous
user.
To test that an anonymous request is authorized to access the readyz
endpoint, run:
$ oc get --as="system:anonymous" --raw='/readyz?verbose'
In contrast, a request to list all projects should not be authorized:
$ oc get --as="system:anonymous" projects
kind: Rule
metadata:
annotations:
compliance.openshift.io/image-digest: pb-ocp477wpm
compliance.openshift.io/rule: api-server-anonymous-auth
control.compliance.openshift.io/CIS-OCP: 1.2.1
control.compliance.openshift.io/NERC-CIP: CIP-003-8 R6;CIP-004-6 R3;CIP-007-3
R6.1
control.compliance.openshift.io/NIST-800-53: CM-6;CM-6(1)
control.compliance.openshift.io/PCI-DSS: Req-2.2
policies.open-cluster-management.io/controls: 1.2.1,CIP-003-8 R6,CIP-004-6 R3,CIP-007-3
R6.1,CM-6,CM-6(1),Req-2.2
policies.open-cluster-management.io/standards: CIS-OCP,NERC-CIP,NIST-800-53,PCI-DSS
creationTimestamp: "2023-03-31T09:09:53Z"
generation: 1
labels:
compliance.openshift.io/profile-bundle: ocp4
name: ocp4-api-server-anonymous-auth
namespace: openshift-compliance
ownerReferences:
- apiVersion: compliance.openshift.io/v1alpha1
blockOwnerDeletion: true
controller: true
kind: ProfileBundle
name: ocp4
uid: 19c2e4a5-094f-416a-a06b-eb0598e39618
resourceVersion: "12971338"
uid: 12db5786-4ff6-4e80-90e0-2b370541f6e1
rationale: When enabled, requests that are not rejected by other configured authentication
methods are treated as anonymous requests. These requests are then served by the
API server. If you are using RBAC authorization, it is generally considered reasonable
to allow anonymous access to the API Server for health checks and discovery purposes,
and hence this recommendation is not scored. However, you should consider whether
anonymous discovery is an acceptable risk for your purposes.
severity: medium
title: Ensure that anonymous requests to the API Server are authorized
Output trong bài gốc là ảnh chụp cấu hình và phiên bản nội dung tại thời điểm chạy, không phải kết quả bảo đảm cho cluster khác.
Chạy scan
ScanSetting mô tả cách chạy scan, lưu kết quả, node và lịch; ScanSettingBinding liên kết cấu hình với profile. Xem cấu hình mặc định:
$ oc describe scansettings default -n openshift-compliance
Name: default
Namespace: openshift-compliance
Labels: <none>
Annotations: <none>
API Version: compliance.openshift.io/v1alpha1
Kind: ScanSetting
Max Retry On Timeout: 3
Metadata:
Creation Timestamp: 2023-03-31T09:09:33Z
Generation: 1
Resource Version: 12971055
UID: 78945c1e-c323-40d8-87d9-c571275d58e3
Raw Result Storage:
Node Selector:
node-role.kubernetes.io/master:
Pv Access Modes:
ReadWriteOnce
Rotation: 3
Size: 1Gi
Tolerations:
Effect: NoSchedule
Key: node-role.kubernetes.io/master
Operator: Exists
Effect: NoExecute
Key: node.kubernetes.io/not-ready
Operator: Exists
Toleration Seconds: 300
Effect: NoExecute
Key: node.kubernetes.io/unreachable
Operator: Exists
Toleration Seconds: 300
Effect: NoSchedule
Key: node.kubernetes.io/memory-pressure
Operator: Exists
Roles:
master
worker
Scan Tolerations:
Operator: Exists
Schedule: 0 1 * * *
Show Not Applicable: false
Strict Node Scan: true
Timeout: 30m
Events: <none>
Nguồn cũng đề cập default-auto-apply, có thể tự áp dụng các remediation được hỗ trợ. Việc tự sửa cấu hình có thể ảnh hưởng workload hoặc node; cần xem xét và thử nghiệm trước khi bật.
Tạo compliance-scansettingbinding.yaml và áp dụng bằng oc apply -f compliance-scansettingbinding.yaml:
apiVersion: compliance.openshift.io/v1alpha1
kind: ScanSettingBinding
metadata:
name: cis-compliance
namespace: openshift-compliance
profiles:
- name: ocp4-cis-node
kind: Profile
apiGroup: compliance.openshift.io/v1alpha1
- name: ocp4-cis
kind: Profile
apiGroup: compliance.openshift.io/v1alpha1
settingsRef:
name: default
kind: ScanSetting
apiGroup: compliance.openshift.io/v1alpha1
Operator tạo ComplianceSuite và ComplianceScan. Trong khi scan đang chạy:
$ oc get compliancescan -n openshift-compliance
NAME PHASE RESULT
ocp4-cis AGGREGATING NOT-AVAILABLE
ocp4-cis-node-master AGGREGATING NOT-AVAILABLE
ocp4-cis-node-worker AGGREGATING NOT-AVAILABLE
Sau khi hoàn thành, ví dụ có kết quả NON-COMPLIANT:
$ oc get compliancescan -n openshift-compliance
NAME PHASE RESULT
ocp4-cis DONE NON-COMPLIANT
ocp4-cis-node-master DONE NON-COMPLIANT
ocp4-cis-node-worker DONE NON-COMPLIANT
Xem chi tiết scan:
$ oc get compliancescan -n openshift-compliance ocp4-cis -o yaml
oc get compliancescan -n openshift-compliance ocp4-cis -o yaml
apiVersion: compliance.openshift.io/v1alpha1
kind: ComplianceScan
metadata:
creationTimestamp: "2023-03-31T10:49:41Z"
finalizers:
- scan.finalizers.compliance.openshift.io
generation: 1
labels:
compliance.openshift.io/suite: cis-compliance
name: ocp4-cis
namespace: openshift-compliance
ownerReferences:
- apiVersion: compliance.openshift.io/v1alpha1
blockOwnerDeletion: true
controller: true
kind: ComplianceSuite
name: cis-compliance
uid: c40db43f-0635-4731-b537-5ad3fc08cc06
resourceVersion: "13035410"
uid: 9d5b10b8-f67c-44f3-b13d-0765cb037091
spec:
content: ssg-ocp4-ds.xml
contentImage: registry.redhat.io/compliance/openshift-compliance-content-rhel8@sha256:c4bf5b2b20ff538adbc430b7ee993fbd7c291203a9810534005148304e3b169b
maxRetryOnTimeout: 3
profile: xccdf_org.ssgproject.content_profile_cis
rawResultStorage:
nodeSelector:
node-role.kubernetes.io/master: ""
pvAccessModes:
- ReadWriteOnce
rotation: 3
size: 1Gi
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
operator: Exists
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 300
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 300
- effect: NoSchedule
key: node.kubernetes.io/memory-pressure
operator: Exists
scanTolerations:
- operator: Exists
scanType: Platform
showNotApplicable: false
strictNodeScan: true
timeout: 30m
status:
conditions:
- lastTransitionTime: "2023-03-31T10:51:20Z"
message: Compliance scan run is done running the scans
reason: NotRunning
status: "False"
type: Processing
- lastTransitionTime: "2023-03-31T10:51:20Z"
message: Compliance scan run is done and has results
reason: Done
status: "True"
type: Ready
phase: DONE
remainingRetries: 3
result: NON-COMPLIANT
resultsStorage:
name: ocp4-cis
namespace: openshift-compliance
warnings: |-
could not fetch /apis/flowcontrol.apiserver.k8s.io/v1alpha1/flowschemas/catch-all: the server could not find the requested resource
could not fetch /apis/logging.openshift.io/v1/namespaces/openshift-logging/clusterlogforwarders/instance: the server could not find the requested resource
could not fetch /apis/apps/v1/namespaces/openshift-sdn/daemonsets/sdn: daemonsets.apps "sdn" not found
could not fetch "/api/v1/nodes/NODE_NAME/proxy/configz": the server could not find the requested resource
could not fetch "/api/v1/nodes/NODE_NAME/proxy/configz": the server could not find the requested resource
could not fetch "/api/v1/nodes/NODE_NAME/proxy/configz": the server could not find the requested resource
could not fetch "/api/v1/nodes/NODE_NAME/proxy/configz": the server could not find the requested resource
could not fetch "/api/v1/nodes/NODE_NAME/proxy/configz": the server could not find the requested resource
could not fetch "/api/v1/nodes/NODE_NAME/proxy/configz": the server could not find the requested resource
could not fetch "/api/v1/nodes/NODE_NAME/proxy/configz": the server could not find the requested resource
could not fetch "/api/v1/nodes/NODE_NAME/proxy/configz": the server could not find the requested resource
could not fetch "/api/v1/nodes/NODE_NAME/proxy/configz": the server could not find the requested resource
could not fetch "/api/v1/nodes/NODE_NAME/proxy/configz": the server could not find the requested resource
could not fetch "/api/v1/nodes/NODE_NAME/proxy/configz": the server could not find the requested resource
could not fetch "/api/v1/nodes/NODE_NAME/proxy/configz": the server could not find the requested resource
could not fetch "/api/v1/nodes/NODE_NAME/proxy/configz": the server could not find the requested resource
could not fetch "/api/v1/nodes/NODE_NAME/proxy/configz": the server could not find the requested resource
could not fetch /apis/hypershift.openshift.io/v1beta1/namespaces/clusters/hostedclusters/None: the server could not find the requested resource
Kubelet configs for 90days-ocp-72ptq-master-1 are not consistent with role master, Diff: [{"op":"replace","path":"/address","value":"192.168.200.183"}] of KubeletConfigs for master role will not be saved.
Kubelet configs for 90days-ocp-72ptq-worker-x7v4j are not consistent with role worker, Diff: [{"op":"replace","path":"/address","value":"192.168.200.194"}] of KubeletConfigs for worker role will not be saved.
Kubelet configs for 90days-ocp-72ptq-master-2 are not consistent with role master, Diff: [{"op":"add","path":"/address","value":"192.168.200.181"}] of KubeletConfigs for master role will not be saved.
Kubelet configs for 90days-ocp-72ptq-master-0 are not consistent with role control-plane, Diff: [{"op":"replace","path":"/address","value":"192.168.200.185"}] of KubeletConfigs for control-plane role will not be saved.
Kubelet configs for 90days-ocp-72ptq-master-2 are not consistent with role control-plane, Diff: [{"op":"add","path":"/address","value":"192.168.200.181"}] of KubeletConfigs for control-plane role will not be saved.
Kubelet configs for 90days-ocp-72ptq-worker-5cgp8 are not consistent with role worker, Diff: [{"op":"add","path":"/address","value":"192.168.200.187"}] of KubeletConfigs for worker role will not be saved.
Dòng lệnh đầu khối output trên được bài gốc đưa vào cùng YAML; đây là output minh họa, không phải manifest để áp dụng. Kiểm tra cả warning và phạm vi profile trước khi diễn giải kết quả.
Liệt kê các check thất bại:
$ oc get compliancecheckresults -n openshift-compliance -l 'compliance.openshift.io/check-status=FAIL'
NAME STATUS SEVERITY
ocp4-cis-api-server-encryption-provider-cipher FAIL medium
ocp4-cis-api-server-encryption-provider-config FAIL medium
ocp4-cis-audit-log-forwarding-enabled FAIL medium
ocp4-cis-configure-network-policies-namespaces FAIL high
ocp4-cis-kubeadmin-removed FAIL medium
ocp4-cis-node-master-kubelet-enable-protect-kernel-defaults FAIL medium
ocp4-cis-node-master-kubelet-enable-protect-kernel-sysctl FAIL medium
ocp4-cis-node-worker-kubelet-enable-protect-kernel-defaults FAIL medium
ocp4-cis-node-worker-kubelet-enable-protect-kernel-sysctl FAIL medium
Xem một check cụ thể:
oc get compliancecheckresults -n openshift-compliance ocp4-cis-audit-log-forwarding-enabled -o yaml
apiVersion: compliance.openshift.io/v1alpha1
description: |-
Ensure that Audit Log Forwarding Is Enabled
OpenShift audit works at the API server level, logging all requests coming to the server. Audit is on by default and the best practice is to ship audit logs off the cluster for retention. The cluster-logging-operator is able to do this with the
ClusterLogForwarders
resource. The forementioned resource can be configured to logs to different third party systems. For more information on this, please reference the official documentation: https://docs.openshift.com/container-platform/4.6/logging/cluster-logging-external.html
id: xccdf_org.ssgproject.content_rule_audit_log_forwarding_enabled
instructions: |-
Run the following command:
oc get clusterlogforwarders instance -n openshift-logging -ojson | jq -r '.spec.pipelines[].inputRefs | contains(["audit"])'
The output should return true.
kind: ComplianceCheckResult
metadata:
annotations:
compliance.openshift.io/rule: audit-log-forwarding-enabled
creationTimestamp: "2023-03-31T10:51:02Z"
generation: 1
labels:
compliance.openshift.io/check-severity: medium
compliance.openshift.io/check-status: FAIL
compliance.openshift.io/scan-name: ocp4-cis
compliance.openshift.io/suite: cis-compliance
name: ocp4-cis-audit-log-forwarding-enabled
namespace: openshift-compliance
ownerReferences:
- apiVersion: compliance.openshift.io/v1alpha1
blockOwnerDeletion: true
controller: true
kind: ComplianceScan
name: ocp4-cis
uid: 9d5b10b8-f67c-44f3-b13d-0765cb037091
resourceVersion: "13034914"
uid: c5b7342d-af35-4944-86bd-8a4f907acccc
rationale: Retaining logs ensures the ability to go back in time to investigate or
correlate any events. Offloading audit logs from the cluster ensures that an attacker
that has access to the cluster will not be able to tamper with the logs because
of the logs being stored off-site.
severity: medium
status: FAIL
Ví dụ trên là ComplianceCheckResult, không phải bản thân đối tượng remediation. Một số kết quả có thể có remediation tự động, số khác cần xử lý thủ công. Xem hướng dẫn remediation và plugin oc-compliance; kiểm tra tác động trước khi áp dụng bất kỳ thay đổi nào.
Quét lỗ hổng image với Quay Container Security Operator
Quét image giúp tìm các lỗ hổng đã biết trong thành phần phần mềm. Kết quả phụ thuộc dữ liệu scanner, image và thời điểm quét; chữ ký image hoặc việc dùng registry tích hợp không tự chứng minh image không có lỗ hổng.
Theo nguồn, Red Hat Quay Container Security Operator theo dõi container trong các namespace được chọn, truy vấn thông tin lỗ hổng từ registry có hỗ trợ scan như Quay/Clair, và đưa kết quả vào đối tượng ImageManifestVuln. Các scanner khác, ví dụ Trivy, có thể được xem xét theo nhu cầu.
Cài đặt và xem kết quả
Trong giao diện Administrator của bài gốc, mở Operators > OperatorHub, tìm Red Hat Quay Container Security Operator, chọn cài đặt và xem lại phạm vi namespace cùng chiến lược phê duyệt. Sau khi cài, ô trạng thái hiển thị thông tin image vulnerability:

Chọn Administration > Image Vulnerabilities để lọc theo project:

Chọn image để xem manifest và các CVE:

Tab affected pods hiển thị Pod liên quan:

Bài gốc cũng dẫn đến báo cáo Quay cho image Pac-Man.

Liệt kê đối tượng lỗ hổng bằng CLI:
oc get vuln --all-namespaces
NAMESPACE NAME AGE
openshift-apiserver-operator sha256.01974e4c0e0d112e09bee8fe2625d565d3d62fa42013b38d7ce43d2d40f6057a 20h
openshift-apiserver sha256.13640b919950fc648219c528ee7ed30262bae856566fbd6c4cb5e15ffd457d6f 20h
openshift-apiserver sha256.8829aefa24dd606d2fe3ff86b97858c07acedae5f5eb3f044c20395762e7c02b 20h
openshift-authentication-operator sha256.31b617cec5c22e187cc22da606fc6998ea3529b1b6e8d80d1799c3dc9705997e 20h
openshift-authentication sha256.41e06255fc823c0082a74466b69ccfb672947b7075ea43a10e729c5f39314d00 20h
openshift-cloud-controller-manager-operator sha256.a7856b6371fc4a7ade8a678daca149db6c6a55ee7137d9e308721d2d3bebf364 20h
openshift-cloud-credential-operator sha256.1986315effe0f3ee415e86df3a87765268ed1da405c7a297c278e1d7030286a4 20h
...
openshift-vsphere-infra sha256.ddf81e535cf7a6b2775f3db690ec1e6eaa1c7427a0f9b98ce120d8ad06520440 20h
test-app sha256.196ae9a1a33a2d32046a46739779ca273667f1d4f231f8a721e8064c3509405e 20h
Xem chi tiết một đối tượng:
oc describe vuln -n {namespace} {sha ID of vuln}
# Example
oc describe vuln -n openshift-apiserver-operator sha256.01974e4c0e0d112e09bee8fe2625d565d3d62fa42013b38d7ce43d2d40f6057a
Output ví dụ:
Name: sha256.01974e4c0e0d112e09bee8fe2625d565d3d62fa42013b38d7ce43d2d40f6057a
Namespace: openshift-apiserver-operator
Labels: openshift-apiserver-operator/openshift-apiserver-operator-7bd84bd596-pgpct=true
Annotations: <none>
API Version: secscan.quay.redhat.com/v1alpha1
Kind: ImageManifestVuln
Metadata:
Creation Timestamp: 2023-03-30T19:01:40Z
Generation: 17
Resource Version: 13206497
UID: dbec02e5-e4c6-412f-b561-757237844d43
Spec:
Features:
Name: pip
Version: 9.0.3
Vulnerabilities:
Description: Pip 21.1 updates its dependency 'urllib3' to v1.26.4 due to security issues.
Metadata: {"UpdatedBy": "pyupio", "RepoName": "pypi", "RepoLink": "https://pypi.org/simple", "DistroName": "", "DistroVersion": "", "NVD": {"CVSSv3": {"Vectors": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N", "Score": 6.5}}}
Name: pyup.io-40291 (CVE-2021-28363)
Namespace Name: pyupio
Severity: Medium
Description: A flaw was found in python-pip in the way it handled Unicode separators in git references. A remote attacker could possibly use this issue to install a different revision on a repository. The highest threat from this vulnerability is to data integrity. This is fixed in python-pip version 21.1.
Metadata: {"UpdatedBy": "pyupio", "RepoName": "pypi", "RepoLink": "https://pypi.org/simple", "DistroName": "", "DistroVersion": "", "NVD": {"CVSSv3": {"Vectors": "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:H/A:N", "Score": 5.7}}}
Name: pyup.io-42559 (CVE-2021-3572)
Namespace Name: pyupio
Severity: Medium
Description: Pip before 19.2 allows Directory Traversal when a URL is given in an install command, because a Content-Disposition header can have ../ in a filename, as demonstrated by overwriting the /root/.ssh/authorized_keys file. This occurs in _download_http_url in _internal/download.py.
Metadata: {"UpdatedBy": "pyupio", "RepoName": "pypi", "RepoLink": "https://pypi.org/simple", "DistroName": "", "DistroVersion": "", "NVD": {"CVSSv3": {"Vectors": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N", "Score": 7.5}}}
Name: pyup.io-38765 (CVE-2019-20916)
Namespace Name: pyupio
Severity: High
Name: openssl-libs
Version: 1:1.1.1k-7.el8_6
Vulnerabilities:
Description: OpenSSL is a toolkit that implements the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols, as well as a full-strength general-purpose cryptography library.
Security Fix(es):
* openssl: X.400 address type confusion in X.509 GeneralName (CVE-2023-0286)
For more details about the security issue(s), including the impact, a CVSS score, acknowledgments, and other related information, refer to the CVE page(s) listed in the References section.
Fixedby: 1:1.1.1k-8.el8_6
Link: https://access.redhat.com/errata/RHSA-2023:1441 https://access.redhat.com/security/cve/CVE-2023-0286
Metadata: {"UpdatedBy": "RHEL8-rhel-8.6-eus", "RepoName": "cpe:/o:redhat:rhel_eus:8.6::baseos", "RepoLink": null, "DistroName": "Red Hat Enterprise Linux Server", "DistroVersion": "8", "NVD": {"CVSSv3": {"Vectors": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:H", "Score": 7.4}}}
Name: RHSA-2023:1441: openssl security update (Important)
Namespace Name: RHEL8-rhel-8.6-eus
Severity: High
Name: urllib3
Version: 1.24.2
Vulnerabilities:
Description: Urllib3 1.26.5 includes a fix for CVE-2021-33503: When provided with a URL containing many @ characters in the authority component, the authority regular expression exhibits catastrophic backtracking, causing a denial of service if a URL were passed as a parameter or redirected to via an HTTP redirect.
Metadata: {"UpdatedBy": "pyupio", "RepoName": "pypi", "RepoLink": "https://pypi.org/simple", "DistroName": "", "DistroVersion": "", "NVD": {"CVSSv3": {"Vectors": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "Score": 7.5}}}
Name: pyup.io-43975 (CVE-2021-33503)
Namespace Name: pyupio
Severity: High
Description: urllib3 before 1.25.9 allows CRLF injection if the attacker controls the HTTP request method, as demonstrated by inserting CR and LF control characters in the first argument of putrequest(). NOTE: this is similar to CVE-2020-26116.
Metadata: {"UpdatedBy": "pyupio", "RepoName": "pypi", "RepoLink": "https://pypi.org/simple", "DistroName": "", "DistroVersion": "", "NVD": {"CVSSv3": {"Vectors": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N", "Score": 7.2}}}
Name: pyup.io-38834 (CVE-2020-26137)
Namespace Name: pyupio
Severity: High
Name: setuptools
Version: 39.2.0
Vulnerabilities:
Description: Python Packaging Authority (PyPA) setuptools before 65.5.1 allows remote attackers to cause a denial of service via HTML in a crafted package or custom PackageIndex page. There is a Regular Expression Denial of Service (ReDoS) in package_index.py.
Metadata: {"UpdatedBy": "pyupio", "RepoName": "pypi", "RepoLink": "https://pypi.org/simple", "DistroName": "", "DistroVersion": "", "NVD": {"CVSSv3": {"Vectors": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H", "Score": 5.9}}}
Name: pyup.io-52495 (CVE-2022-40897)
Namespace Name: pyupio
Severity: Medium
Image: quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256
Manifest: sha256:01974e4c0e0d112e09bee8fe2625d565d3d62fa42013b38d7ce43d2d40f6057a
Status:
Affected Pods:
openshift-apiserver-operator/openshift-apiserver-operator-7bd84bd596-pgpct:
cri-o://dd4fcb700a95c041d19bf7829d3e07516ccf2a36522027f920d76ed0aa57f84c
Fixable Count: 1
High Count: 4
Highest Severity: High
Last Update: 2023-03-31 15:31:32.853602342 +0000 UTC
Medium Count: 3
Events: <none>
Các phiên bản và CVE trong output phản ánh thời điểm quét năm 2023; cần chạy scan mới và xác minh advisory khi đánh giá image hiện tại.
Tài liệu tham khảo
- OpenShift security and compliance
- Understanding container security
- Troubleshooting Compliance Operator
- Running Quay Container Security Operator
- Securing container content
- OpenShift security guide
- CVE và CVSS
Tóm tắt
Chúng ta đã xem cách đánh giá cấu hình với Compliance Operator và xem lỗ hổng image được registry cung cấp qua Quay Container Security Operator. Đến đây kết thúc phần OpenShift; bạn có thể đọc Ngày 63.
Bài viết được chuyển ngữ từ Day 62 — 90DaysOfDevOps 2023, thuộc dự án 90DaysOfDevOps; ghi công Michael Cade và các cộng tác viên. Bản tiếng Việt có hiệu đính, bổ sung ghi chú và được chia sẻ theo giấy phép Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International. Các ảnh minh họa được lấy từ bài gốc.