back to article Critical PostgreSQL bug tied to zero-day attack on US Treasury

A high-severity SQL injection bug in the PostgreSQL interactive tool was exploited alongside the zero-day used to break into the US Treasury in December, researchers say. 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 …

  1. The Man Who Fell To Earth Silver badge
    WTF?

    DOGE is a PostgreSQL bug?

    Who'd have thought.

    1. Anonymous Coward
      Trollface

      Re: DOGE is a PostgreSQL bug?

      This bug? no, that's BigBalls and his leet publicly accessible write credentials to the db skillz.

      Archive: 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. veti Silver badge

        Re: DOGE is a PostgreSQL bug?

        Errr... What exactly did Elon have to do with software used at the US Treasury last year?

        1. Anonymous Coward
          Anonymous Coward

          Re: DOGE is a PostgreSQL bug?

          The commentards missed the mark by miles, but for one small thing.

          Emperor Elon said that the US government doesn't use any SQL databases.

          Which I knew was nonsensical, as we had tons of PostgreSQL and Oracle databases that I monitored the patch level of.

          Made a statement based upon an assessment that was, to put it gently, based upon a hilariously erroneous view of reality.

          As for this, hairy zero day attack that'll get patched quickly enough, such always get pushed to the high priority list due to an actual attack involving that bug.

          Anonymous, lest I get a visit that they'd briefly not enjoy.

  2. b0llchit Silver badge
    WTF?

    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.

    1. Charlie Clark Silver badge

      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.

      1. AthanSpod

        Re: Exposed psql?

        As soon as it became clear how this worked I was screaming "why would you run SQL statements that way?". *Especially* because the part of this doing the scripting is a PHP script, and you could just use a prepared statement with that rather than risking any shenanigans at all the the CL psql command !

        1. Charlie Clark Silver badge

          Re: Exposed psql?

          Right, but note that the real bug is in the way Postgres handles escaping, so there could be problems even then, but you probably won't be given a shell.

    2. kmorwath

      Re: Exposed psql?

      Or you just need a vulnerable server reachable by psql? psql does work over a network to access a remote Postgres SQL database.

      1. klh

        Re: Exposed psql?

        That would give you arbitrary code execution on the machine you are running psql on. Not very useful.

        1. kmorwath

          Re: Exposed psql?

          As I read the bug it allows SQL injections because the server relies on the client for input sanitizations. And these SQL injections happen on the server, not locally. You may not achieve an RCE, but it's still a big vulnerability.

          1. Charlie Clark Silver badge

            Re: Exposed psql?

            Sanitisation is only part of the job, the escaping is done by Postgres code. However, there is no real need to have a psql client on the server or accessible by it. That just makes the bug easier to exploit.

  3. Anonymous Coward
    Anonymous Coward

    Thank god the US government doesn't use SQL then

    "This retard thinks the government uses SQL" - Elon Musk via X

    1. Brewster's Angle Grinder Silver badge
      Joke

      He could be right: all their systems could predate SQL...

      1. Wzrd1

        "He could be right: all their systems could predate SQL..."

        OK, then this bug couldn't happen, since it involved SQL.

        Some systems do indeed predate SQL, they use a fair number of mainframes. Many other systems do use various SQL databases, from Postrge to Oracle and others in between. Wouldn't be shocked to see some old btrieve ones too. The magic trick is making sure everything is up to date in software update patches.

    2. richardnpaul

      Someone should respond to that tweet with "This retard doesn't think that the government uses SQL"

  4. SparkE

    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?

    1. Charlie Clark Silver badge

      Re: Did anyone tell Elon?

      Better call Little Bobby Tables!

    2. Anonymous Coward
      Anonymous Coward

      Re: Did anyone tell Elon?

      That'll never happen. Everyone knows, "The Emperor is never wrong".

      Even money, as we speak, DOGE is running around deleting every SQL database that they find, just to ensure the Emperor is always right.

  5. hx

    I used to subscribe to the postgresql developers list

    And it was refreshing compared to other projects. They are fully aware of the seriousness of their work and that the database is used for Important Data. The only drama was one developer's health scare.

  6. klh

    Clickbaity

    Kind of clickbaity title. _Technically_ true since psql is part of Postgres, but nobody with a sane setup has to run and deploy the bugfix.

    Piping output from a PHP script into psql has to be the stupidest way to pwn yourself I've seen in a while.

  7. shayneoneill

    DB education is hopelessly absent.

    Can I please , one day, stop having to flag sql interpolation bugs from jr or stupid developers. No, "but I escaped it" is not enough. Theres a reason there are multiple escape implementations in PHPs mysql escape code, because its always been a risky approach.

    All modern DB libraries (And by modern I mean "More recent than 25 years ago") support prepared queries. Use it. Its not a complete guarantee (theres all sorts of ways you can goof an SQL insert) but it makes 99% of SQL injection bugs moot.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Other stories you might like