Skip to content

credcheck

credcheck - postgresql plain text credential checker

Overview

PackageVersionCategoryLicenseLanguage
credcheck5.0SECMITC
IDExtensionBinLibLoadCreateTrustRelocSchema
7310credcheckNoYesYesYesNoNo-

Version

TypeRepoVersionPG VerPackageDeps
EXTPGDG5.01817161514credcheck-
RPMPGDG4.71817161514credcheck_$v-
DEBPGDG5.01817161514postgresql-$v-credcheck-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
PGDG 4.7
el9.aarch64.pg15 : credcheck_15
credcheck_15-4.7-1PGDG.rhel9.8.aarch64.rpm PGDG · 4.7 · 40.7KiB credcheck_15-4.7-1PGDG.rhel9.7.aarch64.rpm PGDG · 4.7 · 40.7KiB credcheck_15-4.7-1PGDG.rhel9.6.aarch64.rpm PGDG · 4.7 · 40.8KiB credcheck_15-4.6-1PGDG.rhel9.7.aarch64.rpm PGDG · 4.6 · 40.2KiB credcheck_15-4.6-1PGDG.rhel9.6.aarch64.rpm PGDG · 4.6 · 40.3KiB credcheck_15-4.5-1PGDG.rhel9.7.aarch64.rpm PGDG · 4.5 · 40.2KiB credcheck_15-4.5-1PGDG.rhel9.6.aarch64.rpm PGDG · 4.5 · 40.3KiB credcheck_15-4.4-1PGDG.rhel9.7.aarch64.rpm PGDG · 4.4 · 39.6KiB credcheck_15-4.4-1PGDG.rhel9.6.aarch64.rpm PGDG · 4.4 · 39.7KiB credcheck_15-4.3-1PGDG.rhel9.7.aarch64.rpm PGDG · 4.3 · 39.6KiB credcheck_15-4.3-1PGDG.rhel9.6.aarch64.rpm PGDG · 4.3 · 39.7KiB credcheck_15-4.2-1PGDG.rhel9.aarch64.rpm PGDG · 4.2 · 38.9KiB credcheck_15-4.1-1PGDG.rhel9.aarch64.rpm PGDG · 4.1 · 38.7KiB credcheck_15-3.0-1PGDG.rhel9.aarch64.rpm PGDG · 3.0 · 35.8KiB credcheck_15-2.7-1PGDG.rhel9.aarch64.rpm PGDG · 2.7 · 34.8KiB credcheck_15-2.6-1PGDG.rhel9.aarch64.rpm PGDG · 2.6 · 34.5KiB credcheck_15-2.2-1PGDG.rhel9.aarch64.rpm PGDG · 2.2 · 32.9KiB credcheck_15-2.1-1PGDG.rhel9.aarch64.rpm PGDG · 2.1 · 31.8KiB credcheck_15-2.0-1.rhel9.aarch64.rpm PGDG · 2.0 · 30.9KiB credcheck_15-1.2-1.rhel9.aarch64.rpm PGDG · 1.2 · 27.5KiB credcheck_15-1.0-1.rhel9.aarch64.rpm PGDG · 1.0 · 26.9KiB credcheck_15-0.2.0-3.rhel9.aarch64.rpm PGDG · 0.2.0 · 18.1KiB credcheck_15-0.2.0-1.rhel9.aarch64.rpm PGDG · 0.2.0 · 35.5KiB
PGDG 4.7
el9.aarch64.pg14 : credcheck_14
credcheck_14-4.7-1PGDG.rhel9.8.aarch64.rpm PGDG · 4.7 · 40.6KiB credcheck_14-4.7-1PGDG.rhel9.7.aarch64.rpm PGDG · 4.7 · 40.6KiB credcheck_14-4.7-1PGDG.rhel9.6.aarch64.rpm PGDG · 4.7 · 40.7KiB credcheck_14-4.6-1PGDG.rhel9.7.aarch64.rpm PGDG · 4.6 · 40.2KiB credcheck_14-4.6-1PGDG.rhel9.6.aarch64.rpm PGDG · 4.6 · 40.3KiB credcheck_14-4.5-1PGDG.rhel9.7.aarch64.rpm PGDG · 4.5 · 40.2KiB credcheck_14-4.5-1PGDG.rhel9.6.aarch64.rpm PGDG · 4.5 · 40.3KiB credcheck_14-4.4-1PGDG.rhel9.7.aarch64.rpm PGDG · 4.4 · 39.5KiB credcheck_14-4.4-1PGDG.rhel9.6.aarch64.rpm PGDG · 4.4 · 39.9KiB credcheck_14-4.3-1PGDG.rhel9.7.aarch64.rpm PGDG · 4.3 · 39.5KiB credcheck_14-4.3-1PGDG.rhel9.6.aarch64.rpm PGDG · 4.3 · 39.6KiB credcheck_14-4.2-1PGDG.rhel9.aarch64.rpm PGDG · 4.2 · 39.0KiB credcheck_14-4.1-1PGDG.rhel9.aarch64.rpm PGDG · 4.1 · 38.6KiB credcheck_14-3.0-1PGDG.rhel9.aarch64.rpm PGDG · 3.0 · 35.6KiB credcheck_14-2.7-1PGDG.rhel9.aarch64.rpm PGDG · 2.7 · 34.8KiB credcheck_14-2.6-1PGDG.rhel9.aarch64.rpm PGDG · 2.6 · 34.4KiB credcheck_14-2.2-1PGDG.rhel9.aarch64.rpm PGDG · 2.2 · 32.8KiB credcheck_14-2.1-1PGDG.rhel9.aarch64.rpm PGDG · 2.1 · 31.7KiB credcheck_14-2.0-1.rhel9.aarch64.rpm PGDG · 2.0 · 30.8KiB credcheck_14-1.2-1.rhel9.aarch64.rpm PGDG · 1.2 · 27.4KiB credcheck_14-1.0-1.rhel9.aarch64.rpm PGDG · 1.0 · 26.8KiB credcheck_14-0.2.0-3.rhel9.aarch64.rpm PGDG · 0.2.0 · 18.0KiB credcheck_14-0.2.0-1.rhel9.aarch64.rpm PGDG · 0.2.0 · 35.4KiB
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
u22.x86_64
u22.aarch64
u24.x86_64
u24.aarch64
u26.x86_64
u26.aarch64

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:

Install
pig install credcheck;          # Install for current active PG version
pig
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
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
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

Sources:

credcheck enforces username and plaintext-password rules during role creation, password changes and role renames. It also tracks password reuse, bans repeated authentication failures and can require a password change at first login. Configure policy as a superuser; the defaults do not enforce a comprehensive password-strength policy.

Enable and Set Policy

Add the library to the existing preload list and restart PostgreSQL. Install SQL objects in each database where administrators need its views and reset functions:

shared_preload_libraries = 'credcheck'
credcheck.password_min_length = 12
credcheck.password_contain_username = on
credcheck.password_reuse_history = 2
credcheck.password_reuse_interval = 365
CREATE EXTENSION credcheck;
CREATE ROLE app_user LOGIN PASSWORD 'example-Strong-Pass#123';
SELECT rolename, password_date FROM pg_password_history;

The interval is in days. Installing the SQL extension is separate from loading the server-wide hooks. Upstream release 5.0 uses SQL extension version 5.0.0; installing upgraded files requires a restart to reload the library.

Policy Index

SettingsPurpose
credcheck.username_min_length, credcheck.username_min_special, credcheck.username_min_digit, credcheck.username_min_upper, credcheck.username_min_lowerUsername length and character requirements
credcheck.password_min_length, credcheck.password_min_special, credcheck.password_min_digit, credcheck.password_min_upper, credcheck.password_min_lowerPassword length and character requirements
credcheck.username_min_repeat, credcheck.password_min_repeatMaximum adjacent repetitions, despite the parameter names
credcheck.username_contain, credcheck.username_not_contain, credcheck.password_contain, credcheck.password_not_containRequired or forbidden content
credcheck.username_contain_password, credcheck.password_contain_usernameReject credentials containing one another
credcheck.username_ignore_case, credcheck.password_ignore_caseCase handling
credcheck.password_min_length_su, credcheck.password_valid_until_suSeparate superuser requirements
credcheck.password_valid_until, credcheck.password_valid_maxMinimum and maximum password lifetime; the minimum also supplies an omitted expiry when a password is changed
credcheck.whitelist, credcheck.superuser_nocheckExplicit policy exemptions
credcheck.no_password_loggingSuppress passwords in policy-error logs; enabled by default

CrackLib strength checking is available only when the library was built with that support and its dictionary is available.

Password History and Replication

History contains SHA-256 password hashes, is shared across databases, and is persisted in $PGDATA/pg_password_history. Include that file in backup planning and protect access to the SQL history view, which is granted to PUBLIC by default. credcheck.history_max_size changes the shared-memory capacity and requires a restart.

Version 5.0 replicates history changes through custom WAL resource manager ID 150 on PostgreSQL 15 and later. Keep the matching library preloaded on replicas and recovery servers that replay its WAL. Earlier PostgreSQL versions retain the file-backed history path without this replication support. History-reset and timestamp-test functions reject execution during recovery.

SELECT pg_password_history_reset('app_user');

Resetting history removes reuse protection for those records; reserve it for administrators.

Authentication and Password Changes

credcheck.max_auth_failure = 3
credcheck.auth_delay_ms = 1000
credcheck.whitelist_auth_failure = 'service_user'
credcheck.password_change_first_login = true
SELECT * FROM pg_banned_role;
SELECT pg_banned_role_reset('app_user');
ALTER ROLE app_user SET credcheck_internal.force_change_password = true;

Bans remain until reset and their cache is lost at restart. credcheck.reset_superuser provides the documented superuser recovery path; credcheck.auth_failure_cache_size requires a restart.

Use the actual parameter credcheck.disallow_change_password to prohibit password changes. Even superusers are affected unless they enable credcheck.superuser_nocheck in their session. This exemption bypasses all corresponding role checks and must be controlled.

credcheck.password_valid_warning needs PostgreSQL 17 or later and the official login event trigger installed separately in every relevant database; SQL extension creation does not install that trigger.

Plaintext Boundary

Strength and reuse checks need plaintext at password-change time. Already hashed passwords are rejected by default, including passwords sent by psql’s \password. Setting credcheck.encrypted_password_allowed accepts them without providing equivalent plaintext checks. Protect the password-change connection and do not assume existing credentials are scanned retroactively. Username checks are skipped when creating a role without a password or renaming a role with no password.

Was this page helpful?