text stringlengths 0 1.99k |
|---|
MJK[!,G_!T0@8F,&UF(F%=X5/UL1+YM1@'6!'FE,HEHQAKN+;(C*]8E4;_>Z6 |
M6)'&_N[?9AG2J=$L\055K\_N:GAY!K_1[K>T/`9B9<]=FO9M2ZN^@C#C*U"[ |
M3FF+7;7<@!*OZ<8XP#LA5>8"*6$M+M1:7ZK'M7=?/KS:+`7PQT&SWOBRN6'< |
M'2^Q[4QD&5W%D>23V72%[G:OHO:4K(_PT(1Z8<DR1,3"-*Q(<*ZKV/@7V5K! |
M(8?G(#63W:`HL,H/7.::GZ[&YU\P*5@</`DVD-YL)+$[A>C0S>&?GBL?W!)0 |
M2C>+#Q*EQ$Y-<MA\+RW"0./^Q6Y2"'UW:$N7`)Z+SBJ(2V%\0?4^40SISRP. |
M/J.H*.E$RVQIV\0=!1-'E-.1;&+GF,*]>#9';6VIX*"&SS8B2$?ARB)6HN5Q |
MU!Z>#1"VIY,>*?73AX.EGMD81PC>6<4KGM.[VNX/8ZSXO9U4'CX/GX?/P^?A |
M\_!Y^#Q\'CX/GX?/P^?A\_!Y^#Q\'CX/GX?/P^?A\_!Y^#Q\'CX/GX?/P^?A |
-,_/S_P/JI`YL``@&`0`` |
` |
end |
|=[ EOF ]=---------------------------------------------------------------=| |
==Phrack Inc.== |
Volume 0x10, Issue 0x47, Phile #0x08 of 0x11 |
|=-----------------------------------------------------------------------=| |
|=-----------=[ World of SELECT-only PostgreSQL Injections: ]=-----------=| |
|=--------------------=[ (Ab)using the filesystem ]=---------------------=| |
|=-----------------------------------------------------------------------=| |
|=-------------------------=[ Maksym Vatsyk ]=---------------------------=| |
|=-----------------------------------------------------------------------=| |
-- Table of contents |
0 - Introduction |
1 - The SQLi that started it all |
1.0 - Target info |
1.1 - A rather trivial injection |
1.2 - No stacked queries for you |
1.3 - Abusing server-side lo_ functions |
1.4 - Not (entirely) a superuser |
1.5 - Looking for a privesc |
2 - PostgreSQL storage concepts |
2.0 - Tables and Filenodes |
2.1 - Filenode format |
2.2 - Table metadata |
2.3 - Cold and Hot Data storages |
2.4 - Editing filenodes offline |
3 - Updating the PostgreSQL data without UPDATE |
3.0 - Identifying target table |
3.1 - Search for the associated Filenode |
3.2 - Reading and downloading Filenode |
3.3 - Extracting table metadata |
3.4 - Making ourselves a superuser |
3.5 - Flushing Hot storage |
4 - SELECT-only RCE |
4.0 - Reading original postgresql.conf |
4.1 - Choosing a parameter to exploit |
4.2 - Compiling malicious library |
4.3 - Uploading the stuff back to the server |
4.4 - Reload successful |
5 - Conclusions |
6 - References |
7 - Source code |
--[ 0 - Introduction |
This article tells the story of how a failed attempt to exploit a basic |
SQL injection in a web API with the PostgreSQL DBMS quickly spiraled into |
3 months of researching database source code and (hopefully) helping to |
create several new techniques to pwn Postgres hosts in restrictive |
contexts. Let's get into the story, shall we? |
--[ 1 - The SQLi that started it all |
---[ 1.0 - Target info |
The target web app was written in the Golang Gin[0] framework and used |
PGX[1] as a DB driver. What is interesting about the application is the |
fact that it is a trusted public data repository - anyone can query all |
data. The updates, however, are limited to a trusted set of users. |
This means that getting a SELECT SQL injection will have no impact on the |
application, while DELETE and UPDATE ones will still be critical. |
Unfortunately, I am not allowed to disclose the source code of |
the original application, but it can be roughly boiled down to this |
example (with data and tables changed to something artificial): |
-------------------------------------------------------------------------- |
package main |
import ( |
"context" |
"fmt" |
"log" |
"net/http" |
"github.com/gin-gonic/gin" |
"github.com/jackc/pgx/v4/pgxpool" |
) |
var pool *pgxpool.Pool |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.