Harden securityContext on the bundled postgres StatefulSet

Đang mở Phù hợp với người mới
#4,171 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
77/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go, kubernetes, yaml

Hướng nghiên cứu

Bắt đầu với manifests/ate-install/postgres/postgres.yaml và kiểm tra các security context của container postgres và tls-reloader cùng với fsGroup hiện có ở cấp pod. Thêm các hạn chế được yêu cầu, đồng thời giữ nguyên các thiết lập danh tính tương thích với TLS của container postgres; sau đó kiểm tra pod-certificate-controller.yaml để tìm capability NET_BIND_SERVICE không được sử dụng. Hoàn tất khi các hạn chế container được yêu cầu và việc dọn dẹp capability được thể hiện trong các manifest.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area/security kind/feature

The default install StatefulSet in manifests/ate-install/postgres/postgres.yaml already sets a careful pod-level fsGroup: 70 and documents why the postgres container must not pin runAsUser: pinning it would make the projected TLS key group-readable, and PostgreSQL would refuse to start.

The main postgres container still has no container securityContext at all, and the tls-reloader sidecar only sets runAsUser: 70:

https://github.com/agent-substrate/substrate/blob/7319f1afa2ac90c8224117463f13f7bf782f63ac/manifests/ate-install/postgres/postgres.yaml#L122-L127

https://github.com/agent-substrate/substrate/blob/7319f1afa2ac90c8224117463f13f7bf782f63ac/manifests/ate-install/postgres/postgres.yaml#L149-L151

That leaves allowPrivilegeEscalation at the Kubernetes default (true), does not drop capabilities (including NET_RAW), and does not set runAsNonRoot. The official postgres:18-alpine image already runs as UID 70, so runAsNonRoot: true without runAsUser on the main container should be compatible with the TLS constraint above.

This is leftover install hardening after #2936 / #3028, which covered the Substrate control-plane pods but not the bundled database. Authentication for that database is already in good shape (client certificates, hostssl ... cert, and a NetworkPolicy that admits only ate-api-server). This request is only about the pod security context.

Suggested container securityContext:

For postgres (do not set runAsUser):

securityContext:
  allowPrivilegeEscalation: false
  runAsNonRoot: true
  capabilities:
    drop:
    - ALL

For tls-reloader, keep runAsUser: 70 and add the same allowPrivilegeEscalation: false, runAsNonRoot: true, and capabilities.drop: [ALL].

Optional: seccompProfile: {type: RuntimeDefault} on the pod or containers.

Related: unused NET_BIND_SERVICE on podcertificate-controller

ate-api-server correctly keeps NET_BIND_SERVICE because it binds :443. The same capability is still set on podcertificate-controller:

https://github.com/agent-substrate/substrate/blob/7319f1afa2ac90c8224117463f13f7bf782f63ac/manifests/ate-install/pod-certificate-controller.yaml#L179-L187

cmd/podcertcontroller is a kube-apiserver client; it does not listen on a privileged port (or any port). Dropping the add list would leave drop: [ALL] only.

Found with Rustmaninoff (https://github.com/jose-compu/rustmaninoff), a Checkov-compatible IaC scanner; check IDs CKV_K8S_20, CKV_K8S_23, CKV_K8S_28, and CKV_K8S_25.

Ngôn ngữ chính
Go
Star
8.7k
Fork
969
Merge trung bình
5 ngày 1 giờ
Pull request đã merge (30 ngày)
128

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của agent-substrate/substrate

Tất cả issue của agent-substrate/substrate

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.