Share
## https://sploitus.com/exploit?id=AEA142CD-2632-5ACB-A514-3C2DC73E351F
# CVE-2025-9951 FFmpeg JPEG 2000 exploitation research

This repository documents the path from a validation-passing JPEG 2000
component-mapping mismatch to controlled callback execution in FFmpeg.

The included proof of concept is intentionally constrained. It works against
the matching local research build when launched through GDB with the documented
deterministic allocator layout. GDB only launches the process and supplies the
environment: it does not set breakpoints, modify memory or registers, skip
cleanup, or invoke the callback. This is **not** a portable, standalone, or
remote exploit.

## Contents

- `WRITEUP.md` โ€” full exploitation journey,
  including failed approaches and future work.
- `poc.jp2` โ€” verified 450-byte deterministic-layout PoC.
- `generate_poc.py` โ€” self-contained payload generator for the documented
  layout.
- `geometry.py` โ€” helper used to find the cleanup-safe `112x18` geometry.
- `run_poc.gdb` โ€” batch GDB launch script.

## Verified result

On the research system, the PoC overwrites `AVBuffer.free` with libc `system`
and `AVBuffer.opaque` with a pointer to this benign command:

```text
touch /tmp/cve_2025_9951_small_rce.gdb_proof
```

The payload SHA-256 is:

```text
d429a7fe323f3dcb2b0b98e097ddf2ef3f83ca9d7e656e6e70d2bf0d01180069
```

## Reproduction

Requirements:

- the matching vulnerable, symbolized FFmpeg research build;
- GDB on x86-64 Linux;
- OpenJPEG's `opj_compress` to regenerate the payload;
- the glibc and binary layout described in the write-up.

Generate the file:

```bash
python3 generate_poc.py
```

Run it, replacing the binary path if necessary:

```bash
gdb -q -batch \
  -x run_poc.gdb \
  --args ./ffmpeg-vulnerable/ffmpeg_g
```

Verify the benign marker:

```bash
test -e /tmp/cve_2025_9951_small_rce.gdb_proof
```

The fixed addresses in `generate_poc.py` are deliberate and permitted only by
the deterministic first-exploit model. Address portability and native heap
stability remain open problems.

## Safety

Use only in an isolated environment against systems you own or are explicitly
authorized to test. The marker-file command is included to demonstrate control
without opening a shell or contacting another host.