Agent Wranglers

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

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.