🛡️ Sentinel: Enforce compressed block size limit#6
Conversation
This change adds a 4MB limit on the size of compressed bzip2 blocks to protect against resource exhaustion attacks. - Added `MAX_COMPRESSED_BLOCK_SIZE` constant (4MB). - Introduced `CompressedBlockLimitExceeded` error variant. - Enforced limit in library's `decompress_block_into` and bz2zstd's worker loop. - Added regression test for the limit. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
🛡️ Sentinel: Enforce compressed block size limit
Identified a potential resource exhaustion vulnerability where maliciously crafted bzip2 files could contain extremely large block ranges, leading to excessive memory allocation. Although the uncompressed size was already limited, the compressed range should also be bounded to ensure system stability.
Changes:
MAX_COMPRESSED_BLOCK_SIZEas 4MB inparallel_bzip2_decoder.Bz2Error::CompressedBlockLimitExceededto the library's error type.decompress_block_intoto check the compressed byte length before processing.bz2zstd's parallel worker loop to perform the same check before callingextract_bits.test_compressed_block_limitto verify the enforcement.This is a defense-in-depth measure that complements the existing uncompressed block size limit.
PR created automatically by Jules for task 15669133312938591188 started by @kassoulet