News for hackers. Stuff that matters.
Re:22-Year-Old PostgreSQL Bug Turned into Remote Code Execution by amluto on Thursday November 12, 2026 @06:32PM (#50475939)
Wow, in my mind this is beyond “code smell” and into code reek!

According to the article, Postgres has an internal Datum that might be a pointer or not a pointer. Okay, this is already a bit risky.

Datum comes along with a small-integer type id. That id is stored separately, presumably for efficiency? Maybe you have lots of Datums and one id and you do this for efficiency. Okay, as long as there is a clear story for why the id stays correctly bound to the datum. The “internal” thing where a bogus AST will cause type confusion makes me think the story here isn’t great.

But then I learn that the type id is something that the code looks up in a system table in the database. I’m speechless. This is the kind of thing that can’t be represented in any safe language because the indication of whether a value is a pointer isn’t even in application memory.

Eww. Maybe the AIs can exhaustively enumerate every code path that might get it wrong and rule them all out in a particular release. Maybe there’s even a Lean program that can verify it. But this is still the kind of design that is wrong by construction and is only okay if every single detail avoids the giant foot-cannon.

Re:22-Year-Old PostgreSQL Bug Turned into Remote Code Execution by koolba on Thursday November 12, 2026 @07:07PM (#50476309)
> This is the kind of thing that can’t be represented in any safe language because the indication of whether a value is a pointer isn’t even in application memory.

Welcome to the wonderful world of high performance low level optimization.

Storing type ids everywhere would double the size small fields and quadruple tiny ones like booleans. It’s also not necessary for most persisted data as you know the columns for a table.

Smaller representation makes reading and writing faster, and it also makes more data fit in memory.

Re:22-Year-Old PostgreSQL Bug Turned into Remote Code Execution by amluto on Thursday November 12, 2026 @09:31PM (#50477352)
Great. So you store a type id separately. But you make that typeid define how to safely read (maybe not interpret, but still read) the data without needing to cross-reference to anything else.

I’ve written plenty of high performance code. You can have safe and high performance.

Re:22-Year-Old PostgreSQL Bug Turned into Remote Code Execution by malisper on Friday November 13, 2026 @03:02AM (#50479924)
> Great. So you store a type id separately. But you make that typeid define how to safely read (maybe not interpret, but still read) the data without needing to cross-reference to anything else.

Yes, that's how it works in Postgres

Re:22-Year-Old PostgreSQL Bug Turned into Remote Code Execution by amluto on Friday November 13, 2026 @09:27AM (#50483995)
Unless the OP is completely wrong, it’s not. The author was able to fairly straightforwardly prepare a statement (thus selecting a type id), execute another statement (changing the meaning of that type id), and then execute the prepared statement (uses the old type id with the new semantics, which had a different idea of whether a particular field was a pointer).
Re:22-Year-Old PostgreSQL Bug Turned into Remote Code Execution by mistrial9 on Thursday November 12, 2026 @07:07PM (#50476316)
its an abstraction in the software architecture