Critical PostgreSQL bug tied to zero-day attack on US Treasury
- Reference: 1739542799
- News link: https://www.theregister.co.uk/2025/02/14/postgresql_bug_treasury/
- Source link:
Rapid7's principal security researcher, Stephen Fewer, disclosed CVE-2025-1094 (8.1) on Thursday, saying it was a key part of the exploit chain that also included the BeyondTrust zero-day (CVE-2024-12356).
In fact, CVE-2025-1094 was so important to the chain that the [1]BeyondTrust attack couldn't have been pulled off without it, we're told.
[2]
"Rapid7 discovered that in every scenario we tested, a successful exploit for CVE-2024-12356 had to include exploitation of CVE-2025-1094 in order to achieve remote code execution," [3]said Fewer.
[4]
[5]
"While CVE-2024-12356 was patched by BeyondTrust in December 2024, and this patch successfully blocks exploitation of both CVE-2024-12356 and CVE-2025-1094, the patch did not address the root cause of CVE-2025-1094, which remained a zero-day until Rapid7 discovered and reported it to PostgreSQL."
According to Rapid7's director of vulnerability intelligence, Caitlin Condon, CVE-2025-1094 affects all versions of the PostgreSQL interactive tool, but, fortunately, it isn't particularly simple to exploit. Given the complexity of the exploit pattern, Rapid7 doesn't expect attacks to be carried out away from the BeyondTrust versions already known to be vulnerable.
[6]
She [7]said via Mastodon: "But with the above said, it's clear that the adversaries who perpetrated the December attack really knew the target technology, which is yet another example of a zero-day exploit trend Rapid7 started tracking in 2023."
The vulnerability in the PostgreSQL interactive tool (psql) can lead to arbitrary code execution (ACE) and there is also a technique to exploit it independently from CVE-2024-12356. Rapid7 said BeyondTrust's patch for its zero-day didn't address the root cause of the psql bug, but it does prevent the two from being exploited together.
The psql vulnerability can be exploited because of an incorrect assumption that a [8]SQL injection attack can't be carried out when a malicious input is safely escaped via PostgreSQL's string escaping routines, Fewer said.
[9]
However, the researcher discovered that a malicious input can still be executed by the psql tool under specific conditions as part of a SQL statement.
[10]Mysterious Palo Alto firewall reboots? You're not alone
[11]Have I Been Pwned likely to ban resellers from buying subs, citing 'sh*tty behavior' and onerous support requests
[12]Feds want devs to stop coding 'unforgivable' buffer overflow vulnerabilities
[13]February's Patch Tuesday sees Microsoft offer just 63 fixes
Fewer said: "Because of how PostgreSQL string escaping routines handle invalid UTF-8 characters, in combination with how invalid byte sequences within the invalid UTF-8 characters are processed by psql, an attacker can leverage CVE-2025-1094 to generate a SQL injection."
Running meta-commands can extend psql's functionality, and it's through these that an attacker can feasibly achieve ACE by using the exclamation mark meta-command to execute a shell command on the operating system. Attackers can also use the vulnerability to execute SQL statements of their choosing.
The full [14]technical rundown of both vulnerabilities can be found on AttackerKB, which details all the important indicators of compromise and remediation steps. However, to summarize, users should apply the latest versions, released on February 13, to keep themselves safe.
Condon praised the [15]PostgreSQL team for their cooperation and communication during the disclosure process.
She said: "One teeny tiny last semi-personal note – this is one of the most straightforward disclosure timelines we've been able to put in a [coordinated vulnerability disclosure] blog in a while, which is extra nice (and unfortunately not the norm in recent years) and also makes me extra grateful to the PostgreSQL dev group." ®
Get our [16]Tech Resources
[1] https://www.theregister.com/2024/12/31/us_treasury_department_hacked/
[2] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_security/research&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=2&c=2Z692tYp0bT2mC0zlRIeamQAAAFg&t=ct%3Dns%26unitnum%3D2%26raptor%3Dcondor%26pos%3Dtop%26test%3D0
[3] https://www.rapid7.com/blog/post/2025/02/13/cve-2025-1094-postgresql-psql-sql-injection-fixed/
[4] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_security/research&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44Z692tYp0bT2mC0zlRIeamQAAAFg&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0
[5] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_security/research&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33Z692tYp0bT2mC0zlRIeamQAAAFg&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0
[6] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_security/research&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44Z692tYp0bT2mC0zlRIeamQAAAFg&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0
[7] https://infosec.exchange/@catc0n/113997296172337824
[8] https://www.theregister.com/2024/03/26/fbi_cisa_sql_injection/
[9] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_security/research&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33Z692tYp0bT2mC0zlRIeamQAAAFg&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0
[10] https://www.theregister.com/2025/02/13/palo_alto_firewall/
[11] https://www.theregister.com/2025/02/13/hibp_reseller_ban/
[12] https://www.theregister.com/2025/02/13/fbi_cisa_unforgivable_buffer_overflow/
[13] https://www.theregister.com/2025/02/12/patch_tuesday_february_2025/
[14] https://attackerkb.com/topics/G5s8ZWAbYH/cve-2024-12356/rapid7-analysis
[15] https://www.theregister.com/2025/02/11/microsoft_postgresql_extensions/
[16] https://whitepapers.theregister.com/
Re: DOGE is a PostgreSQL bug?
[1]This bug? no, that's BigBalls and his leet publicly accessible write credentials to the db skillz.
Archive: [2]here
Hay. Elon. This is what happens when you get tweens to write your IT infrastructure without code review because they're 'geniuses', 'genius'.
[1] https://doge.gov/workforce?orgId=7cd300eb-cf3f-47f5-90f1-9e66a8bc8d07
[2] https://archive.is/VM3D3
Exposed psql?
For the underlying bug to be of consequence you have to have psql exposed to be invoked with user-input or your server was already compromised (but then it was already game-over).
I always thought that you never ever had these command-line tools exposed to direct or indirect (external) user input, regardless whether the data is escaped or not. The risk of introducing problems are so high when you give (indirect) access to psql... The tool can do so much that it shouldn't be exposed directly or indirectly to anything touching external users.
And, sure, the underlying bug is bad and we are all happy that it is (will be) fixed. But, some common sense in separation principles could have prevented the chain of events in the first place.
Re: Exposed psql?
Have to agree with you and the real bug is somewhat obscured by some fairly hair-raising deployment practices: it should never really get that far:
$(echo "SELECT COUNT(1) FROM gw_sessions WHERE session_key = $quoted AND session_type = 'sdcust' AND (expiration IS NULL OR expiration>NOW())" | $db)
Where $db = /path/to/psql. I mean, really?
Not only do we have the underlying bug in Postgres, but also quoting to the shell and a requirement for psql locally and apparently without further authentication.
But I'm impressed by the skills of the exploit.
Thank god the US government doesn't use SQL then
"This retard thinks the government uses SQL" - Elon Musk via X
He could be right: all their systems could predate SQL...
Did anyone tell Elon?
I read somewhere last week that Musk mocked people who thought the US government used SQL databases. Maybe he needs to update his?
Re: Did anyone tell Elon?
Better call [1]Little Bobby Tables !
[1] https://xkcd.com/327/
DOGE is a PostgreSQL bug?
Who'd have thought.