CVE-2021-40574
📋 TL;DR
CVE-2021-40574 is a double-free vulnerability in Gpac's MP4Box binary that allows attackers to cause denial of service, execute arbitrary code, or escalate privileges. This affects users processing malicious text-based media files with vulnerable versions of Gpac. The vulnerability resides in the gf_text_get_utf8_line function in load_text.c.
💻 Affected Systems
- Gpac
- MP4Box
📦 What is this software?
Gpac by Gpac
⚠️ Risk & Real-World Impact
Worst Case
Remote code execution leading to complete system compromise, privilege escalation to root/admin, and persistent backdoor installation.
Likely Case
Denial of service through application crashes when processing malicious media files, potentially disrupting media processing workflows.
If Mitigated
Limited to application crashes with proper sandboxing and privilege separation, preventing system-wide impact.
🎯 Exploit Status
Exploitation requires crafting a malicious media file with specific text content. The double-free vulnerability can be leveraged for memory corruption leading to code execution. Public proof-of-concept exists in GitHub issues.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Fixed in commit 30ac5e5236b790accd1f25347eebf2dc8c6c1bcb and later versions
Vendor Advisory: https://github.com/gpac/gpac/security/advisories
Restart Required: Yes
Instructions:
1. Update Gpac to version after commit 30ac5e5236b790accd1f25347eebf2dc8c6c1bcb
2. Rebuild from source or use updated package from distribution repositories
3. Restart any services using MP4Box
🔧 Temporary Workarounds
Disable text processing
allAvoid processing media files with text tracks or subtitles using MP4Box
mp4box -no-text input.mp4
Sandbox execution
linuxRun MP4Box in a container or sandbox with limited privileges
docker run --rm -v $(pwd):/data gpac mp4box input.mp4
🧯 If You Can't Patch
- Implement strict input validation for media files before processing with MP4Box
- Run MP4Box with minimal privileges (non-root user, seccomp, AppArmor/SELinux profiles)
🔍 How to Verify
Check if Vulnerable:
Check Gpac version: mp4box -version | grep 'GPAC' and compare to affected range 0.9.0-preview to 1.0.1
Check Version:
mp4box -version 2>&1 | grep -i gpac
Verify Fix Applied:
Verify version is newer than commit 30ac5e5236b790accd1f25347eebf2dc8c6c1bcb or check if binary contains the patched load_text.c
📡 Detection & Monitoring
Log Indicators:
- MP4Box segmentation faults
- Memory corruption errors in system logs
- Unexpected process termination of mp4box
Network Indicators:
- Unusual outbound connections from media processing servers
- Large volumes of media file uploads to processing systems
SIEM Query:
process_name="mp4box" AND (event_type="crash" OR exit_code="139")
🔗 References
- https://github.com/gpac/gpac/blob/v0.9.0-preview/src/filters/load_text.c#L232
- https://github.com/gpac/gpac/blob/v0.9.0-preview/src/filters/load_text.c#L304
- https://github.com/gpac/gpac/commit/30ac5e5236b790accd1f25347eebf2dc8c6c1bcb
- https://github.com/gpac/gpac/issues/1897
- https://www.debian.org/security/2023/dsa-5411
- https://github.com/gpac/gpac/commit/30ac5e5236b790accd1f25347eebf2dc8c6c1bcb
- https://github.com/gpac/gpac/issues/1897
- https://www.debian.org/security/2023/dsa-5411