# CVE-2024-0985: PostgreSQL non-owner REFRESH MATERIALIZED VIEW CONCURRENTLY executes arbitrary SQL

> An attacker can execute arbitrary SQL as a superuser by tricking them into refreshing a malicious materialized view concurrently.

- **Severity:** High 8.0 (`CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 8 Feb 2024
- **Updated:** 13 Jun 2025
- **Also known as:** ALPINE-CVE-2024-0985, ALSA-2024:0950, ALSA-2024:0951, ALSA-2024:0956, ALSA-2024:0973, ALSA-2024:0974, ALSA-2024:0975, AZL-34279, AZL-35111, BELL-CVE-2024-0985, BIT-postgresql-2024-0985, CLEANSTART-2026-FA69444, CLSA-2024-1711492417, DEBIAN-CVE-2024-0985, DLA-3764-1, DSA-5622-1, DSA-5623-1, ECHO-6ae2-fea4-43ea, GHSA-4828-5p9m-g4ff, JLSEC-2026-46, MGASA-2024-0043, RHSA-2024:0950, RHSA-2024:0951, RHSA-2024:0956, RHSA-2024:0973, RHSA-2024:0974, RHSA-2024:0975, RHSA-2024:0988, RHSA-2024:0990, RHSA-2024:0992, RHSA-2024:1017, RHSA-2024:1069, RHSA-2024:1070, RHSA-2024:1071, RHSA-2024:1195, RHSA-2024:1240, RHSA-2024:1241, RHSA-2024:1314, RHSA-2024:1315, RHSA-2024:1348, RHSA-2024:1422, RHSA-2024:1426, RHSA-2024:1428, RHSA-2024:1429, RHSA-2024:1437, RLSA-2024:0950, RLSA-2024:0951, RLSA-2024:0956, RLSA-2024:0973, RLSA-2024:0974, RLSA-2024:0975, SUSE-SU-2024:0520-1, SUSE-SU-2024:0522-1, SUSE-SU-2024:0523-1, SUSE-SU-2024:0540-1, SUSE-SU-2024:0541-1, SUSE-SU-2024:0542-1, SUSE-SU-2024:0546-1, SUSE-SU-2024:0550-1, SUSE-SU-2024:0551-1, SUSE-SU-2024:0552-1, UBUNTU-CVE-2024-0985, USN-6656-1, USN-6656-2, openSUSE-SU-2024:13669-1, openSUSE-SU-2024:13670-1, openSUSE-SU-2024:13671-1, openSUSE-SU-2024:13672-1

## What is CVE-2024-0985?

CVE-2024-0985 is a high-severity vulnerability in Postgresql Postgresql, published on 8 Feb 2024. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official 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. Versions before PostgreSQL 16.2, 15.6, 14.11, 13.14, and 12.18 are affected.

Weakness: CWE-271 (Privilege Dropping / Lowering Errors)

## Which versions are affected by CVE-2024-0985?

1 open source package ship an affected version, including postgresql. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `postgresql` | Bitnami | From 12.0.0 | 12.18.0, 13.14.0, 14.11.0, 15.6.0 |
| `pg_repack` | AlmaLinux:8 | All versions | 1.4.6-3.module_el8.6.0+2758+4f4474df |
| `pg_repack` | AlmaLinux:8 | All versions | 1.4.6-3.module_el8.6.0+2760+1746ec94 |
| `pg_repack` | AlmaLinux:8 | All versions | 1.4.6-3.module_el8.6.0+3094+eb237fb8 |
| `pg_repack` | AlmaLinux:8 | All versions | 1.4.6-3.module_el8.6.0+3095+ee60d910 |
| `pg_repack` | AlmaLinux:8 | All versions | 1.4.6-3.module_el8.9.0+3704+f1f917ce |
| `pg_repack` | AlmaLinux:8 | All versions | 1.4.8-1.module_el8.8.0+3487+43ec1b9f |
| `pgaudit` | AlmaLinux:8 | All versions | 1.4.0-7.module_el8.9.0+3740+0e74851f.alma.1 |
| `pgaudit` | AlmaLinux:8 | All versions | 1.5.0-1.module_el8.6.0+2760+1746ec94 |
| `pgaudit` | AlmaLinux:8 | All versions | 1.5.0-1.module_el8.6.0+3095+ee60d910 |
| `pgaudit` | AlmaLinux:8 | All versions | 1.7.0-1.module_el8.8.0+3487+43ec1b9f |
| `postgres-decoderbufs` | AlmaLinux:8 | All versions | 0.10.0-2.module_el8.6.0+2758+4f4474df |
| `postgres-decoderbufs` | AlmaLinux:8 | All versions | 0.10.0-2.module_el8.6.0+2760+1746ec94 |
| `postgres-decoderbufs` | AlmaLinux:8 | All versions | 0.10.0-2.module_el8.6.0+3094+eb237fb8 |
| `postgres-decoderbufs` | AlmaLinux:8 | All versions | 0.10.0-2.module_el8.6.0+3095+ee60d910 |
| `postgres-decoderbufs` | AlmaLinux:8 | All versions | 0.10.0-2.module_el8.9.0+3704+f1f917ce |
| `postgres-decoderbufs` | AlmaLinux:8 | All versions | 1.9.7-1.Final.module_el8.8.0+3487+43ec1b9f |
| `postgresql` | AlmaLinux:8 | All versions | 10.23-4.module_el8.9.0+3736+952d0ed7.alma.1 |
| `postgresql` | AlmaLinux:8 | All versions | 12.18-1.module_el8.9.0+3740+0e74851f.alma.1 |
| `postgresql` | AlmaLinux:8 | All versions | 13.14-1.module_el8.9.0+3738+d55e2165.alma.1 |
| `postgresql` | AlmaLinux:8 | All versions | 15.6-1.module_el8.9.0+3739+514705ed.alma.1 |
| `postgresql-contrib` | AlmaLinux:8 | All versions | 10.23-4.module_el8.9.0+3736+952d0ed7.alma.1 |
| `postgresql-contrib` | AlmaLinux:8 | All versions | 12.18-1.module_el8.9.0+3740+0e74851f.alma.1 |
| `postgresql-contrib` | AlmaLinux:8 | All versions | 13.14-1.module_el8.9.0+3738+d55e2165.alma.1 |
| `postgresql-contrib` | AlmaLinux:8 | All versions | 15.6-1.module_el8.9.0+3739+514705ed.alma.1 |
| `postgresql-docs` | AlmaLinux:8 | All versions | 10.23-4.module_el8.9.0+3736+952d0ed7.alma.1 |
| `postgresql-docs` | AlmaLinux:8 | All versions | 12.18-1.module_el8.9.0+3740+0e74851f.alma.1 |
| `postgresql-docs` | AlmaLinux:8 | All versions | 13.14-1.module_el8.9.0+3738+d55e2165.alma.1 |
| `postgresql-docs` | AlmaLinux:8 | All versions | 15.6-1.module_el8.9.0+3739+514705ed.alma.1 |
| `postgresql-plperl` | AlmaLinux:8 | All versions | 10.23-4.module_el8.9.0+3736+952d0ed7.alma.1 |
| `postgresql-plperl` | AlmaLinux:8 | All versions | 12.18-1.module_el8.9.0+3740+0e74851f.alma.1 |
| `postgresql-plperl` | AlmaLinux:8 | All versions | 13.14-1.module_el8.9.0+3738+d55e2165.alma.1 |
| `postgresql-plperl` | AlmaLinux:8 | All versions | 15.6-1.module_el8.9.0+3739+514705ed.alma.1 |
| `postgresql-plpython3` | AlmaLinux:8 | All versions | 10.23-4.module_el8.9.0+3736+952d0ed7.alma.1 |
| `postgresql-plpython3` | AlmaLinux:8 | All versions | 12.18-1.module_el8.9.0+3740+0e74851f.alma.1 |
| `postgresql-plpython3` | AlmaLinux:8 | All versions | 13.14-1.module_el8.9.0+3738+d55e2165.alma.1 |
| `postgresql-plpython3` | AlmaLinux:8 | All versions | 15.6-1.module_el8.9.0+3739+514705ed.alma.1 |
| `postgresql-pltcl` | AlmaLinux:8 | All versions | 10.23-4.module_el8.9.0+3736+952d0ed7.alma.1 |
| `postgresql-pltcl` | AlmaLinux:8 | All versions | 12.18-1.module_el8.9.0+3740+0e74851f.alma.1 |
| `postgresql-pltcl` | AlmaLinux:8 | All versions | 13.14-1.module_el8.9.0+3738+d55e2165.alma.1 |

Products: Postgresql Postgresql.

## How do I fix CVE-2024-0985?

Upgrade postgresql to a fixed version for your release line: 12.18.0, 13.14.0, 14.11.0 or 15.6.0.

## Is CVE-2024-0985 being exploited?

There is no known exploitation of CVE-2024-0985 in the wild and no public exploit code.

## Other vulnerabilities in Postgresql Postgresql

- [CVE-2013-1902](https://insights.sbomify.com/CVE-2013-1902/): Information disclosure in n/a (critical 10.0)
- [CVE-2013-1903](https://insights.sbomify.com/CVE-2013-1903/): Information disclosure in n/a (critical 10.0)
- [CVE-2007-3279](https://insights.sbomify.com/CVE-2007-3279/): Privilege escalation in n/a (critical 10.0)
- [CVE-2002-1399](https://insights.sbomify.com/CVE-2002-1399/): Integer overflow in n/a (critical 10.0)
- [CVE-2016-3065](https://insights.sbomify.com/CVE-2016-3065/): Information disclosure in n/a (critical 9.1)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-0985 and fix it if it is affected.

What it is: CVE-2024-0985 is a high-severity vulnerability in Postgresql Postgresql, published on 8 Feb 2024. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2024-0985 in the wild and no public exploit code.

Affected packages and fixed versions:
- postgresql (Bitnami): affected from 12.0.0; fixed in 12.18.0, 13.14.0, 14.11.0, 15.6.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-0985/ (Markdown: https://insights.sbomify.com/CVE-2024-0985/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-0985
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-0985
- OSV: https://osv.dev/vulnerability/CVE-2024-0985

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-0985/
Summaries are generated and may contain mistakes; the official description above is the record.
