目标达成 感谢每一位支持者 — 我们达成了 100% 目标!

目标: 1000 元 · 已筹: 1325

100%

CVE-2024-27304 PoC — pgx 安全漏洞

来源
关联漏洞
标题:pgx 安全漏洞 (CVE-2024-27304)
Description:pgx是适用于 Go 的 PostgreSQL 驱动程序和工具包。 pgx存在安全漏洞,该漏洞源于通过协议消息大小溢出可以进行SQL注入。
Description
PoC of "DEF CON 32 - SQL Injection Isn't Dead Smuggling Queries at the Protocol Level - Paul Gerste"
介绍
# CVE-2024-27304-PoC

## references
- [DEF CON 32 - SQL Injection Isn't Dead Smuggling Queries at the Protocol Level - Paul Gerste](https://www.youtube.com/watch?v=Tfg1B8u1yvE)
- [pgx SQL Injection via Protocol Message Size Overflow](https://github.com/advisories/GHSA-mrww-27vc-gghv)

## webapp
A simple web application with login functionality. Only administrators can log in.

This application uses PostgreSQL and pgx v5.5.3 (vulnerable version).

The attacker attempts to log in by maliciously inserting records into the users table. However, since placeholders are used, traditional SQL injection does not work.

## exploit
PostgreSQL Message Formats: https://www.postgresql.org/docs/17/protocol-message-formats.html

The exploit depends on the message format that pgx sends to the database server when executing SQL.
By default, pgx sends a prepared statement with `P(Parse)` and then sends parameters with `B(Bind)`.

If the following configuration is set, pgx sends the interpolated query with `Q(Query)`:
```go
cfg.ConnConfig.DefaultQueryExecMode = pgx.QueryExecModeSimpleProtocol
```

You can view the actual messages using tcpdump with the `-X` option.

### scripts

- `Q_simple.py`: Causes overflow with `Q(Query)`. Assumes the attacker has complete knowledge of the query being executed (if black-box, bruteforce is required).
- `Q_nop_sled.py`: Causes overflow with `Q(Query)`. Succeeds in exploitation within 5 attempts.
- `B_simple.py`: Causes overflow with `B(Bind)`. Assumes the attacker has complete knowledge of the query being executed (in my opinion, `B(Bind)` exploitation is difficult in black-box scenarios).

### Notes
- A large amount of memory is required to successfully execute the exploit.
- This exploit sends an extremely large payload and may cause a DoS. As mentioned in the video, **do not execute this exploit against third-party systems**.
文件快照

登录后查看神龙缓存的 POC 文件快照

登录查看
备注
    1. 建议优先通过来源进行访问。
    2. 本地 POC 快照面向订阅用户开放;当原始来源失效或无法访问时,本地镜像作为订阅权益的一部分提供。
    3. 持续抓取、验证、维护这份 POC 档案需要不少投入,因此本地快照已纳入付费订阅。您的订阅是让这份资料能继续走下去的关键,由衷感谢。 查看订阅方案 →