p PatchFirst

CVE-2025-59734

CVE-2025-59734 · Heap-buffer-overflow write in FFmpeg SANM process_ftch

This page contains facts from public vulnerability sources. Check the original advisory before updating.

It is possible to cause an use-after-free write in SANM decoding with a carefully crafted animation using subversion <2. When a STOR chunk is present, a subsequent FOBJ chunk will be saved in ctx->stored_frame. Stored frames can later be referenced by FTCH chunks. For files using subversion < 2, the undecoded frame is stored, and decoded again when the FTCH chunks are parsed. However, in process_frame_obj if the frame has an invalid size, there’s an early return, with a value of 0.  This causes the code in decode_frame to still store the raw frame buffer into ctx->stored_frame. Leaving ctx->has_dimensions set to false. A subsequent chunk with type FTCH would call process_ftch and decode that frame obj again, adding to the top/left values and calling process_frame_obj again. Given that we never set ctx->have_dimensions before, this time we set the dimensions, calling init_buffers, which can reallocate the buffer in ctx->stored_frame, freeing the previous one. However, the GetByteContext object gb still holds a reference to the old buffer. Finally, when the code tries to decode the frame, codecs that accept a GetByteContext as a parameter will trigger a use-after-free read when using gb. GetByteContext is only used for reading bytes, so at most one could read invalid data. There are no heap allocations between the free and when the object is accessed. However, upon returning to process_ftch, the code restores the original values for top/left in stored_frame, writing 4 bytes to the freed data at offset 6, potentially corrupting the allocator’s metadata. This issue can be triggered just by probing whether a file has the sanm format. We recommend upgrading to version 8.0 or beyond.

CVSS 8.7 · High · EPSS 0.2% · Fix available

Published
Updated

Stack: system

Affected products and versions

  • ffmpeg

    Versions
    • ≥ 4d7c609be37dc57d31527c8c9e5945dc9491a7cd, < 8.0: Affected (custom)
    • ≥ 7.1.1, < 8.0: Affected (semver)

    Update to 8.0

  • libav Ubuntu:Pro:14.04:LTS

    Versions
    • 6:0.8.7-1ubuntu2
    • 6:9.10-1ubuntu1
    • 6:9.10-1ubuntu2
    • 6:9.10-1ubuntu5
    • 6:9.10-1ubuntu6
    • 6:9.10-1ubuntu7
    • 6:9.11-2ubuntu1
    • 6:9.11-2ubuntu2
    • 6:9.13-0ubuntu0.14.04.1
    • 6:9.14-0ubuntu0.14.04.1
    • 6:9.16-0ubuntu0.14.04.1
    • 6:9.18-0ubuntu0.14.04.1
    • 6:9.20-0ubuntu0.14.04.1
    • 6:9.20-0ubuntu0.14.04.1+esm1
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • ffmpeg Ubuntu:Pro:16.04:LTS

    Versions
    • 7:2.7.2-1build1
    • 7:2.8.1-1ubuntu1
    • 7:2.8.2-1ubuntu1
    • 7:2.8.3-1
    • 7:2.8.4-1
    • 7:2.8.4-1ubuntu1
    • 7:2.8.4-1ubuntu2
    • 7:2.8.4-1ubuntu3
    • 7:2.8.4-1ubuntu4
    • 7:2.8.6-1ubuntu1
    • 7:2.8.6-1ubuntu2
    • 7:2.8.8-0ubuntu0.16.04.1
    • 7:2.8.10-0ubuntu0.16.04.1
    • 7:2.8.11-0ubuntu0.16.04.1
    • 7:2.8.14-0ubuntu0.16.04.1
    • 7:2.8.15-0ubuntu0.16.04.1
    • 7:2.8.15-0ubuntu0.16.04.1+esm1
    • 7:2.8.17-0ubuntu0.1
    • 7:2.8.17-0ubuntu0.1+esm1
    • 7:2.8.17-0ubuntu0.1+esm2
    • 7:2.8.17-0ubuntu0.1+esm3
    • 7:2.8.17-0ubuntu0.1+esm4
    • 7:2.8.17-0ubuntu0.1+esm5
    • 7:2.8.17-0ubuntu0.1+esm6
    • 7:2.8.17-0ubuntu0.1+esm7
    • 7:2.8.17-0ubuntu0.1+esm8
    • 7:2.8.17-0ubuntu0.1+esm9
    • 7:2.8.17-0ubuntu0.1+esm10
    • 7:2.8.17-0ubuntu0.1+esm11
    • 7:2.8.17-0ubuntu0.1+esm12
    • 7:2.8.17-0ubuntu0.1+esm13
    • 7:2.8.17-0ubuntu0.1+esm14
    • 7:2.8.17-0ubuntu0.1+esm15
    • 7:2.8.17-0ubuntu0.1+esm16
    • 7:2.8.17-0ubuntu0.1+esm17
    • 7:2.8.17-0ubuntu0.1+esm18
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • ffmpeg Ubuntu:Pro:18.04:LTS

    Versions
    • 7:3.3.4-2
    • 7:3.3.4-2build3
    • 7:3.4-2ubuntu2
    • 7:3.4-4
    • 7:3.4-4build1
    • 7:3.4.1-1
    • 7:3.4.1-1build1
    • 7:3.4.2-1
    • 7:3.4.2-1build1
    • 7:3.4.2-2
    • 7:3.4.4-0ubuntu0.18.04.1
    • 7:3.4.6-0ubuntu0.18.04.1
    • 7:3.4.8-0ubuntu0.2
    • 7:3.4.11-0ubuntu0.1
    • 7:3.4.11-0ubuntu0.1+esm1
    • 7:3.4.11-0ubuntu0.1+esm2
    • 7:3.4.11-0ubuntu0.1+esm3
    • 7:3.4.11-0ubuntu0.1+esm4
    • 7:3.4.11-0ubuntu0.1+esm5
    • 7:3.4.11-0ubuntu0.1+esm6
    • 7:3.4.11-0ubuntu0.1+esm7
    • 7:3.4.11-0ubuntu0.1+esm8
    • 7:3.4.11-0ubuntu0.1+esm9
    • 7:3.4.11-0ubuntu0.1+esm10
    • 7:3.4.11-0ubuntu0.1+esm11
    • 7:3.4.11-0ubuntu0.1+esm12
    • 7:3.4.11-0ubuntu0.1+esm13
    • 7:3.4.11-0ubuntu0.1+esm14
    • 7:3.4.11-0ubuntu0.1+esm15
    • 7:3.4.11-0ubuntu0.1+esm16
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • ffmpeg Ubuntu:Pro:20.04:LTS

    Versions
    • 7:4.1.4-1build2
    • 7:4.2.1-2
    • 7:4.2.1-2ubuntu1
    • 7:4.2.2-1build1
    • 7:4.2.2-1ubuntu1
    • 7:4.2.4-1ubuntu0.1
    • 7:4.2.4-1ubuntu0.1+esm1
    • 7:4.2.7-0ubuntu0.1
    • 7:4.2.7-0ubuntu0.1+esm1
    • 7:4.2.7-0ubuntu0.1+esm2
    • 7:4.2.7-0ubuntu0.1+esm3
    • 7:4.2.7-0ubuntu0.1+esm4
    • 7:4.2.7-0ubuntu0.1+esm5
    • 7:4.2.7-0ubuntu0.1+esm6
    • 7:4.2.7-0ubuntu0.1+esm7
    • 7:4.2.7-0ubuntu0.1+esm8
    • 7:4.2.7-0ubuntu0.1+esm9
    • 7:4.2.7-0ubuntu0.1+esm10
    • 7:4.2.7-0ubuntu0.1+esm11
    • 7:4.2.7-0ubuntu0.1+esm12
    • 7:4.2.7-0ubuntu0.1+esm13
    • 7:4.2.7-0ubuntu0.1+esm14
    • 7:4.2.7-0ubuntu0.1+esm15
    • 7:4.2.7-0ubuntu0.1+esm16
    • 7:4.2.7-0ubuntu0.1+esm17
    • 7:4.2.7-0ubuntu0.1+esm18
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • ffmpeg Ubuntu:22.04:LTS

    Versions
    • 7:4.4-6ubuntu5
    • 7:4.4.1-2ubuntu1
    • 7:4.4.1-3ubuntu1
    • 7:4.4.1-3ubuntu2
    • 7:4.4.1-3ubuntu3
    • 7:4.4.1-3ubuntu5
    • 7:4.4.2-0ubuntu0.22.04.1
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • ffmpeg Ubuntu:24.04:LTS

    Versions
    • 7:6.0-6ubuntu1
    • 7:6.0-9ubuntu1
    • 7:6.1-2ubuntu1
    • 7:6.1-3ubuntu1
    • 7:6.1-4ubuntu1
    • 7:6.1-5ubuntu1
    • 7:6.1.1-1ubuntu1
    • 7:6.1.1-3ubuntu1
    • 7:6.1.1-3ubuntu5
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • ffmpeg Ubuntu:25.10

    Versions
    • 7:7.1.1-1ubuntu1
    • 7:7.1.1-1ubuntu2
    • 7:7.1.1-1ubuntu3
    • 7:7.1.1-1ubuntu4
    • 7:7.1.1-1ubuntu4.1
    • 7:7.1.1-1ubuntu4.2
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

Original sources

Check your server →