Extension scripts replace objects not belonging to the extension

Some extensions use CREATE OR REPLACE or CREATE IF NOT EXISTS commands. Some don't adhere to the documented rule to target only objects known to be extension members already. An attack requires permission to create non-temporary objects in at least one schema, ability to lure or wait for an administrator to create or update an affected extension in that schema, and ability to lure or wait for a victim to use the object targeted in CREATE OR REPLACE or CREATE IF NOT EXISTS. Given all three prerequisites, the attacker can run arbitrary code as the victim role, which may be a superuser. Known-affected extensions include both PostgreSQL-bundled and non-bundled extensions. PostgreSQL is blocking this attack in the core server, so there's no need to modify individual extensions.

The PostgreSQL project thanks Sven Klemm for reporting this problem.

Version Information

Affected Version Fixed In Fix Published
14 14.5 2022-08-11
13 13.8 2022-08-11
12 12.12 2022-08-11
11 11.17 2022-08-11
10 10.22 2022-08-11

For more information about PostgreSQL versioning, please visit the versioning page.

CVSS 3.0

Overall Score 7.1
Component core server
Vector AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H

Reporting Security Vulnerabilities

If you wish to report a new security vulnerability in PostgreSQL, please send an email to

For reporting non-security bugs, please see the Report a Bug page.