Harden securityContext on the bundled postgres StatefulSet

Abierto Apto para principiantes
#4,171 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
77/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go, kubernetes, yaml

Línea de trabajo

Empieza con manifests/ate-install/postgres/postgres.yaml y revisa los contextos de seguridad de los contenedores postgres y tls-reloader junto con el fsGroup existente a nivel de pod. Añade las restricciones solicitadas y conserva la configuración de identidad compatible con TLS del contenedor postgres; después, revisa pod-certificate-controller.yaml para localizar la capacidad NET_BIND_SERVICE no utilizada. El trabajo estará terminado cuando las restricciones solicitadas para los contenedores y la eliminación de la capacidad estén reflejadas en los manifests.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Go
Estrellas
8.7k
Forks
969
Merge medio
5 d 1 h
PR fusionados (30 d)
128

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de agent-substrate/substrate

Todos los issues de agent-substrate/substrate

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.