Security and Compliance
Databases usually store the most valuable and sensitive data in an information system. Attacks and failures can therefore have severe consequences. Security requires multiple controls: who can connect, what they can do, and whether traffic is protected. It must also record operations and support recovery of damaged, lost, or deleted data.
Pigsty provides a default security baseline through declarative configuration. Declare HBA rules, roles and privileges, certificates, encryption, backups, and audit policies as parameters in the inventory. Idempotent playbooks render and apply these settings.
Security as Code supports policy versioning, review, and traceability. One inventory provides a consistent baseline across instances. To audit database access, start with the YAML declaration. Then verify generated HBA rules and database grants against the running system.
Security as Code
Manual operations can scatter security settings across pg_hba.conf, DBA-issued GRANT statements, and temporary incident firewall rules. Documentation can then diverge from the running configuration. This makes each instance’s effective rules difficult to determine.
Pigsty stores security policy in the cluster definition alongside other properties.
Declare users, privileges, and HBA rules. Playbooks apply them idempotently to each instance, including new instances. Git history records configuration changes. Manual GRANT statements, runtime parameter changes, and node file edits can still cause drift. In production, regularly compare declared and actual state.
Default Security Baseline
The default configuration enables these controls to reduce omissions:
| Capability | Default Behavior | Related Parameter |
|---|---|---|
| Password hashing | New or updated PostgreSQL passwords use SCRAM-SHA-256 | pg_pwd_enc |
| Data checksums | Page checksums are enabled during cluster initialization to detect silent corruption | pg_checksum |
| Server-side TLS | PostgreSQL server certificates are installed and ssl is enabled, so TLS connections are accepted | — |
| Local CA | A self-signed CA is created automatically for managed component certificates | ca_create |
| etcd encryption and authentication | TLS for client and peer traffic, plus RBAC password authentication | etcd_root_password |
| MINIO object storage HTTPS | Silo backup traffic uses HTTPS by default | minio_https |
| Nginx HTTPS | Web ingress listens on both ports 80 and 443 by default | nginx_sslmode |
| HBA rules | Layered access: local ident, intranet password authentication, and SSL required for public administrator access | pg_default_hba_rules |
| Roles and privileges | A four-tier role model and default privilege templates provide a least-privilege baseline | pg_default_roles |
| Backup and recovery | pgBackRest is enabled by default, with two full backups retained in the local repository | pgbackrest_enabled |
| Firewall | Zone mode trusts intranet CIDRs and exposes only required ports to public networks | node_firewall_mode |
| Restricted sudo | Sudo access for the database OS user is limited to the required command set | pg_dbsu_sudo |
Hardening with Trade-offs
Defaults target a trusted intranet. Some controls need explicit enablement because of performance costs, compatibility limits, or required operator decisions:
- Examples contain public default passwords for quick starts and local tests. Before production, run
./configure -gto randomize recognized credentials. Then check the pgBackRest passphrase, Silo users inha/safe, and all custom values. - The Patroni REST API and PgBouncer disable TLS by default. Explicitly enable
patroni_ssl_enabledandpgbouncer_sslmodewith the issued certificates. - Password checks (
passwordcheck) and auditing (pgaudit) are disabled by default. Confirm package availability, then configure preloading and policy. - SELinux defaults to
permissive. Remove the demo firewall exception for port5432in production. - Local backups have no encryption by default. The remote
miniopreset enables AES-256 encryption. Change its default encryption passphrase.
The ha/safe template combines TLS, certificate authentication, password checks, and backup encryption. Use it with the consistency-first CRIT parameter template as a starting point. Review public credentials, audit extensions, and the failure model explicitly. See Security Model for the full hardening path.
This Chapter
| Section | Question Answered |
|---|---|
| Security Model | Where is the root of trust? How many defensive layers exist? How should the baseline be hardened? |
| Authentication | Who can connect? How is identity proven? How are HBA rules declared and applied? |
| Access Control | What can a connected user do? How does least privilege become the default? |
| Encrypted Communication | How is traffic encrypted? Who issues, distributes, and rotates certificates? |
| Data Security | How is data kept intact, recoverable, confidential, and traceable? |
| Compliance | How do security capabilities map to MLPS and SOC 2 controls? |
Related Topics
These pages provide operational security guidance:
- 🔰 Security Recommendations: minimum hardening for a quick single-node deployment
- 🛡️ Security Considerations: production hardening checklist
- 📄
ha/safeTemplate: complete hardening configuration reference - 🔑 HBA Rules: detailed PGSQL HBA configuration
- 👤 Access Control: role and privilege parameter reference
- ♾️ High Availability: business continuity
- ⏰ Backup and Recovery: PITR and disaster recovery
Pigsty trust boundaries and defense in depth, with the admin node as a high-trust control plane and a path from the default baseline to production hardening.
Pigsty manages PostgreSQL and PgBouncer HBA rules declaratively, combining SCRAM passwords and client certificates to define who may connect and how identity is proven.
Pigsty turns least privilege into reusable declarative cluster configuration through a built-in four-tier role model and default privilege templates.
Pigsty provides a self-signed CA that issues certificates and distributes trust for managed components, creating a unified TLS foundation.
Protect PostgreSQL data integrity, recoverability, confidentiality, and traceability with checksums, backup and PITR, encryption, and audit logs.
Compliance combines configuration, process, and evidence. This page covers launch hardening, MLPS and SOC 2 control mappings, supply-chain integrity, and vulnerability response.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)