Skip to content
credcheck

credcheck

credcheck : credcheck - postgresql plain text credential checker

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
7310
credcheck
credcheck
4.7
SEC
MIT
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--sLd--
No
Yes
Yes
Yes
no
no
Relationships
See Also
passwordcheck_cracklib
login_hook
passwordcheck
pgaudit
pg_auth_mon
set_user
auth_delay
pg_permissions

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PGDG
4.7
18
17
16
15
14
credcheck-
RPM
PGDG
4.7
18
17
16
15
14
credcheck_$v-
DEB
PGDG
4.7
18
17
16
15
14
postgresql-$v-credcheck-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
el8.aarch64
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
el9.x86_64
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
el9.aarch64
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
el10.x86_64
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
el10.aarch64
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
d12.x86_64
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
d12.aarch64
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
d13.x86_64
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
d13.aarch64
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
u22.x86_64
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
u22.aarch64
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
u24.x86_64
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
u24.aarch64
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
u26.x86_64
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
u26.aarch64
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PGDG 4.7
PackageVersionOSORGSIZEFile URL
credcheck_184.7el8.x86_64pgdg42.3 KiBcredcheck_18-4.7-1PGDG.rhel8.10.x86_64.rpm
credcheck_184.6el8.x86_64pgdg41.8 KiBcredcheck_18-4.6-1PGDG.rhel8.10.x86_64.rpm
credcheck_184.5el8.x86_64pgdg41.5 KiBcredcheck_18-4.5-1PGDG.rhel8.10.x86_64.rpm
credcheck_184.4el8.x86_64pgdg40.8 KiBcredcheck_18-4.4-1PGDG.rhel8.10.x86_64.rpm
credcheck_184.3el8.x86_64pgdg40.6 KiBcredcheck_18-4.3-1PGDG.rhel8.10.x86_64.rpm
credcheck_184.2el8.x86_64pgdg40.0 KiBcredcheck_18-4.2-1PGDG.rhel8.x86_64.rpm
credcheck_184.1el8.x86_64pgdg39.4 KiBcredcheck_18-4.1-1PGDG.rhel8.x86_64.rpm
credcheck_183.0el8.x86_64pgdg35.6 KiBcredcheck_18-3.0-2PGDG.rhel8.x86_64.rpm
credcheck_184.7el8.aarch64pgdg41.5 KiBcredcheck_18-4.7-1PGDG.rhel8.10.aarch64.rpm
credcheck_184.6el8.aarch64pgdg41.1 KiBcredcheck_18-4.6-1PGDG.rhel8.10.aarch64.rpm
credcheck_184.5el8.aarch64pgdg40.8 KiBcredcheck_18-4.5-1PGDG.rhel8.10.aarch64.rpm
credcheck_184.4el8.aarch64pgdg40.2 KiBcredcheck_18-4.4-1PGDG.rhel8.10.aarch64.rpm
credcheck_184.3el8.aarch64pgdg39.9 KiBcredcheck_18-4.3-1PGDG.rhel8.10.aarch64.rpm
credcheck_184.2el8.aarch64pgdg39.2 KiBcredcheck_18-4.2-1PGDG.rhel8.aarch64.rpm
credcheck_184.1el8.aarch64pgdg38.8 KiBcredcheck_18-4.1-1PGDG.rhel8.aarch64.rpm
credcheck_183.0el8.aarch64pgdg35.1 KiBcredcheck_18-3.0-2PGDG.rhel8.aarch64.rpm
credcheck_184.7el9.x86_64pgdg41.3 KiBcredcheck_18-4.7-1PGDG.rhel9.7.x86_64.rpm
credcheck_184.6el9.x86_64pgdg40.9 KiBcredcheck_18-4.6-1PGDG.rhel9.7.x86_64.rpm
credcheck_184.5el9.x86_64pgdg40.8 KiBcredcheck_18-4.5-1PGDG.rhel9.7.x86_64.rpm
credcheck_184.4el9.x86_64pgdg40.3 KiBcredcheck_18-4.4-1PGDG.rhel9.7.x86_64.rpm
credcheck_184.3el9.x86_64pgdg40.0 KiBcredcheck_18-4.3-1PGDG.rhel9.7.x86_64.rpm
credcheck_184.2el9.x86_64pgdg39.6 KiBcredcheck_18-4.2-1PGDG.rhel9.x86_64.rpm
credcheck_184.1el9.x86_64pgdg39.2 KiBcredcheck_18-4.1-1PGDG.rhel9.x86_64.rpm
credcheck_183.0el9.x86_64pgdg35.9 KiBcredcheck_18-3.0-2PGDG.rhel9.x86_64.rpm
credcheck_184.7el9.aarch64pgdg40.7 KiBcredcheck_18-4.7-1PGDG.rhel9.7.aarch64.rpm
credcheck_184.6el9.aarch64pgdg40.2 KiBcredcheck_18-4.6-1PGDG.rhel9.7.aarch64.rpm
credcheck_184.5el9.aarch64pgdg40.5 KiBcredcheck_18-4.5-1PGDG.rhel9.7.aarch64.rpm
credcheck_184.4el9.aarch64pgdg39.6 KiBcredcheck_18-4.4-1PGDG.rhel9.7.aarch64.rpm
credcheck_184.3el9.aarch64pgdg39.7 KiBcredcheck_18-4.3-1PGDG.rhel9.7.aarch64.rpm
credcheck_184.2el9.aarch64pgdg39.1 KiBcredcheck_18-4.2-1PGDG.rhel9.aarch64.rpm
credcheck_184.1el9.aarch64pgdg38.7 KiBcredcheck_18-4.1-1PGDG.rhel9.aarch64.rpm
credcheck_183.0el9.aarch64pgdg35.6 KiBcredcheck_18-3.0-2PGDG.rhel9.aarch64.rpm
credcheck_184.7el10.x86_64pgdg41.6 KiBcredcheck_18-4.7-1PGDG.rhel10.1.x86_64.rpm
credcheck_184.5el10.x86_64pgdg41.1 KiBcredcheck_18-4.5-1PGDG.rhel10.1.x86_64.rpm
credcheck_184.4el10.x86_64pgdg40.6 KiBcredcheck_18-4.4-1PGDG.rhel10.1.x86_64.rpm
credcheck_184.3el10.x86_64pgdg40.4 KiBcredcheck_18-4.3-1PGDG.rhel10.1.x86_64.rpm
credcheck_184.2el10.x86_64pgdg40.3 KiBcredcheck_18-4.2-1PGDG.rhel10.x86_64.rpm
credcheck_184.1el10.x86_64pgdg39.7 KiBcredcheck_18-4.1-1PGDG.rhel10.x86_64.rpm
credcheck_183.0el10.x86_64pgdg36.3 KiBcredcheck_18-3.0-2PGDG.rhel10.x86_64.rpm
credcheck_184.7el10.aarch64pgdg41.1 KiBcredcheck_18-4.7-1PGDG.rhel10.1.aarch64.rpm
credcheck_184.6el10.aarch64pgdg40.6 KiBcredcheck_18-4.6-1PGDG.rhel10.1.aarch64.rpm
credcheck_184.5el10.aarch64pgdg40.6 KiBcredcheck_18-4.5-1PGDG.rhel10.1.aarch64.rpm
credcheck_184.4el10.aarch64pgdg40.3 KiBcredcheck_18-4.4-1PGDG.rhel10.1.aarch64.rpm
credcheck_184.3el10.aarch64pgdg40.0 KiBcredcheck_18-4.3-1PGDG.rhel10.1.aarch64.rpm
credcheck_184.2el10.aarch64pgdg39.9 KiBcredcheck_18-4.2-1PGDG.rhel10.aarch64.rpm
credcheck_184.1el10.aarch64pgdg39.5 KiBcredcheck_18-4.1-1PGDG.rhel10.aarch64.rpm
credcheck_183.0el10.aarch64pgdg36.3 KiBcredcheck_18-3.0-2PGDG.rhel10.aarch64.rpm
postgresql-18-credcheck4.7d12.x86_64pgdg75.2 KiBpostgresql-18-credcheck_4.7-1.pgdg12+1_amd64.deb
postgresql-18-credcheck4.6d12.x86_64pgdg74.4 KiBpostgresql-18-credcheck_4.6-1.pgdg12+1_amd64.deb
postgresql-18-credcheck4.7d12.aarch64pgdg74.0 KiBpostgresql-18-credcheck_4.7-1.pgdg12+1_arm64.deb
postgresql-18-credcheck4.6d12.aarch64pgdg73.1 KiBpostgresql-18-credcheck_4.6-1.pgdg12+1_arm64.deb
postgresql-18-credcheck4.7d13.x86_64pgdg75.0 KiBpostgresql-18-credcheck_4.7-1.pgdg13+1_amd64.deb
postgresql-18-credcheck4.6d13.x86_64pgdg74.1 KiBpostgresql-18-credcheck_4.6-1.pgdg13+1_amd64.deb
postgresql-18-credcheck4.7d13.aarch64pgdg73.8 KiBpostgresql-18-credcheck_4.7-1.pgdg13+1_arm64.deb
postgresql-18-credcheck4.6d13.aarch64pgdg73.0 KiBpostgresql-18-credcheck_4.6-1.pgdg13+1_arm64.deb
postgresql-18-credcheck4.7u22.x86_64pgdg69.6 KiBpostgresql-18-credcheck_4.7-1.pgdg22.04+1_amd64.deb
postgresql-18-credcheck4.6u22.x86_64pgdg68.5 KiBpostgresql-18-credcheck_4.6-1.pgdg22.04+1_amd64.deb
postgresql-18-credcheck4.7u22.aarch64pgdg68.1 KiBpostgresql-18-credcheck_4.7-1.pgdg22.04+1_arm64.deb
postgresql-18-credcheck4.6u22.aarch64pgdg67.2 KiBpostgresql-18-credcheck_4.6-1.pgdg22.04+1_arm64.deb
postgresql-18-credcheck4.7u24.x86_64pgdg68.8 KiBpostgresql-18-credcheck_4.7-1.pgdg24.04+1_amd64.deb
postgresql-18-credcheck4.6u24.x86_64pgdg68.2 KiBpostgresql-18-credcheck_4.6-1.pgdg24.04+1_amd64.deb
postgresql-18-credcheck4.7u24.aarch64pgdg67.5 KiBpostgresql-18-credcheck_4.7-1.pgdg24.04+1_arm64.deb
postgresql-18-credcheck4.6u24.aarch64pgdg66.9 KiBpostgresql-18-credcheck_4.6-1.pgdg24.04+1_arm64.deb
postgresql-18-credcheck4.7u26.x86_64pgdg68.4 KiBpostgresql-18-credcheck_4.7-1.pgdg26.04+1_amd64.deb
postgresql-18-credcheck4.6u26.x86_64pgdg67.6 KiBpostgresql-18-credcheck_4.6-1.pgdg26.04+1_amd64.deb
postgresql-18-credcheck4.7u26.aarch64pgdg67.0 KiBpostgresql-18-credcheck_4.7-1.pgdg26.04+1_arm64.deb
postgresql-18-credcheck4.6u26.aarch64pgdg66.2 KiBpostgresql-18-credcheck_4.6-1.pgdg26.04+1_arm64.deb

