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

目标: 1000 元 · 已筹: 1336

100%

CVE-2022-35737 PoC — SQLite 输入验证错误漏洞

来源
关联漏洞
标题: SQLite 输入验证错误漏洞 (CVE-2022-35737)
Description:SQLite是一款轻型的数据库,是遵守ACID的关系型数据库管理系统。 SQLite 3.39.2之前版本存在安全漏洞,该漏洞源于辅助C语言的API
Description
Stranger strings: CVE-2022-35737
介绍
# CVE-2022-35737

Integer overflow in SQLite3 `sqlite3_str_vappendf` function.

CVSS 6.7 AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:H

CVE-2022-35737 was introduced in SQLite version 1.0.12 and fixed in release
3.39.2, available on July 21, 2022. It is exploitable on 64-bit systems, and
exploitability depends on how the program is compiled: arbitrary code execution
is confirmed when the library is compiled without stack canaries, but
unconfirmed when stack canaries are present; denial-of-service is confirmed in
all cases.

Large string inputs to the `sqlite3_str_vappendf` function can cause signed
integer overflow when the format specifier is `%q`, `%Q`, or `%w`. This can
cause user-controlled data to be written beyond the bounds of a stack-allocated
buffer, resulting in program crash, infinite loop, or possible arbitrary code
execution.

This repository contains proof-of-concept code that demonstrate the
exploitation of the vulnerability.

## Proofs-of-Concept

### `snprintf-good-example.c`

Demonstrate that `sqlite3_snprintf` correctly escapes all existing single-quote
characters and adds a leading and trailing single quote to a short string.

Expected outcome:

```
$ ./snprintf-good-example
src: hello, 'world'!
dst: 'hello, ''world''!'
```

### `snprintf-crash.c`

Demonstrate that `sqlite_snprintf` crashes when called with sufficiently large
strings.

Expected outcome: SIGSEGV

```
$ ./snprintf-crash
Segmentation fault (core dumped)
```

### `snprintf-control-pc.c`

Demonstrate that it is possible to control the length of the buffer overflow to
overwrite targeted data on the stack, like the stack canary and saved return
address.

Expected outcome: SIGABRT

```
$ ./snprintf-control-pc
*** stack smashing detected ***: terminated
Aborted (core dumped)
```

### `snprintf-livelock.c`

Demonstrate that it is possible to cause the vulnerable program to loop nearly
endlessly (2^64 iterations).

Expected outcome: loop endlessly (on a reasonable timescale)

```
$ ./snprintf-livelock
<no output>
^C
```

### `pdo-sqlite3-quote-poc.php`

Demonstrate that CVE-2022-35737 is reachable from the PHP interpreter when run
with non-default memory limits.

Expected outcome: SIGSEGV

```
$ php pdo-sqlite3-quote-poc.php
Segmentation fault (core dumped)
```

## Dockerfile

If desired, the proofs-of-concept can be executed in a Docker container that
has dependencies pinned to the vulnerable version of the SQLite library.

```
$ docker build -t cve-2022-35737 .
$ docker run -it --rm cve-2022-35737 /bin/bash
root@289cef859649:/poc# ./snprintf-crash
Segmentation fault (core dumped)
```
文件快照

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

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