Skip to content

decoder/mad: limit ID3 tag allocations - #2554

Open
acts-1631 wants to merge 1 commit into
MusicPlayerDaemon:v0.24.xfrom
acts-1631:fix/mad-id3-limit
Open

decoder/mad: limit ID3 tag allocations#2554
acts-1631 wants to merge 1 commit into
MusicPlayerDaemon:v0.24.xfrom
acts-1631:fix/mad-id3-limit

Conversation

@acts-1631

Copy link
Copy Markdown
Contributor

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.

FmtWarning(mad_domain,
"ID3 tag is too large: {}",
size);
return MadDecoderAction::BREAK;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants