From 797ac6bb0f56602ffca02df744f0058a18eaf4c0 Mon Sep 17 00:00:00 2001 From: Rayhan Hossain Date: Fri, 13 Nov 2026 10:39:59 -0800 Subject: [PATCH 1/2] docs: add a security page to the public documentation Add a single, short Security page (v1/security.md) checked against the current code: secure defaults (always-on gateway TLS, SCRAM credentials from Secret references, hardened security contexts, plugin mTLS, signed images with a verify command), the operator's cluster-wide permissions and why it needs them, a production hardening checklist, current limitations, and how to report vulnerabilities. Link it from the nav and the docs home page. Supersedes the March draft in #301, which predates the v1 docs move and claimed features the operator doesn't have (read-only root filesystems everywhere, TLS 1.2 minimum, client mTLS, Helm-installed user roles). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9f1a71b4-9969-4456-9f65-8d19dd550d8e Signed-off-by: Rayhan Hossain --- .../operator-public-documentation/v1/index.md | 4 ++ .../v1/security.md | 72 +++++++++++++++++++ mkdocs.yml | 1 + 3 files changed, 77 insertions(+) create mode 100644 docs/operator-public-documentation/v1/security.md diff --git a/docs/operator-public-documentation/v1/index.md b/docs/operator-public-documentation/v1/index.md index 3b7a53353..79dfec51c 100644 --- a/docs/operator-public-documentation/v1/index.md +++ b/docs/operator-public-documentation/v1/index.md @@ -368,6 +368,10 @@ switched to db sample_mflix ## Configuration and advanced topics +### Security + +TLS is always on and pods run with hardened security contexts by default. For the operator's permissions and a production hardening checklist, see [Security](security.md). + ### Sidecar injector plugin configuration The operator uses a sidecar injector plugin to automatically inject the DocumentDB Gateway container into PostgreSQL pods. You can customize the gateway image, pod labels, and annotations. diff --git a/docs/operator-public-documentation/v1/security.md b/docs/operator-public-documentation/v1/security.md new file mode 100644 index 000000000..1c9ff071d --- /dev/null +++ b/docs/operator-public-documentation/v1/security.md @@ -0,0 +1,72 @@ +--- +title: Security +description: Security defaults, operator permissions, and a hardening checklist for DocumentDB clusters managed by the DocumentDB Kubernetes Operator. +tags: + - security + - tls + - rbac +--- + +# Security + +This page summarizes what the operator secures for you, what it needs access to, and what you should configure for production. Kubernetes cluster security (API server access, etcd encryption, node hardening) remains your responsibility. + +## Secure by default + +| Area | Default behavior | +|------|------------------| +| **Client encryption** | The gateway always uses TLS; it cannot be turned off. `spec.tls.gateway.mode` defaults to `SelfSigned`, a cert-manager certificate that is renewed automatically. See [TLS](configuration/tls.md). | +| **Client authentication** | Username and password over SCRAM-SHA-256. Credentials come from the Secret in `spec.documentDbCredentialSecret` (keys `username` and `password`) and reach the gateway as Secret-referenced environment variables, not command-line arguments. | +| **Database pods** | PostgreSQL containers use CloudNativePG's security context: non-root, read-only root filesystem, no privilege escalation, all capabilities dropped, `RuntimeDefault` seccomp. | +| **Gateway and OTel sidecars** | Non-root, no privilege escalation, all capabilities dropped, `RuntimeDefault` seccomp. | +| **Operator and plugins** | Non-root, no privilege escalation, all capabilities dropped, `RuntimeDefault` seccomp. | +| **Internal traffic** | CloudNativePG reaches the sidecar-injector and WAL-replica plugins over gRPC with mutual TLS. The validating webhook serves a cert-manager certificate. | +| **Monitoring** | When monitoring is enabled, the OTel Collector logs in as a dedicated role that is not a superuser and has no extra role memberships. | +| **Images** | Operator, sidecar, DocumentDB, gateway and combined images are signed with [cosign](https://docs.sigstore.dev/) keyless signing from this repository's GitHub Actions workflows. | + +To verify an image signature (replace `operator:` with any of the images above): + +```bash +cosign verify \ + --certificate-identity-regexp '^https://github.com/documentdb/documentdb-kubernetes-operator/\.github/workflows/' \ + --certificate-oidc-issuer https://token.actions.githubusercontent.com \ + ghcr.io/documentdb/documentdb-kubernetes-operator/operator: +``` + +## What the operator can access + +The operator runs with a **cluster-wide** `ClusterRole`; it can't be limited to specific namespaces. Notable permissions: + +| Permission | Why | +|------------|-----| +| `secrets`: `get`, `list`, `watch` (all namespaces) | Read credential and TLS Secrets. The operator never writes Secrets. | +| `pods/exec`: `create` | Run `psql` in the primary pod to upgrade the DocumentDB extension and grant the replication role. | +| `serviceaccounts`, `roles`, `rolebindings` | Create a ServiceAccount, Role and RoleBinding for each DocumentDB cluster. | +| `nodes`: `get`, `list` | Detect the container runtime to choose the image mode. | +| `persistentvolumes`: `update`, `patch` | Apply the reclaim policy and record schema-version annotations on volumes. | + +Treat the operator namespace (`documentdb-operator`) and the CloudNativePG namespace (`cnpg-system`) as privileged: limit who can create pods, read Secrets or exec in them. + +## Hardening checklist + +- [ ] **Use a trusted certificate.** In production, set `spec.tls.gateway.mode` to `CertManager` or `Provided` and have clients verify the server certificate instead of passing `tlsAllowInvalidCertificates=true`. See [TLS](configuration/tls.md). +- [ ] **Encrypt replication across clusters.** For multi-region deployments, set all four `spec.tls.postgres` Secrets (`replicationTLSSecret`, `clientCASecret`, `serverTLSSecret` and `serverCASecret`) so cross-cluster replication verifies the server with `sslmode=verify-full`. See [Multi-region setup](multi-region-deployment/setup.md) and [PostgreSQL certificates](configuration/tls.md#postgresql-certificates). +- [ ] **Limit network exposure.** Prefer `serviceType: ClusterIP`. A `LoadBalancer` Service may be reachable from outside the cluster; restrict it with your cloud provider's firewall or load balancer settings. The operator doesn't create NetworkPolicies; see [Network Policies](configuration/networking.md#network-policies) for the traffic to allow. +- [ ] **Protect credentials.** Use a strong password, enable [encryption at rest for Secrets](https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/), and restrict `get`/`list` on Secrets in DocumentDB namespaces. Consider syncing the credential Secret from an external secret store. The Secret name can't be changed after the cluster is created. +- [ ] **Encrypt storage.** Encryption at rest and backup encryption come from your StorageClass and CSI driver; backups are VolumeSnapshots of the same volumes. Use an encrypted StorageClass and VolumeSnapshotClass. +- [ ] **Set resource limits.** The operator and plugin Deployments set CPU and memory requests only. Add limits with the Helm values `operator.resources`, `sidecarInjector.resources` and `walReplicaPlugin.resources` if your policies require them. +- [ ] **Enforce Pod Security Admission.** The chart doesn't label namespaces. Add `pod-security.kubernetes.io/warn: restricted` to DocumentDB namespaces first to find violations, then enforce the level your policy requires. +- [ ] **Enable io_uring only when needed.** The opt-in `IOUring` feature gate switches PostgreSQL pods to a `Localhost` seccomp profile that also allows `io_uring_setup`, `io_uring_enter` and `io_uring_register`. See [io_uring](../io-uring.md). +- [ ] **Keep up to date.** Apply operator patch releases and keep cert-manager on a supported, patched version. + +## Current limitations + +- No certificate-based (mutual TLS) client authentication; clients authenticate with username and password. +- The operator doesn't configure a minimum TLS version or cipher suites for the gateway. +- No database audit logging. Use Kubernetes audit logs and the events the operator records on DocumentDB resources. +- Helm image values accept tags, not digests. +- Release images are signed but don't include SBOMs or provenance attestations. + +## Reporting a vulnerability + +Don't report security vulnerabilities in public GitHub issues. Follow the private reporting process in [SECURITY.md](https://github.com/documentdb/documentdb-kubernetes-operator/blob/main/SECURITY.md). diff --git a/mkdocs.yml b/mkdocs.yml index 5de95e555..325df65cc 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -48,6 +48,7 @@ nav: - TLS: v1/configuration/tls.md - PostgreSQL Tuning: postgresql-tuning.md - io_uring Async I/O: io-uring.md + - Security: v1/security.md - Operations: - Upgrades: v1/operations/upgrades.md - Failover: v1/operations/failover.md From 18394fbc7bba174982a36b9ec539b57bc924ec33 Mon Sep 17 00:00:00 2001 From: Rayhan Hossain Date: Mon, 16 Nov 2026 10:51:10 -0800 Subject: [PATCH 2/2] docs: address review feedback on the security page - Describe only the sidecar-injector plugin connection; the WAL-replica plugin is not deployable yet (the chart refuses walReplica: true). - Include watch with get and list when restricting Secret access, since watch also returns Secret data. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9f1a71b4-9969-4456-9f65-8d19dd550d8e Signed-off-by: Rayhan Hossain --- docs/operator-public-documentation/v1/security.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/operator-public-documentation/v1/security.md b/docs/operator-public-documentation/v1/security.md index 1c9ff071d..dcdf80c1c 100644 --- a/docs/operator-public-documentation/v1/security.md +++ b/docs/operator-public-documentation/v1/security.md @@ -20,7 +20,7 @@ This page summarizes what the operator secures for you, what it needs access to, | **Database pods** | PostgreSQL containers use CloudNativePG's security context: non-root, read-only root filesystem, no privilege escalation, all capabilities dropped, `RuntimeDefault` seccomp. | | **Gateway and OTel sidecars** | Non-root, no privilege escalation, all capabilities dropped, `RuntimeDefault` seccomp. | | **Operator and plugins** | Non-root, no privilege escalation, all capabilities dropped, `RuntimeDefault` seccomp. | -| **Internal traffic** | CloudNativePG reaches the sidecar-injector and WAL-replica plugins over gRPC with mutual TLS. The validating webhook serves a cert-manager certificate. | +| **Internal traffic** | CloudNativePG reaches the sidecar-injector plugin over gRPC with mutual TLS. The validating webhook serves a cert-manager certificate. | | **Monitoring** | When monitoring is enabled, the OTel Collector logs in as a dedicated role that is not a superuser and has no extra role memberships. | | **Images** | Operator, sidecar, DocumentDB, gateway and combined images are signed with [cosign](https://docs.sigstore.dev/) keyless signing from this repository's GitHub Actions workflows. | @@ -45,14 +45,14 @@ The operator runs with a **cluster-wide** `ClusterRole`; it can't be limited to | `nodes`: `get`, `list` | Detect the container runtime to choose the image mode. | | `persistentvolumes`: `update`, `patch` | Apply the reclaim policy and record schema-version annotations on volumes. | -Treat the operator namespace (`documentdb-operator`) and the CloudNativePG namespace (`cnpg-system`) as privileged: limit who can create pods, read Secrets or exec in them. +Treat the operator namespace (`documentdb-operator`) and the CloudNativePG namespace (`cnpg-system`) as privileged: limit who can create pods, read or watch Secrets, or exec in them. ## Hardening checklist - [ ] **Use a trusted certificate.** In production, set `spec.tls.gateway.mode` to `CertManager` or `Provided` and have clients verify the server certificate instead of passing `tlsAllowInvalidCertificates=true`. See [TLS](configuration/tls.md). - [ ] **Encrypt replication across clusters.** For multi-region deployments, set all four `spec.tls.postgres` Secrets (`replicationTLSSecret`, `clientCASecret`, `serverTLSSecret` and `serverCASecret`) so cross-cluster replication verifies the server with `sslmode=verify-full`. See [Multi-region setup](multi-region-deployment/setup.md) and [PostgreSQL certificates](configuration/tls.md#postgresql-certificates). - [ ] **Limit network exposure.** Prefer `serviceType: ClusterIP`. A `LoadBalancer` Service may be reachable from outside the cluster; restrict it with your cloud provider's firewall or load balancer settings. The operator doesn't create NetworkPolicies; see [Network Policies](configuration/networking.md#network-policies) for the traffic to allow. -- [ ] **Protect credentials.** Use a strong password, enable [encryption at rest for Secrets](https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/), and restrict `get`/`list` on Secrets in DocumentDB namespaces. Consider syncing the credential Secret from an external secret store. The Secret name can't be changed after the cluster is created. +- [ ] **Protect credentials.** Use a strong password, enable [encryption at rest for Secrets](https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/), and restrict `get`, `list` and `watch` on Secrets in DocumentDB namespaces (`watch` also returns Secret data). Consider syncing the credential Secret from an external secret store. The Secret name can't be changed after the cluster is created. - [ ] **Encrypt storage.** Encryption at rest and backup encryption come from your StorageClass and CSI driver; backups are VolumeSnapshots of the same volumes. Use an encrypted StorageClass and VolumeSnapshotClass. - [ ] **Set resource limits.** The operator and plugin Deployments set CPU and memory requests only. Add limits with the Helm values `operator.resources`, `sidecarInjector.resources` and `walReplicaPlugin.resources` if your policies require them. - [ ] **Enforce Pod Security Admission.** The chart doesn't label namespaces. Add `pod-security.kubernetes.io/warn: restricted` to DocumentDB namespaces first to find violations, then enforce the level your policy requires.