Repository navigation
docs: add a security page to the public documentation - #512
hossain-rayhan wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The security documentation omits watch from Secret permissions to restrict, leaving a credential-disclosure path, and incorrectly presents the unavailable WAL-replica plugin as an active secured traffic path.
2 open issues
What changed in this PR
Adds a concise Security page to the operator’s public v1 documentation, replacing the broader approach proposed in #301 with guidance grounded in current behavior.
Changes:
- Documents security defaults, operator permissions, and current limitations.
- Provides a production hardening checklist and links to private vulnerability reporting.
- Links the page from the navigation and documentation home page.
| File | Description |
|---|---|
mkdocs.yml |
Adds Security after Configuration in the navigation. |
docs/operator-public-documentation/v1/security.md |
Adds security guidance and a hardening checklist. |
docs/operator-public-documentation/v1/index.md |
Introduces and links to the Security page. |
Review effort: Balanced
| | **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. | |
There was a problem hiding this comment.
Agreed, fixed in 18394fb. The internal-traffic row now describes only the sidecar-injector connection; the WAL-replica plugin isn't deployable yet (00_preflight.yaml refuses walReplica: true).
| - [ ] **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. |
There was a problem hiding this comment.
Good point, fixed in 18394fb. The checklist now says to restrict get, list and watch on Secrets and notes that watch also returns Secret data. I made the same change to the operator-namespace guidance ("read or watch Secrets").
|
🤖 Auto-triaged by documentdb-triage-tool. Applied: Reasoningcomponent from path globs (docs); effort from diff stats (77+0 LOC, 3 files) If a label is wrong, ping |
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 documentdb#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 <hossain.rayhan@outlook.com>
- 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 <hossain.rayhan@outlook.com>
b3535fe to
18394fb
Compare
xgerman
left a comment
There was a problem hiding this comment.
Converted the supplied Microsoft Learn Authoring Assistant edits into 13 optional inline copyedit suggestions. These are editorial suggestions, not blocking findings. Omitted the final proposed edit because it introduces a stray quote into the SECURITY.md URL and breaks the link.
|
|
||
| # 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. |
There was a problem hiding this comment.
Optional copyedit from Microsoft Learn Authoring Assistant:
| 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. | |
| This article 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. |
|
|
||
| | 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). | |
There was a problem hiding this comment.
Optional copyedit from Microsoft Learn Authoring Assistant:
| | **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 encryption** | The gateway always uses TLS; it can't be turned off. `spec.tls.gateway.mode` defaults to `SelfSigned`, a cert-manager certificate that renews automatically. See [TLS](configuration/tls.md). | |
| | **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 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. | |
There was a problem hiding this comment.
Optional copyedit from Microsoft Learn Authoring Assistant:
| | **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. | | |
| | **Monitoring** | When monitoring is enabled, the OTel Collector signs in as a dedicated role that isn't a superuser and has no extra role memberships. | |
| | **Operator and plugins** | Non-root, no privilege escalation, all capabilities dropped, `RuntimeDefault` seccomp. | | ||
| | **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. | |
There was a problem hiding this comment.
Optional copyedit from Microsoft Learn Authoring Assistant:
| | **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. | | |
| | **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. | |
| | **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:<version>` with any of the images above): |
There was a problem hiding this comment.
Optional copyedit from Microsoft Learn Authoring Assistant:
| To verify an image signature (replace `operator:<version>` with any of the images above): | |
| To verify an image signature, replace `operator:<version>` with any of the preceding images: |
|
|
||
| - [ ] **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. |
There was a problem hiding this comment.
Optional copyedit from Microsoft Learn Authoring Assistant:
| - [ ] **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. | |
| - [ ] **Limit network exposure.** Prefer `serviceType: ClusterIP`. A `LoadBalancer` Service might 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. |
| - [ ] **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` 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. |
There was a problem hiding this comment.
Optional copyedit from Microsoft Learn Authoring Assistant:
| - [ ] **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. | |
| - [ ] **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. You can't change the Secret name after the cluster is created. |
| - [ ] **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` 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. |
There was a problem hiding this comment.
Optional copyedit from Microsoft Learn Authoring Assistant:
| - [ ] **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. | |
| - [ ] **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. |
| - [ ] **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). |
There was a problem hiding this comment.
Optional copyedit from Microsoft Learn Authoring Assistant:
| - [ ] **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). | |
| - [ ] **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). |
|
|
||
| ## Current limitations | ||
|
|
||
| - No certificate-based (mutual TLS) client authentication; clients authenticate with username and password. |
There was a problem hiding this comment.
Optional copyedit from Microsoft Learn Authoring Assistant:
| - No certificate-based (mutual TLS) client authentication; clients authenticate with username and password. | |
| - No certificate-based (mutual TLS) client authentication; clients authenticate by using a username and password. |

Summary
Adds one short Security page,
docs/operator-public-documentation/v1/security.md. It's linked in the nav (after Configuration) and from the docs home page under "Configuration and advanced topics". This supersedes the March draft in #301.Page contents
SelfSignedby default, renewed by cert-manager).cosign verifycommand.pods/exec, per-cluster ServiceAccount/Role/RoleBinding, nodes, PVs.verify-fullreplication TLS, network exposure and NetworkPolicies, Secret protection, storage and backup encryption, resource limits, Pod Security Admission, io_uring, patching.SECURITY.mdinstead of copying contact details.Verification
Every statement was checked against the current code on
main, including the Helm templates,values.yaml, API types, the sidecar injector,internal/cnpg, the RBAC ClusterRole, the release workflows, and the CloudNativePG v1.29.2 module for the PostgreSQL container security context.cosign verifycommand passes for the releasedoperator:1.1.1,sidecar:1.1.1,gateway:1.0.0,documentdb:1.0.0anddocumentdb-combined:18-1.0.0images.mkdocs build --strictpasses using thedeploy_docs.ymlpackage pins. The new page renders, and its nav and index links resolve.Claims in #301 that are not true in current code, and so were left out: a read-only root filesystem on every container (only PostgreSQL has one), distroless images everywhere, CPU/memory limits by default, TLS 1.2+ enforcement, mutual TLS client authentication, Helm-installed admin/editor/viewer roles, and "least-privilege" cluster roles.