Skip to content

credcheck

credcheck - postgresql plain text credential checker

Overview

PackageVersionCategoryLicenseLanguage
credcheck6.0SECPostgreSQLC
IDExtensionBinLibLoadCreateTrustRelocSchema
7310credcheckNoYesYesYesNoNo-

pkg 6.0; SQL 6.0.0; restart then update extension; migrates 5.x history; PgBouncer needs setup.

Version

TypeRepoVersionPG VerPackageDeps
EXTPGDG6.01817161514credcheck-
RPMPGDG6.01817161514credcheck_$v-
DEBPGDG6.01817161514postgresql-$v-credcheck-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
PGDG 6.0
el9.x86_64.pg15 : credcheck_15
credcheck_15-6.0-1PGDG.rhel9.8.x86_64.rpm PGDG · 6.0 · 54.3KiB credcheck_15-4.7-1PGDG.rhel9.8.x86_64.rpm PGDG · 4.7 · 41.5KiB credcheck_15-4.7-1PGDG.rhel9.7.x86_64.rpm PGDG · 4.7 · 41.5KiB credcheck_15-4.7-1PGDG.rhel9.6.x86_64.rpm PGDG · 4.7 · 41.6KiB credcheck_15-4.6-1PGDG.rhel9.7.x86_64.rpm PGDG · 4.6 · 40.9KiB credcheck_15-4.6-1PGDG.rhel9.6.x86_64.rpm PGDG · 4.6 · 41.0KiB credcheck_15-4.5-1PGDG.rhel9.7.x86_64.rpm PGDG · 4.5 · 40.9KiB credcheck_15-4.5-1PGDG.rhel9.6.x86_64.rpm PGDG · 4.5 · 41.0KiB credcheck_15-4.4-1PGDG.rhel9.7.x86_64.rpm PGDG · 4.4 · 40.3KiB credcheck_15-4.4-1PGDG.rhel9.6.x86_64.rpm PGDG · 4.4 · 40.4KiB credcheck_15-4.3-1PGDG.rhel9.7.x86_64.rpm PGDG · 4.3 · 40.0KiB credcheck_15-4.3-1PGDG.rhel9.6.x86_64.rpm PGDG · 4.3 · 40.2KiB credcheck_15-4.2-1PGDG.rhel9.x86_64.rpm PGDG · 4.2 · 39.7KiB credcheck_15-4.1-1PGDG.rhel9.x86_64.rpm PGDG · 4.1 · 39.3KiB credcheck_15-3.0-1PGDG.rhel9.x86_64.rpm PGDG · 3.0 · 36.1KiB credcheck_15-2.7-1PGDG.rhel9.x86_64.rpm PGDG · 2.7 · 35.2KiB credcheck_15-2.6-1PGDG.rhel9.x86_64.rpm PGDG · 2.6 · 34.9KiB credcheck_15-2.2-1PGDG.rhel9.x86_64.rpm PGDG · 2.2 · 33.4KiB credcheck_15-2.1-1PGDG.rhel9.x86_64.rpm PGDG · 2.1 · 32.5KiB credcheck_15-2.0-1.rhel9.x86_64.rpm PGDG · 2.0 · 31.6KiB credcheck_15-1.2-1.rhel9.x86_64.rpm PGDG · 1.2 · 28.1KiB credcheck_15-1.0-1.rhel9.x86_64.rpm PGDG · 1.0 · 27.5KiB credcheck_15-0.2.0-3.rhel9.x86_64.rpm PGDG · 0.2.0 · 18.8KiB credcheck_15-0.2.0-1.rhel9.x86_64.rpm PGDG · 0.2.0 · 35.9KiB
el9.aarch64
PGDG 6.0
el9.aarch64.pg15 : credcheck_15
credcheck_15-6.0-1PGDG.rhel9.8.aarch64.rpm PGDG · 6.0 · 53.5KiB 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 6.0
el9.aarch64.pg14 : credcheck_14
credcheck_14-6.0-1PGDG.rhel9.8.aarch64.rpm PGDG · 6.0 · 51.8KiB 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

Build

You can build the RPM packages for credcheck using pig build:

pig build pkg credcheck         # build RPM packages

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 6.0 uses SQL extension version 6.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 in 6.0 is revoked from PUBLIC and granted to pg_read_all_stats. credcheck.history_max_size changes the history 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.

Upgrade and New Interfaces in 6.0

6.0 moves password history into an integer-indexed hash table in an mmap file. The first upgraded startup imports 5.x history and renames the old file to pg_password_history.legacy-migrated; this happens on both primary and standby. Preserve and verify the history backup before upgrading. After installing matching libraries and restarting, run ALTER EXTENSION credcheck UPDATE TO '6.0.0' in databases using its SQL objects. Current SQL revokes PUBLIC access to the history function/view and grants view access to pg_read_all_stats; review existing custom grants.

credcheck.password_valid_min sets a short initial password lifetime for new roles; the default 0 disables it. Existing roles changing their password retain the previous lifetime policy. New pg_check_password(username, password) checks candidate credentials, raising an error on a violation and returning true on acceptance; it does not evaluate password reuse history.

credcheck.lastlog defaults off. When enabled, pg_lastlog exposes sessions and server startup/shutdown events; optional SQL tracking records query text, so define access and retention deliberately. PgBouncer integration for failed-attempt limits and first-login password changes needs the documented extra SQL and pooler hooks; preload alone does not configure it. credcheck.no_password_logging now masks password literals while retaining the error statement structure. This release also fixes self-ALTER ROLE privilege escalation and memory defects.

Was this page helpful?