mandiant / mandiant/macos-UnifiedLogs
Bound chunkset uncompressed size before allocating
@puffyCid is already working on this.
Since Jul 26, 2026.
- Dominant language
- Rust
- Stars
- 376
- Forks
- 43
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 8
Description
## Summary
`ChunksetChunk::parse_chunkset` reads the on-disk `chunkset_uncompress_size` (a `u32`) and passes it directly to `lz4_flex::decompress` as the output size:
https://github.com/mandiant/macos-UnifiedLogs/blob/4c4e136e0210ea66fdce1413e6cd9e5aeb3c8a3e/src/chunkset.rs#L43-L77
A small malformed `bv41` chunk can therefore declare a very large output (up to `u32::MAX`) and trigger the corresponding allocation before decompression rejects the data. In a WebAssembly consumer this can terminate the worker and abort the scan; native consumers can experience process memory exhaustion.
This is an availability issue in our downstream use, not a result-integrity issue. I observed it in crate version 0.6.0 and confirmed the same path on current `main` at `4c4e136e0210ea66fdce1413e6cd9e5aeb3c8a3e`. A downstream archive-size cap does not prevent the allocation because it occurs inside this parser after the trace file has already been accepted.
## Suggested hardening
- Reject declared output sizes above a caller- or library-configurable maximum before allocation.
- Where possible, also reject sizes inconsistent with the enclosing chunk/container bounds.
- Add a regression case using tiny compressed input with an oversized declared output.
A configurable limit would preserve support for legitimately large logs while giving constrained/WASM consumers a safe bound.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.