Skip to content

docs: add a security page to the public documentation - #512

Open
hossain-rayhan wants to merge 2 commits into
documentdb:mainfrom
hossain-rayhan:rayhan/security-doc
Open

hossain-rayhan wants to merge 2 commits into
documentdb:mainfrom
hossain-rayhan:rayhan/security-doc

Conversation

@hossain-rayhan

Copy link
Copy Markdown
Collaborator

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

  • Secure by default:
    • Gateway TLS is always on (SelfSigned by default, renewed by cert-manager).
    • SCRAM-SHA-256 username/password, with credentials passed to the gateway as Secret-referenced environment variables.
    • Hardened security contexts for PostgreSQL (CloudNativePG), the gateway and OTel sidecars, the operator and the plugins.
    • Mutual TLS between CloudNativePG and the plugins, and a dedicated monitoring role.
    • cosign-signed images, with a cosign verify command.
  • What the operator can access: a cluster-wide ClusterRole, with the reason for each sensitive permission: read-only Secrets, pods/exec, per-cluster ServiceAccount/Role/RoleBinding, nodes, PVs.
  • Hardening checklist: trusted certificates, verify-full replication TLS, network exposure and NetworkPolicies, Secret protection, storage and backup encryption, resource limits, Pod Security Admission, io_uring, patching.
  • Current limitations: no client mTLS, no operator-set minimum TLS version, no audit logging, tag-only image values, and no SBOM or provenance attestations.
  • Reporting: links to SECURITY.md instead 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: the documented cosign verify command passes for the released operator:1.1.1, sidecar:1.1.1, gateway:1.0.0, documentdb:1.0.0 and documentdb-combined:18-1.0.0 images.
  • Docs build: mkdocs build --strict passes using the deploy_docs.yml package 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.

Copilot AI balanced review requested due to automatic review settings November 13, 2026 18:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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. |

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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").

@documentdb-triage-tool documentdb-triage-tool Bot added the documentation Improvements or additions to documentation label Nov 13, 2026
@documentdb-triage-tool

Copy link
Copy Markdown

🤖 Auto-triaged by documentdb-triage-tool.

Applied: documentation
Project fields suggested: Component docs · Priority P2 · Effort M · Status Needs Review
Confidence: 0.95 (deterministic)

Reasoning

component from path globs (docs); effort from diff stats (77+0 LOC, 3 files)

If a label is wrong, ping @patty-chow so the rules can be tuned. Issues with component labels are left alone; PR component labels are reconciled from changed paths on every run.

hossain-rayhan and others added 2 commits November 16, 2026 10:50
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>

@xgerman xgerman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional copyedit from Microsoft Learn Authoring Assistant:

Suggested change
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). |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional copyedit from Microsoft Learn Authoring Assistant:

Suggested change
| **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. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional copyedit from Microsoft Learn Authoring Assistant:

Suggested change
| **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. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional copyedit from Microsoft Learn Authoring Assistant:

Suggested change
| **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):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional copyedit from Microsoft Learn Authoring Assistant:

Suggested change
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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional copyedit from Microsoft Learn Authoring Assistant:

Suggested change
- [ ] **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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional copyedit from Microsoft Learn Authoring Assistant:

Suggested change
- [ ] **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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional copyedit from Microsoft Learn Authoring Assistant:

Suggested change
- [ ] **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).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional copyedit from Microsoft Learn Authoring Assistant:

Suggested change
- [ ] **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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional copyedit from Microsoft Learn Authoring Assistant:

Suggested change
- 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants