All your PostgreSQL databases are belong to us
PostgreSQL 8.4.12 had two XML-related vulnerabilities: CVE-2012-3489 allowed error-based XXE to read files and steal Windows hashes, and CVE-2012-3488 allowed arbitrary file read/write via xslt_process(). An authenticated attacker could gain database admin privileges and then execute commands.
Published on agarri.fr
On August 17, 2012, PostgreSQL released a security advisory including patches for CVE-2012-3488 and CVE-2012-3489. This post will describe these vulnerabilities and how to exploit them.
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 the XML parsing functions (xml_parse and xslt_process) did not disable external entity resolution and XSLT document writing, allowing file access.
Impact
An authenticated attacker could read arbitrary files, steal password hashes, write files, and potentially execute commands as the PostgreSQL user.
What the attacker needed
Authenticated access to PostgreSQL; outbound SMB connectivity for hash capture; contrib/xml2 module for XSLT attacks
How it was found
- Connect to PostgreSQL with a low-privilege account.
- Trigger the xml_parse() vulnerability with a crafted XML document containing an external entity pointing to a remote SMB share.
- Capture the NTLM hash from the SMB connection.
- Crack the hash to obtain the password.
- Use the cracked password to connect as the postgres user and dump password hashes.
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 is a database. Two features that process XML (a data format) could be tricked into reading or writing files on the server. An attacker with a low-privilege database account could use these to steal password hashes or take over the database.
What is XXE?
An XML parser resolves entities the attacker defines, reading local files or making the server send requests.