CVE-2023-39417 Postgresql: extension script @substitutions@ within quoting allow sql injection

High 7.5 Published Updated

Attackers with CREATE privileges can execute arbitrary code as superuser via SQL injection in vulnerable extension scripts using specific quoting constructs.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2023-39417?

CVE-2023-39417 is a high-severity SQL injection vulnerability in Debian Debian Linux, published on 11 Aug 2023. Any signed-in user can exploit it over the network, with no action from the victim.

Official description

IN THE EXTENSION SCRIPT, a SQL Injection vulnerability was found in PostgreSQL if it uses @extowner@, @extschema@, or @extschema:...@ inside a quoting construct (dollar quoting, '', or ""). If an administrator has installed files of a vulnerable, trusted, non-bundled extension, an attacker with database-level CREATE privilege can execute arbitrary code as the bootstrap superuser.

Weakness: CWE-89

Which versions are affected by CVE-2023-39417?

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

PackageAffectedFixed in
postgresql BitnamiFrom 11.0.011.21.0, 12.16.0, 13.12.0, 14.9.0, 15.4.0
Linux distribution packages (32)
postgresql12 SUSE:Linux Enterprise High Performance Computing 15 SP1-LTSSAll versions12.16-150100.3.44.1
postgresql14 SUSE:Linux Enterprise Module for Basesystem 15 SP4All versions14.9-150200.5.29.1
postgresql13 SUSE:Linux Enterprise Module for Legacy 15 SP4All versions13.12-150200.5.43.1
postgresql14 SUSE:Linux Enterprise Module for Legacy 15 SP5All versions14.9-150200.5.29.1
postgresql14 SUSE:Linux Enterprise Module for Package Hub 15 SP4All versions14.9-150200.5.29.1
postgresql14 SUSE:Linux Enterprise Module for Package Hub 15 SP5All versions14.9-150200.5.29.1
postgresql14 SUSE:Linux Enterprise Module for Server Applications 15 SP4All versions14.9-150200.5.29.1
postgresql12 SUSE:Linux Enterprise Server 12 SP5All versions12.16-3.42.1
postgresql13 SUSE:Linux Enterprise Server 12 SP5All versions13.12-3.36.1
postgresql14 SUSE:Linux Enterprise Server 12 SP5All versions14.9-3.26.1
postgresql12 SUSE:Linux Enterprise Server 15 SP1-LTSSAll versions12.16-150100.3.44.1
postgresql12 SUSE:Linux Enterprise Server for SAP Applications 12 SP5All versions12.16-3.42.1
postgresql13 SUSE:Linux Enterprise Server for SAP Applications 12 SP5All versions13.12-3.36.1
postgresql14 SUSE:Linux Enterprise Server for SAP Applications 12 SP5All versions14.9-3.26.1
postgresql12 SUSE:Linux Enterprise Server for SAP Applications 15 SP1All versions12.16-150100.3.44.1
postgresql12 SUSE:Linux Enterprise Software Development Kit 12 SP5All versions12.16-3.42.1
postgresql13 SUSE:Linux Enterprise Software Development Kit 12 SP5All versions13.12-3.36.1
postgresql14 SUSE:Linux Enterprise Software Development Kit 12 SP5All versions14.9-3.26.1
postgresql13 SUSE:Manager Proxy 4.2All versions13.12-150200.5.43.1
postgresql14 SUSE:Manager Proxy 4.2All versions14.9-150200.5.29.1
postgresql13 SUSE:Manager Server 4.2All versions13.12-150200.5.43.1
postgresql14 SUSE:Manager Server 4.2All versions14.9-150200.5.29.1
postgresql12 openSUSE:Leap 15.4All versions12.16-150200.8.47.1
postgresql13 openSUSE:Leap 15.4All versions13.12-150200.5.43.1
postgresql14 openSUSE:Leap 15.4All versions14.9-150200.5.29.1
postgresql12 openSUSE:Leap 15.5All versions12.16-150200.8.47.1
postgresql13 openSUSE:Leap 15.5All versions13.12-150200.5.43.1
postgresql14 openSUSE:Leap 15.5All versions14.9-150200.5.29.1
postgresql11 openSUSE:TumbleweedAll versions11.21-1.1
postgresql12 openSUSE:TumbleweedAll versions12.16-1.1
postgresql13 openSUSE:TumbleweedAll versions13.12-1.1
postgresql14 openSUSE:TumbleweedAll versions14.9-1.1

Products include Debian Debian Linux, Postgresql Postgresql, Redhat Enterprise Linux, Redhat Software Collections.

How do I fix CVE-2023-39417?

Upgrade postgresql to a fixed version for your release line: 11.21.0, 12.16.0, 13.12.0 or 14.9.0.

Use parameterised queries everywhere and never build SQL by joining strings. Upgrade affected software first; a web application firewall only buys time. More about SQL injection.

Is CVE-2023-39417 being exploited?

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

All Debian Debian Linux vulnerabilities

Sources

Also known as ALPINE-CVE-2023-39417, AZL-27892, BIT-postgresql-2023-39417, CLEANSTART-2026-JQ15135, CLSA-2023-1695319921, CLSA-2023-1696537563 and 23 more.

Is CVE-2023-39417 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free