postgres-hardening

postgres-hardening is a skill for Claude Code, Codex from GoldenWing-360/claude-security-skills. It costs 86 tokens per session (2,381 once invoked), scanned A, original, MIT.

A practical security checklist for PostgreSQL, a database commonly used by web applications, whether it runs on your own server or through a managed provider.

In plain words
What is it for?
Use it when provisioning or inheriting PostgreSQL, adding an application, securing multi-tenant data, responding to an advisory, or planning a major-version upgrade.
Why use it?
It helps close common database exposure and access-control gaps, including public network access, overly broad roles, cross-tenant data access, weak backups, and missing audit logs.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when provisioning or inheriting PostgreSQL, adding an application, securing multi-tenant data, responding to an advisory, or planning a major-version upgrade.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/goldenwing-360/claude-security-skills/postgres-hardening
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add GoldenWing-360/claude-security-skills --skill postgres-hardening
Clone the repo
git clone --depth 1 https://github.com/GoldenWing-360/claude-security-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for postgres-hardening

README.md
[![agentmods](https://agentmods.dev/badge/skills/goldenwing-360/claude-security-skills/postgres-hardening/github.svg)](https://agentmods.dev/skills/goldenwing-360/claude-security-skills/postgres-hardening)
Your own site
<a href="https://agentmods.dev/skills/goldenwing-360/claude-security-skills/postgres-hardening"><img src="https://agentmods.dev/badge/skills/goldenwing-360/claude-security-skills/postgres-hardening/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for postgres-hardening

Your own site · 80×15
<a href="https://agentmods.dev/skills/goldenwing-360/claude-security-skills/postgres-hardening"><img src="https://agentmods.dev/badge/skills/goldenwing-360/claude-security-skills/postgres-hardening.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 86 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,381 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00086 $0.02381
Opus 5 $0.00043 $0.01190
Sonnet 5 $0.00017 $0.00476
Haiku 4.5 $0.00009 $0.00238

Measured 11d ago against content hash dbb6381554d6, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

postgres-hardening scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootlowPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

sudo ss -tlnp | grep 5432

Downgraded: this mod is about security review, or the phrase is quoted, so it is likely naming the pattern rather than instructing it.

postgres-hardening/SKILL.md · 246 lines

How it starts

The opening of the file, as written. The whole thing — 246 lines — stays where its author put it; the contents beside it link to each section on GitHub.

PostgreSQL Hardening

A practical baseline for a single Postgres instance (self-hosted or managed) that backs a web app. Skews toward small-team realities — not a regulated-environment DBA's playbook.

When to invoke

  • New Postgres provisioned (Docker, package, RDS, Supabase, Neon — same threat model)
  • Inheriting an existing Postgres with no documented hardening
  • Adding a new application or service that connects to an existing Postgres
  • After a Postgres security advisory
  • Reviewing a multi-tenant schema where one tenant should not see another's data
  • Planning a major-version upgrade (14 → 15 → 16 → 17)

Step 1 — Network reachability

Postgres listening on 0.0.0.0:5432 open to the internet is one of the most common misconfigurations in shared/cloud environments.

# What is the listener bound to?
sudo ss -tlnp | grep 5432

# From outside the VPS — can the world reach it? (this should fail)
nc -zv <vps-ip> 5432

Acceptable bindings:

  • 127.0.0.1 only — app on same host, no remote access (best for single-VPS deployments)
  • VPC-internal IP only — apps in same private network
  • Public IP only with TLS-required + IP allowlist at firewall — last resort, document why

In postgresql.conf:

listen_addresses = 'localhost'        # or 'localhost,10.0.0.5' for private LAN
port = 5432

Restart Postgres after change.

Step 2 — pg_hba.conf (host-based auth)

This file is the primary access-control surface. Order matters: the first matching rule wins.

# TYPE    DATABASE        USER            ADDRESS         METHOD

# Local Unix socket — for admin tasks
local     all             postgres                        peer
local     all             all                             scram-sha-256

# App connections from same host
host      app_db          app_user        127.0.0.1/32    scram-sha-256
host      app_db          app_user        ::1/128         scram-sha-256

# Private LAN, TLS required
hostssl   app_db          app_user        10.0.0.0/24     scram-sha-256

# Read-only analytics user, scoped
hostssl   app_db          readonly_user   10.0.0.0/24     scram-sha-256

# Catch-all reject — explicit deny at the end
host      all             all             0.0.0.0/0       reject
host      all             all             ::/0            reject

Read the full file on GitHub · 246 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 246 lines · 86 tokens per session scan A dbb6381554d6

Subscribe to this mod's changes

postgres-hardening is a skill published in the GitHub repository GoldenWing-360/claude-security-skills (17 stars, last pushed 1mo ago), licensed MIT. It adds 86 tokens to every session and 2,381 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 1 finding (asks for root). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

database-optimizer

Optimizes database queries and improves performance across PostgreSQL and MySQL systems. Use when investigating slow queries, analyzing execution plans, or optimizing database performance. Invoke for index design, query rewrites, configuration tuning, partitioning strategies, lock contention resolution.

Jeffallan/claude-skills · 54 tokens

postgres-pro

Use when optimizing PostgreSQL queries, configuring replication, or implementing advanced database features. Invoke for EXPLAIN analysis, JSONB operations, extension usage, VACUUM tuning, performance monitoring.

Jeffallan/claude-skills · 41 tokens

postgres-database-migration

Use this skill for planning, testing, and safely executing PostgreSQL schema migrations — especially when working with production data or shared databases. Trigger when user asks to: Test a schema migration before applying it to production Add, remove, or rename columns safely on a live table Change a column's data…

timescale/pg-aiguide · 220 tokens

setup-timescaledb-hypertables

Use this skill when creating database schemas or tables for Timescale, TimescaleDB, TigerData, or Tiger Cloud, especially for time-series, IoT, metrics, events, or log data. Use this to improve the performance of any insert-heavy table. Trigger when user asks to: Create or design SQL schemas/tables AND…

timescale/pg-aiguide · 219 tokens

design-postgis-tables

Comprehensive PostGIS spatial table design reference covering geometry types, coordinate systems, spatial indexing, and performance patterns for location-based applications.

timescale/pg-aiguide · 31 tokens

migrate-postgres-tables-to-hypertables

Use this skill to migrate identified PostgreSQL tables to Timescale/TimescaleDB hypertables with optimal configuration and validation. Trigger when user asks to: Migrate or convert PostgreSQL tables to hypertables Execute hypertable migration with minimal downtime Plan blue-green migration for large tables Validate…

timescale/pg-aiguide · 181 tokens