pgextwlist

PostgreSQL Extension Whitelisting

Overview

PackageVersionCategoryLicenseLanguage
pgextwlist1.19SECPostgreSQLC
IDExtensionBinLibLoadCreateTrustRelocSchema
7390pgextwlistNoYesYesNoNoNo-
Relatedddlx pgdd pg_permissions adminpack pgaudit set_user pg_catcheck noset

missing pg18 on el

Version

TypeRepoVersionPG VerPackageDeps
EXTMIXED1.191817161514pgextwlist-
RPMPIGSTY1.191817161514pgextwlist_$v-
DEBPGDG1.191817161514postgresql-$v-pgextwlist-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
d12.aarch64
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
d13.x86_64
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
d13.aarch64
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
u22.x86_64
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
u22.aarch64
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
u24.x86_64
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
u24.aarch64
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19
PGDG 1.19

Build

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

pig build pkg pgextwlist         # build RPM packages

Install

You can install pgextwlist directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

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

pig install pgextwlist;          # Install for current active PG version
pig ext install -y pgextwlist -v 18  # PG 18
pig ext install -y pgextwlist -v 17  # PG 17
pig ext install -y pgextwlist -v 16  # PG 16
pig ext install -y pgextwlist -v 15  # PG 15
pig ext install -y pgextwlist -v 14  # PG 14
dnf install -y pgextwlist_18       # PG 18
dnf install -y pgextwlist_17       # PG 17
dnf install -y pgextwlist_16       # PG 16
dnf install -y pgextwlist_15       # PG 15
dnf install -y pgextwlist_14       # PG 14
apt install -y postgresql-18-pgextwlist   # PG 18
apt install -y postgresql-17-pgextwlist   # PG 17
apt install -y postgresql-16-pgextwlist   # PG 16
apt install -y postgresql-15-pgextwlist   # PG 15
apt install -y postgresql-14-pgextwlist   # PG 14

Preload:

shared_preload_libraries = 'pgextwlist';

Usage

pgextwlist: PostgreSQL extension whitelisting

pgextwlist implements extension whitelisting: only explicitly allowed extensions can be installed, and whitelisted extensions are installed with superuser privileges even when requested by non-superusers.

Configuration

Add to postgresql.conf:

local_preload_libraries = 'pgextwlist'
extwlist.extensions = 'hstore,cube,pg_stat_statements'

Or per-role:

ALTER ROLE adminuser SET extwlist.extensions = 'pg_stat_statements, postgis';
ParameterDescription
extwlist.extensionsComma-separated list of whitelisted extensions
extwlist.custom_pathFilesystem path for custom pre/post scripts

Behavior

Non-superusers can install whitelisted extensions:

-- Allowed (hstore is whitelisted)
CREATE EXTENSION hstore;

-- Blocked (not whitelisted)
CREATE EXTENSION earthdistance;
-- ERROR: extension "earthdistance" is not whitelisted

Operations CREATE EXTENSION, DROP EXTENSION, ALTER EXTENSION ... UPDATE, and COMMENT ON EXTENSION are run as superuser for whitelisted extensions.

Custom Scripts

Place scripts in ${extwlist.custom_path}/extname/:

ScriptWhen
before--1.0.sqlBefore installing version 1.0
before-create.sqlBefore CREATE (fallback)
after--1.0.sqlAfter installing version 1.0
after-create.sqlAfter CREATE (fallback)
before-update.sql / after-update.sqlAround ALTER EXTENSION UPDATE
before-drop.sql / after-drop.sqlAround DROP EXTENSION

Custom scripts support template variables: @extschema@, @current_user@, @database_owner@.


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