Turning a 22-year-old Postgres type-confusion primitive into RCE
A prepared statement kept a composite-type value whose attribute was later altered from uuid to bytea, so at execution the bytea output function interpreted attacker-controlled UUID bytes as a varlena external expanded-object header. A forged header and methods table let the attacker redirect an indirect native call to system(), and a second type confusion through unnest() leaked memory addresses to defeat ASLR.
mehmetince.net
Published on mehmetince.net
Nov 9, 2026
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely ALTER TYPE on a composite attribute changes the type metadata without rewriting values already stored in a prepared statement, so a later output function interprets the old bytes under the new type's rules.
Impact
A lowest-privileged login role could crash the backend and, with a forged object and a leaked address, redirect an indirect call to run a command as the database process; the text notes managed providers block reading process memory, which is why a separate leak was needed.
What the attacker needed
A login role on PostgreSQL; ability to create a temp composite type; ability to prepare and execute a query
How it was found
- Create a one-field composite type whose attribute is a uuid.
- Prepare a query that casts a chosen UUID literal to that composite type.
- Alter the attribute's type to bytea with CASCADE.
- Execute the prepared statement, which crashes the backend.
- Craft the UUID bytes as a fake expanded-object header pointing at a fake methods table.
- Use the same confusion with unnest() to leak memory addresses and defeat ASLR.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
PostgreSQL stores each value together with a note about what type it is, and the code that prints a value trusts that note rather than checking the bytes. Here the note was changed after the value was already saved, so a function expecting binary data read a UUID's bytes as if they were a description of where the real data lives. That let the author point PostgreSQL at a fake structure and make it call a command instead of printing a value.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.