You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Hash-keyed sets of file values can make a read or save quadratic #248
Several readers and savers key a hash set or dictionary on values that come from the file. Where those keys can be made to collide, a hostile file can make the work quadratic in its size:
long and ulong keys:
Matroska TargetTypeValue level sets (MatroskaTag, three sites);
Audible and TIFF size maps (AudibleFile, TiffSize);
AppleHeadroom;
IfdGraph.
A 64-bit key hashes as its high half XOR its low half, so every (k << 32) | k hashes to 0.
int and uint keys:MatroskaRewrite's length map, and MP4 track IDs (Mp4ChapterCodec, Mp4PictureSkip).
String keys:
InvolvedPeopleFrame;
ImageGainMap;
Mp4QuickTimeKeys;
the ApeTag item dictionary.
String hashing is not randomized on .NET Framework, where netstandard2.0 runs.
The Matroska save paths moved to comparison-based sets for this reason in the follow-ups branch (#244, #247).
Expected
No read or save takes more than O(n log n) time in a count the file controls, whatever the values. Each site should use a comparison-based structure, or be bounded so that collisions cannot add up. Each one needs a scaling test with colliding keys.
Reopening. PR #249 mentioned this issue as related and still open, but GitHub read its wording ("not closed: #248") as a closing keyword. #249 fixed this only on the Matroska save paths it changed. The sites listed here are untouched.
Another site: Mp4Tag._preservedByType is a Dictionary<uint, List<int>> keyed by the 4-byte type of each unmapped ilst child, and a uint hashes to itself. 56,000 empty atoms whose types collide (a 448 KB file) take about 3.3 s to read, against 48 ms for sequential types.
Activity
decriptor commentedon Dec 4, 2026
Reopening. PR #249 mentioned this issue as related and still open, but GitHub read its wording ("not closed: #248") as a closing keyword. #249 fixed this only on the Matroska save paths it changed. The sites listed here are untouched.
decriptor commentedon Dec 4, 2026
Another site:
Mp4Tag._preservedByTypeis aDictionary<uint, List<int>>keyed by the 4-byte type of each unmappedilstchild, and auinthashes to itself. 56,000 empty atoms whose types collide (a 448 KB file) take about 3.3 s to read, against 48 ms for sequential types.