Commit bf5a6cb
Grok Compression
Fix heap buffer overflow in MJ2 stco_decompact (CVE pending)
The stco_decompact function writes to tk->samples_[samples_count] without
checking whether samples_count has exceeded the vector size. When a crafted
MJ2 file has samples_per_chunk (from stsc box) larger than the actual sample
count (from stts box), the inner loop writes past the end of the vector.
This is an attacker-controlled linear heap write: both the value (chunk.offset_
from stco box) and length (samples_per_chunk from stsc box) are attacker-
controlled 32-bit fields from the file.
Fix (defense in depth):
1. Add bounds check in stco_decompact inner loop to stop before OOB write
2. Validate samples_per_chunk in stsc_decompact against actual sample count,
rejecting inconsistent files early
Reported-by: Claude / Ada Logics1 parent 0a1e165 commit bf5a6cb
1 file changed
Lines changed: 14 additions & 2 deletions
Lines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
548 | 548 | | |
549 | 549 | | |
550 | 550 | | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
551 | 558 | | |
552 | | - | |
| 559 | + | |
553 | 560 | | |
554 | 561 | | |
555 | 562 | | |
556 | | - | |
| 563 | + | |
557 | 564 | | |
558 | 565 | | |
559 | 566 | | |
| |||
627 | 634 | | |
628 | 635 | | |
629 | 636 | | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
630 | 642 | | |
631 | 643 | | |
632 | 644 | | |
| |||
0 commit comments