Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2025-15667

CVE-2025-15667: GPAC MP4Box Use-After-Free Vulnerability

CVE-2025-15667 is a use-after-free vulnerability in GPAC MP4Box affecting the gf_isom_nalu_sample_rewrite function. This flaw allows local attackers to trigger a double free condition. Learn the technical details and mitigation.

Published:

CVE-2025-15667 Overview

CVE-2025-15667 is a double free vulnerability in GPAC, an open-source multimedia framework, affecting versions up to 2.5-DEV. The flaw resides in the gf_isom_nalu_sample_rewrite function within src/isomedia/avc_ext.c, part of the MP4Box component. Manipulation of the nalu_out_bs argument triggers a double free condition [CWE-119]. The vulnerability requires local access and low-privileged authentication for exploitation. A public proof-of-concept has been disclosed, and a patch is available under commit f29f955f2a3b5e8e507caad3e52319f961bf37bf.

Critical Impact

Local attackers with low privileges can trigger a double free in MP4Box, potentially causing memory corruption or denial of service when processing malicious MP4 files.

Affected Products

  • GPAC versions up to and including 2.5-DEV
  • MP4Box component (src/isomedia/avc_ext.c)
  • Applications embedding the GPAC ISO media library for NALU sample rewriting

Discovery Timeline

  • 2026-07-06 - CVE-2025-15667 published to NVD
  • 2026-07-06 - Last updated in NVD database

Technical Details for CVE-2025-15667

Vulnerability Analysis

The vulnerability exists in GPAC's MP4Box NAL Unit (NALU) sample rewriting logic. The gf_isom_nalu_sample_rewrite function in src/isomedia/avc_ext.c mishandles memory tied to the nalu_out_bs bitstream argument. When an error path is taken during NALU rewriting, the underlying buffer can be freed once by the function's cleanup logic and again by the caller, producing a double free condition.

Double free vulnerabilities corrupt heap metadata and can lead to unpredictable process state, crashes, or in some cases attacker-controlled memory writes. The issue is classified under [CWE-119] for improper restriction of operations within the bounds of a memory buffer. Exploitation requires local access to the host with a low-privileged account and no user interaction beyond invoking MP4Box against a crafted file.

Root Cause

The root cause is missing ownership handling of the nalu_out_bs output bitstream when gf_isom_nalu_sample_rewrite exits along an error path with mdia->in_nalu_rewrite still set. Without extracting the buffer via gf_bs_get_content_no_truncate before returning, subsequent cleanup code frees memory that is later freed again by a different code path.

Attack Vector

An attacker with local access supplies a malformed MP4 file to a GPAC utility such as MP4Box, particularly when using the -cat operation that exercises NALU rewriting. Processing the crafted input drives the code into the vulnerable error path, triggering the double free.

c
// Security patch in src/isomedia/avc_ext.c
// Source: https://github.com/gpac/gpac/commit/f29f955f2a3b5e8e507caad3e52319f961bf37bf
 	if (sei_suffix_bs)
 		gf_bs_del(sei_suffix_bs);
 
+	if (e && mdia->in_nalu_rewrite) {
+		// avoid double free later
+		u8 *output;
+		u32 outSize, allocSize;
+		gf_bs_get_content_no_truncate(mdia->nalu_out_bs, &output, &outSize, &allocSize);
+	}
+
 	mdia->in_nalu_rewrite = GF_FALSE;
 	return e;
 }

The patch extracts the buffer contents on the error path so ownership is transferred out of the bitstream, preventing the second free. A companion fix in src/isomedia/box_code_base.c adds the missing GF_ISOM_SAMPLE_GROUP_AV1S case to a free routine to avoid related memory issues:

c
// Security patch in src/isomedia/box_code_base.c
// Source: https://github.com/gpac/gpac/commit/f29f955f2a3b5e8e507caad3e52319f961bf37bf
 	case GF_ISOM_SAMPLE_GROUP_RAP:
 	case GF_ISOM_SAMPLE_GROUP_TELE:
 	case GF_ISOM_SAMPLE_GROUP_SAP:
+	case GF_ISOM_SAMPLE_GROUP_AV1S:
 		gf_free(entry);
 		return;
 	case GF_ISOM_SAMPLE_GROUP_SEIG:

Detection Methods for CVE-2025-15667

Indicators of Compromise

  • Unexpected crashes or SIGABRT signals from MP4Box or GPAC-based tooling when processing MP4 files with embedded H.264/H.265 NAL units.
  • Heap corruption messages such as double free or corruption in system logs or dmesg output tied to GPAC processes.
  • MP4 sample files sourced from untrusted locations that contain malformed NALU sample groups or truncated AVC/HEVC configuration boxes.

Detection Strategies

  • Enable AddressSanitizer (ASan) or Valgrind when running GPAC in test or triage environments to surface double free events at the point of failure.
  • Inventory hosts and containers running GPAC or MP4Box and compare installed versions against 2.5-DEV and later patched builds using MP4Box -version.
  • Monitor for invocation of MP4Box with the -cat argument against files originating from untrusted network shares, uploads, or email attachments.

Monitoring Recommendations

  • Log process execution and command-line arguments for GPAC binaries on servers that perform automated media processing.
  • Alert on repeated abnormal terminations of GPAC processes, which may indicate exploitation attempts or reliability regressions.
  • Track file-system reads of MP4 assets by MP4Box from staging directories where user-supplied media is stored.

How to Mitigate CVE-2025-15667

Immediate Actions Required

  • Upgrade GPAC to a build that includes commit f29f955f2a3b5e8e507caad3e52319f961bf37bf or later from the GPAC repository.
  • Restrict local access to systems running MP4Box so that only trusted, authenticated users can execute the binary.
  • Avoid processing untrusted MP4 inputs with MP4Box until the patched version is deployed, particularly workflows using -cat.

Patch Information

The fix is committed to the GPAC repository under commit f29f955f. Rebuild GPAC from source at or after this commit, or install a distribution package that incorporates the fix. Additional context is available in GitHub Issue #3403 and the VulDB CVE-2025-15667 entry.

Workarounds

  • Run MP4Box inside a sandbox or container with minimal privileges and no access to sensitive data when patching is not immediately possible.
  • Reject or pre-validate MP4 inputs using an alternative parser before handing files to GPAC, dropping files with malformed NALU structures.
  • Disable automated media pipelines that invoke GPAC on user-supplied content until the patched build is rolled out.
bash
# Verify installed GPAC version and rebuild from the patched commit
MP4Box -version

git clone https://github.com/gpac/gpac.git
cd gpac
git checkout f29f955f2a3b5e8e507caad3e52319f961bf37bf
./configure && make -j"$(nproc)" && sudo make install

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.