credcheck

credcheck - postgresql plain text credential checker

Overview

PackageVersionCategoryLicenseLanguage
credcheck4.6SECMITC
IDExtensionBinLibLoadCreateTrustRelocSchema
7310credcheckNoYesYesYesNoNo-
Relatedpasswordcheck_cracklib login_hook passwordcheck pgaudit pg_auth_mon set_user auth_delay pg_permissions

Version

TypeRepoVersionPG VerPackageDeps
EXTPGDG4.61817161514credcheck-
RPMPGDG4.61817161514credcheck_$v-
DEBPGDG4.61817161514postgresql-$v-credcheck-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
PGDG 4.6
PGDG 4.6
PGDG 4.6
PGDG 4.6
PGDG 4.6
d12.aarch64
PGDG 4.6
PGDG 4.6
PGDG 4.6
PGDG 4.6
PGDG 4.6
d13.x86_64
PGDG 4.6
PGDG 4.6
PGDG 4.6
PGDG 4.6
PGDG 4.6
d13.aarch64
PGDG 4.6
PGDG 4.6
PGDG 4.6
PGDG 4.6
PGDG 4.6
u22.x86_64
PGDG 4.6
PGDG 4.6
PGDG 4.6
PGDG 4.6
PGDG 4.6
u22.aarch64
PGDG 4.6
PGDG 4.6
PGDG 4.6
PGDG 4.6
PGDG 4.6
u24.x86_64
PGDG 4.6
PGDG 4.6
PGDG 4.6
PGDG 4.6
PGDG 4.6
u24.aarch64
PGDG 4.6
PGDG 4.6
PGDG 4.6
PGDG 4.6
PGDG 4.6

Install

You can install credcheck directly. First, make sure the PGDG repository is added and enabled:

pig repo add pgdg -u          # Add PGDG repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install credcheck;          # Install for current active PG version
pig ext install -y credcheck -v 18  # PG 18
pig ext install -y credcheck -v 17  # PG 17
pig ext install -y credcheck -v 16  # PG 16
pig ext install -y credcheck -v 15  # PG 15
pig ext install -y credcheck -v 14  # PG 14
dnf install -y credcheck_18       # PG 18
dnf install -y credcheck_17       # PG 17
dnf install -y credcheck_16       # PG 16
dnf install -y credcheck_15       # PG 15
dnf install -y credcheck_14       # PG 14
apt install -y postgresql-18-credcheck   # PG 18
apt install -y postgresql-17-credcheck   # PG 17
apt install -y postgresql-16-credcheck   # PG 16
apt install -y postgresql-15-credcheck   # PG 15
apt install -y postgresql-14-credcheck   # PG 14

Preload:

shared_preload_libraries = 'credcheck';

Create Extension:

CREATE EXTENSION credcheck;

Usage

credcheck: Credential checking for PostgreSQL usernames and passwords

credcheck enforces configurable rules for username and password strength during CREATE ROLE, ALTER ROLE, and password changes. It also supports password reuse policies and authentication failure banning.

Configuration Parameters

Add to postgresql.conf:

shared_preload_libraries = 'credcheck'

Username Checks

ParameterDescriptionExample
credcheck.username_min_lengthMinimum username length4
credcheck.username_min_specialMinimum special characters1
credcheck.username_min_digitMinimum digit characters1
credcheck.username_min_upperMinimum uppercase characters2
credcheck.username_min_lowerMinimum lowercase characters1
credcheck.username_min_repeatMax adjacent repeat characters2
credcheck.username_containMust contain one of these charsa,b,c
credcheck.username_not_containMust not contain these charsx,y,z
credcheck.username_contain_passwordUsername must not contain passwordon

Password Checks

ParameterDescriptionExample
credcheck.password_min_lengthMinimum password length8
credcheck.password_min_specialMinimum special characters1
credcheck.password_min_digitMinimum digit characters1
credcheck.password_min_upperMinimum uppercase characters1
credcheck.password_min_lowerMinimum lowercase characters1
credcheck.password_min_repeatMax adjacent repeat characters3
credcheck.password_contain_usernamePassword must not contain usernameon
credcheck.password_valid_untilMinimum days for VALID UNTIL60
credcheck.password_valid_maxMaximum days for VALID UNTIL365
credcheck.whitelistUsernames excluded from checksadmin,super

Examples

-- Rejected: username too short
CREATE USER abc WITH PASSWORD 'pass';
-- ERROR: username length should match the configured credcheck.username_min_length

-- Rejected: password contains username
CREATE USER abcd$ WITH PASSWORD 'abcd$xyz';
-- ERROR: password should not contain username

Password Reuse Policy

SET credcheck.password_reuse_history = 2;
SET credcheck.password_reuse_interval = 365;  -- days

View password history:

SELECT rolename, password_hash FROM pg_password_history;

Authentication Failure Ban

SET credcheck.max_auth_failure = 3;  -- ban after 3 failures

Reset banned users:

SELECT pg_banned_role_reset();              -- reset all
SELECT pg_banned_role_reset('username');     -- reset specific user

Last Modified 2026-03-12: add pg extension catalog (95749bf)