Feature/fake mp4 structural detection - #3242
Open
RajaMuhammadAwais wants to merge 11 commits into
Open
Conversation
RajaMuhammadAwais
force-pushed
the
feature/fake-mp4-structural-detection
branch
from
September 1, 2026 17:55
1327fa4 to
fd0a127
Compare
RajaMuhammadAwais
marked this pull request as draft
September 1, 2026 18:35
RajaMuhammadAwais
marked this pull request as ready for review
September 2, 2026 12:05
Member
|
@RajaMuhammadAwais, could you rebase please? |
RajaMuhammadAwais
force-pushed
the
feature/fake-mp4-structural-detection
branch
from
September 7, 2026 10:41
2374435 to
a183c77
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Please sign (check) the below before submitting the Pull Request:
Link to the related issue:
Describe changes:
Generic Fake-MP4 Structural Detection with Memory-Safety Hardening
Overview
This pull request adds a conservative, generic detector for suspicious HTTP responses that resemble ISO Base Media File Format (ISO-BMFF) / MP4 containers but contain an unusually large private
uuidbox instead of normal playable media data.The detection is based on file-structure evidence only. It does not depend on domains, IP addresses, filenames, User-Agent strings, malware names, campaign identifiers, hard-coded UUID values, PowerShell content, or other campaign-specific indicators.
The implementation is inspired by the public Censys research on fake MP4 files being used as payload carriers:
:contentReference[oaicite:0]{index=0}
The detector reports the existing
NDPI_HTTP_SUSPICIOUS_CONTENTrisk because the observed content is structurally inconsistent with a normal playable MP4 file. It does not classify the response as malware by itself.Detection Conditions
The HTTP response is considered suspicious only when all of the following structural conditions are satisfied:
ftyp.uuidbox is present.Content-Lengthheader is present.Content-Length.moovormdatbox has been observed.This combination is intended to distinguish a suspicious carrier-like structure from an ordinary MP4 file containing small UUID metadata.
Streaming and Fragmentation Support
The parser processes the response body incrementally across TCP packets.
It supports:
ftyp,uuid, and other top-level boxes.Only an incomplete 8-byte or 16-byte MP4 box header is temporarily retained. Box payloads are skipped according to their declared size and are never copied, decrypted, executed, or stored.
This keeps memory usage independent of the carrier payload size.
Content-Length Validation
The detector uses
Content-Lengthonly when it can be parsed safely and unambiguously.The following cases do not generate the structural alert:
Content-Length.Content-Lengthheaders.This is intentional. Without a reliable total body size, a file-level dominance ratio would be unreliable and could produce false positives.
Chunked or unknown-length responses are therefore conservatively ignored by this specific heuristic.
Parser Resource Limits
The MP4 parser uses bounded arithmetic and resource limits:
The cumulative budget prevents an attacker from bypassing a per-box limit by sending many individually valid but collectively excessive boxes.
Memory-Safety Fixes
Additional research-based hardening was added after reviewing the original implementation.
Extended-Size Box Underflow
ISO-BMFF allows a 16-byte extended-size box header when the normal 32-bit size field is
1.Previously, a malformed extended-size declaration smaller than the required 16-byte header could result in: