INF-33Required
Force encryption on every managed service
Configure every database, cache and bucket to refuse plain connections. Make every client check the server's certificate.
How to do it
Encrypting traffic between your own servers is required by encrypt data. This rule enforces it on the server side. Set the service's own switch, such as rds.force_ssl for PostgreSQL on RDS or transit encryption on a Redis cache. Newer engines often turn it on by default, so set it in code anyway. Give buckets a policy that denies any request where aws:SecureTransport is false. On the client, use the provider's certificate bundle and full verification, such as sslmode=verify-full. A hosted database with a public address by design, such as Supabase or Neon, has the same switch, such as Supabase's SSL enforcement. When the app connects from fixed addresses, also turn on the host's network restrictions, so only those addresses reach the database port. Those restrictions do not cover the host's HTTPS data API, so row-level rules guard that path, as Keep each customer's data apart says.
Examples
Terraform example
resource "aws_db_parameter_group" "orders" {
family = "postgres17"
parameter {
name = "rds.force_ssl"
value = "1"
}
}
JavaScript example
import pg from 'pg';
import { readFileSync } from 'node:fs';
const pool = new pg.Pool({
connectionString: process.env.DATABASE_URL,
ssl: { ca: readFileSync('/etc/ssl/certs/rds-global-bundle.pem', 'utf8'), rejectUnauthorized: true },
});
Python example
import os
import psycopg
conn = psycopg.connect(os.environ["DATABASE_URL"], sslmode="verify-full", sslrootcert="/etc/ssl/certs/rds-global-bundle.pem")
Shell example
psql "host=orders.internal.example.com dbname=shop sslmode=disable" -c 'select 1' # must fail
How to check
A database connection without TLS is refused. A client given a wrong host name fails the certificate check. A bucket request over plain HTTP gets 403.
Sources
Related rules
- DAT-66 Log in to the database with SCRAM instead of MD5 in Data and databases
- DAT-80 Encrypt database storage with a key you control in Data and databases
- APS-54 Encrypt data on the wire and on disk in Application security
- DAT-7 Keep each customer's data apart in Data and databases
- STK-58 Use Let's Encrypt for TLS certificates in Software choices
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/infrastructure/networking-and-dns/enforce-tls-on-services">Agent Wranglers infrastructure and environments playbook</a>. In code you write, add a comment next to it with the same link.