Source

Install

Make sure PGDG repo available:

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

Install this extension with pig:

pig install credcheck;		# install via package name, for the active PG version

pig install credcheck -v 18;   # install for PG 18
pig install credcheck -v 17;   # install for PG 17
pig install credcheck -v 16;   # install for PG 16
pig install credcheck -v 15;   # install for PG 15
pig install credcheck -v 14;   # install for PG 14

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'credcheck';

Create this extension with:

CREATE EXTENSION credcheck;

Usage

Sources: README, release 4.7

credcheck enforces configurable rules for PostgreSQL usernames and passwords during CREATE ROLE, ALTER ROLE, password changes, and role renames. It can reject weak credentials, enforce password expiration windows, track password reuse, ban users after repeated authentication failures, delay failed authentication responses, force first-login password changes, and block password changes for ordinary users.

Required Setup

Add to postgresql.conf:

shared_preload_libraries = 'credcheck'

Restart PostgreSQL after changing preload libraries. Password reuse history, authentication failure banning, first-login password changes, and login-time expiry warnings depend on preload or login-event support described in the upstream README.

Configuration Parameters

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
credcheck.username_ignore_caseIgnore case for username checkson

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_containMust contain one of these charsa,b,c
credcheck.password_not_containMust not contain these chars!@=$#
credcheck.password_ignore_caseIgnore case for password checkson
credcheck.password_valid_untilMinimum days for VALID UNTIL60
credcheck.password_valid_maxMaximum days for VALID UNTIL365
credcheck.password_valid_warningWarn before password expiry; PostgreSQL 17+ login event trigger7
credcheck.password_change_first_loginForce a new user to change password before normal queriestrue
credcheck.whitelistUsernames excluded from checksadmin,super
credcheck.superuser_nocheckSkip policy checks for changes made by a superuseron
credcheck.disallow_password_changeDisallow users from changing their own passwordon

