decoder/mad: limit ID3 tag allocations - #2554
Open
acts-1631 wants to merge 1 commit into
Open
Conversation
| FmtWarning(mad_domain, | ||
| "ID3 tag is too large: {}", | ||
| size); | ||
| return MadDecoderAction::BREAK; |
The mad decoder calls libid3tag directly when libmad reports lost sync. Unlike tag/Id3Load.cxx, this path accepted the tag's declared size and allocated that many bytes in a noexcept function. A ten-byte header can therefore request about 256 MiB and terminate MPD if allocation fails. Apply the same 4 MiB limit before ParseId3() allocates memory. Stop decoding an oversized tag so the same header is not retried.
acts-1631
force-pushed
the
fix/mad-id3-limit
branch
from
August 2, 2026 13:07
2de5201 to
fe5aa22
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.
When libmad reports MAD_ERROR_LOSTSYNC, DecodeNextFrame() checks for an
ID3 header and passes its declared size to ParseId3(). Unlike the normal
tag/Id3Load.cxx path, this decoder-specific path did not enforce the
4 MiB ID3 size limit.
ParseId3() can consequently allocate the full attacker-controlled size
inside a noexcept call chain. A ten-byte ID3 header can declare a tag of
about 256 MiB, causing MPD to terminate if the allocation fails.
Apply the existing 4 MiB policy before calling ParseId3(). Oversized
tags stop this decoder attempt instead of retrying the same header.