NewsCrawler.org

Turning a 22-year-old PostgreSQL type-confusion bug into remote code execution

This is the third part of the series "Systemic Risks in the Managed PostgreSQL Industry". The author describes a 22-year-old zero-day in PostgreSQL core, a new class of type-confusion[1] vulnerabilities. He found it while exploiting memory-corruption bugs in PostgreSQL extensions, starting with pg_clickhouse[2], which translates ClickHouse values into native PostgreSQL values. The vendor of pg_clickhouse fixed the bug the author reported on 23 June.

The article explains how PostgreSQL stores values. A value sits in a Datum[3], an 8-byte carrier that does not record its own type. The type is identified by an OID[4] that points to a row in the pg_type system catalog, and output functions trust the values and flags around the Datum.

In the TLDR section, the author describes changing the type of one field in a composite type and asking PostgreSQL to read the value back. He says this type confusion gave one of the most reliable memory-corruption exploits he has seen.

Read the original mehmetince.netDiscussion

Discussion

Commenters mostly argue that the exploit needs an authenticated database account, so it is closer to privilege escalation than remote code execution, mainly relevant for multi-tenant databases. Others say the write-up is long and may mix human and AI writing, while some praise the detailed account of PostgreSQL internals.

Sources

Published: First seen: Читать по-русски

Open as a page