title: PostgreSQL non-owner REFRESH MATERIALIZED VIEW CONCURRENTLY executes arbitrary SQL
description: Late privilege drop in REFRESH MATERIALIZED VIEW CONCURRENTLY in PostgreSQL allows an object creator to execute arbitrary SQL functions as the command issuer. The command intends to run SQL functions as the owner of the materialized view, enabling safe refresh of untrusted materialized views. The victim is a superuser or member of one of the attacker's roles. The attack requires luring the victim into running REFRESH MATERIALIZED VIEW CONCURRENTLY on the attacker's materialized view. As part of exploiting this vulnerability, the attacker creates functions that use CREATE RULE to convert the internally-built temporary table to a view. Versions before PostgreSQL 15.6, 14.11, 13.14, and 12.18 are affected. The only known exploit does not work in PostgreSQL 16 and later. For defense in depth, PostgreSQL 16.2 adds the protections that older branches are using to fix their vulnerability.
problem types: Privilege Dropping / Lowering Errors
affected:
{
defaultStatus: unaffected
product: PostgreSQL
vendor: n/a
versions:
lessThan: 15.6, status: affected, version: 15, versionType: rpm
lessThan: 14.11, status: affected, version: 14, versionType: rpm
lessThan: 13.14, status: affected, version: 13, versionType: rpm
lessThan: 12.18, status: affected, version: 0, versionType: rpm
}
metrics:
format: CVSS
cvssV3_1: [
version: 3.1
vectorString: CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H
baseScore: 8
baseSeverity: HIGH
]
workarounds: Use REFRESH MATERIALIZED VIEW without CONCURRENTLY.