CyberSecBulletin
CVE-2024-7348NVD status: Modified

PostgreSQL: Time-of-check Time-of-use (TOCTOU) Race Condition

CVE-2024-7348 is a high-severity time-of-check time-of-use (TOCTOU) race condition vulnerability in PostgreSQL, with a CVSS 3.1 base score of 7.5 out of 10. It can be exploited remotely over the network by an attacker with a low-privileged account, without any action from a user. The record lists versions 16.4, 15.8, 14.13 as the first without the flaw, so updating PostgreSQL to one of those releases or later removes the exposure. There is no confirmed exploitation so far. EPSS estimates a 1.57% chance of exploitation within 30 days, higher than 76% of scored CVEs.

Next patch cycle

High severity with no evidence of exploitation so far.

What to do

  1. Update PostgreSQL to 16.4 or 15.8 or 14.13 or 13.16, whichever matches your release line, or a later version.
  2. Read the advisory on postgresql.org for workarounds and exact fixed builds.

Affected products and versions

VendorProductAffected versionsFixed in
PostgreSQLPostgreSQL16 up to, but not including, 16.4; 15 up to, but not including, 15.8; 14 up to, but not including, 14.13; 13 up to, but not including, 13.16; before 12.2016.4, 15.8, 14.13, 13.16, 12.20

Version data comes from the organisation that assigned the CVE. Confirm against the vendor advisory before deciding you are unaffected.

How the severity score breaks down

Attack vector
NetworkCan be exploited remotely over a network, including the internet.
Attack complexity
HighSuccess depends on conditions outside the attacker's control.
Privileges required
LowA basic user account is enough.
User interaction
NoneNo action by a victim is required.
Scope
UnchangedImpact stays within the vulnerable component.
Confidentiality
HighAll data handled by the component can be read.
Integrity
HighData or code can be modified at will.
Availability
HighThe component can be taken down completely.

Vector: CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H. Scored by NVD.

Scoring systemScoreSeverityScored by
CVSS 3.18.8HighCNA
CVSS 3.17.5HighNVD

Official description

Time-of-check Time-of-use (TOCTOU) race condition in pg_dump in PostgreSQL allows an object creator to execute arbitrary SQL functions as the user running pg_dump, which is often a superuser. The attack involves replacing another relation type with a view or foreign table. The attack requires waiting for pg_dump to start, but winning the race condition is trivial if the attacker retains an open transaction. Versions before PostgreSQL 16.4, 15.8, 14.13, 13.16, and 12.20 are affected.

Source: the CVE record as published by its numbering authority, via NVD and CVE.org.

The underlying weakness: Time-of-check Time-of-use (TOCTOU) Race Condition

The product checks the state of a resource before using that resource, but the resource's state can change between the check and the use in a way that invalidates the results of the check.

How developers prevent this class of flaw

  • The most basic advice for TOCTOU vulnerabilities is to not perform a check before the use. This does not resolve the underlying issue of the execution of a function on a resource whose state and identity cannot be assured, but it does help to limit the false sense of security given by the check.
  • When the file being altered is owned by the current user and group, set the effective gid and uid to that of the current user and group when executing this statement.
  • Limit the interleaving of operations on files from multiple processes.

More Time-of-check Time-of-use (TOCTOU) Race Condition vulnerabilities (CWE-367)

Timeline

  1. CVE record published.
  2. CISA published its SSVC assessment (exploitation: none, automatable: no, technical impact: total).
  3. Record last changed materially (score, affected products, status or references).

References

Other vulnerabilities in PostgreSQL

All PostgreSQL vulnerabilities

Recent Time-of-check Time-of-use (TOCTOU) Race Condition vulnerabilities

Spotted an error? Tell us.