If built with cracklib support, credcheck can also reject passwords that are easy to crack.

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

Enforce password lifetime bounds:

SET credcheck.password_valid_until = 30;
SET credcheck.password_valid_max = 180;

CREATE USER abcd$;
-- ERROR: require a VALID UNTIL option with a date older than 30 days

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;

The upstream README says password hashes are kept in shared memory and saved to $PGDATA/pg_password_history, so include that file in backup planning. Use credcheck.history_max_size to size the cache; changing it requires a PostgreSQL restart.

Authentication Failure Ban

SET credcheck.max_auth_failure = 3;  -- ban after 3 failures
SET credcheck.auth_delay_ms = 1000;  -- delay failed authentication
SET credcheck.whitelist_auth_failure = 'appuser1,appuser2';

Reset banned users:

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

credcheck.reset_superuser can force superusers to be exempt from banning or reset a banned superuser.

First-Login And Password-Change Controls

Force a new user to change the password before running normal queries:

SET credcheck.password_change_first_login = true;
CREATE USER user1 PASSWORD 'Rkd89,34' VALID UNTIL '2050-12-31';
-- first login:
-- ERROR: you must change your password first.
ALTER USER user1 PASSWORD 'Zkd89,34';

Force the same behavior later:

ALTER USER user1 SET credcheck_internal.force_change_password = true;

Version 4.7 adds credcheck.disallow_password_change for sites where users must not change their own password:

SET credcheck.disallow_password_change = on;
ALTER ROLE user1 PASSWORD 'My-New-Pass#123';
-- ERROR: you are not allowed to change your password.
Last updated on