If your PHP app talks to PostgreSQL through the pg_* helper functions, this is one to patch.
At a glance
- CVE: CVE-2026-17543
- Severity: 9.8 (Critical) at NVD. PHP’s own score is 8.1 (High) on CVSS 4.0. Either way, it’s a SQL injection bug worth taking seriously.
- Affected: PHP 8.2 before 8.2.33, 8.3 before 8.3.33, 8.4 before 8.4.24, and 8.5 before 8.5.9, in the
pgsqlextension’spg_insert(),pg_update(),pg_select()andpg_delete(). - Known exploited: No. It’s not on CISA’s KEV list.
What’s going on
Those four helpers take an array of column-and-value pairs and build the SQL for you. Each value gets escaped with libpq’s PQescapeStringConn() and then wrapped in a PostgreSQL escape string, E'...'. The trouble is that the two disagree about backslashes. With standard_conforming_strings = on, which has been PostgreSQL’s default since 9.1, PQescapeStringConn() leaves \ alone. Inside E'...', though, a backslash escapes the next character.
So an attacker sends a value like zzz\' OR 1=1 --. PHP doubles the quote to '' as it should, but the backslash escapes the first of those two quotes and the second one closes the string. Everything after that runs as SQL. PHP’s advisory shows pg_select() handing back every row in a table this way.
So who’s at risk? Apps that pass user input to pg_insert(), pg_update(), pg_select() or pg_delete(). The bug lives in the conversion code those four helpers share, so queries you run with pg_query_params() or through PDO’s PostgreSQL driver aren’t part of it.
Timeline
- Disclosed: 2026-07-30 (PHP’s advisory went public with the fixed releases)
- Patch released: 2026-07-30 (PHP 8.2.33, 8.3.33, 8.4.24 and 8.5.9)
- CVE published at NVD: 2026-07-30
== UPDATE ==
The July 2026 PHP releases fix it: the helpers now wrap values in plain string constants instead of E'...'.
- Patch available: Yep.
- Fixed in: PHP 8.2.33, 8.3.33, 8.4.24, 8.5.9. Heads-up if you’re on 8.2: its security support ends on 31 Dec 2026, so it’s worth planning a move to a newer branch.
- How to apply: Update PHP through your package manager (or PHP distribution) to the fixed release or anything newer on your branch, then restart your web server and any PHP-FPM pools so every worker loads the new build. As of this write-up, the newest releases are 8.2.36, 8.3.37, 8.4.28 and 8.5.13, and they include later security fixes too. If you use your distro’s PHP packages, install the distro’s security update; distros often backport the fix without bumping to the upstream version number.
- If you can’t patch yet: move any call that takes user input off those four helpers and onto
pg_query_params()with$1,$2placeholders, which sends the values separately from the SQL. It’s a good habit anyway.