credcheck
credcheck : credcheck - postgresql plain text credential checker
Overview
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sLd-- | No | Yes | Yes | Yes | no | no |
| Relationships | |
|---|---|
| See Also | pg_pwhash passwordcheck passwordcheck_cracklib passwordpolicy chkpass pg_enigma column_encrypt |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG | 6.0 |
18 17 16 15 14 | credcheck |
- |
| RPM | PGDG | 6.0 |
18 17 16 15 14 | credcheck_$v |
- |
| DEB | PGDG | 5.0 |
18 17 16 15 14 | postgresql-$v-credcheck |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| 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 6.0 | PGDG 6.0 | PGDG 6.0 | PGDG 6.0 | PGDG 6.0 |
| el9.aarch64 | PGDG 6.0 | PGDG 6.0 | PGDG 6.0 | PGDG 6.0 | PGDG 6.0 |
| el10.x86_64 | PGDG 6.0 | PGDG 6.0 | PGDG 6.0 | PGDG 6.0 | PGDG 6.0 |
| el10.aarch64 | PGDG 6.0 | PGDG 6.0 | PGDG 6.0 | PGDG 6.0 | PGDG 6.0 |
| d12.x86_64 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 |
| d12.aarch64 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 |
| d13.x86_64 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 |
| d13.aarch64 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 |
| u22.x86_64 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 |
| u22.aarch64 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 |
| u24.x86_64 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 |
| u24.aarch64 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 |
| u26.x86_64 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 |
| u26.aarch64 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 | PGDG 5.0 |
Source
github.com/HexaCluster/credcheck
Install
Make sure PGDG repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
Create this extension with:
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:
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
| Settings | Purpose |
|---|---|
credcheck.username_min_length, credcheck.username_min_special, credcheck.username_min_digit, credcheck.username_min_upper, credcheck.username_min_lower |
Username length and character requirements |
credcheck.password_min_length, credcheck.password_min_special, credcheck.password_min_digit, credcheck.password_min_upper, credcheck.password_min_lower |
Password length and character requirements |
credcheck.username_min_repeat, credcheck.password_min_repeat |
Maximum adjacent repetitions, despite the parameter names |
credcheck.username_contain, credcheck.username_not_contain, credcheck.password_contain, credcheck.password_not_contain |
Required or forbidden content |
credcheck.username_contain_password, credcheck.password_contain_username |
Reject credentials containing one another |
credcheck.username_ignore_case, credcheck.password_ignore_case |
Case handling |
credcheck.password_min_length_su, credcheck.password_valid_until_su |
Separate superuser requirements |
credcheck.password_valid_until, credcheck.password_valid_max |
Minimum and maximum password lifetime; the minimum also supplies an omitted expiry when a password is changed |
credcheck.whitelist, credcheck.superuser_nocheck |
Explicit policy exemptions |
credcheck.no_password_logging |
Suppress 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.
Resetting history removes reuse protection for those records; reserve it for administrators.
Authentication and Password Changes
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.