Skip to content

Commit bf64b52

Browse files
catenacybervictorjulien
authored andcommitted
http2: better compression against decompression bombs
Ticket: 8513 Suricata decides at 2 levels if a http2 flow is doing a compression bomb. There is a direct computation when one chunk of TCP data is being parsed. In this case, do not take the ratio into account, just use the size of the decompressed data, so that if we get a big chunk of TCP data like 1 MiB, and a not so high ratio of 200, we do not trigger the debug assertion in util-file.c about 64MiB The other case stays unchanged : when accumulating over the lifetile of a flow with multiple txs, take into account the compression ratio, so that a flow of many txs, having a super high (brotli) compression ratio, ends up classified as a compression bomb. (For example, having 100 txs each turning a 100 byte input into a 700 KiB one)
1 parent 9aaa6f7 commit bf64b52

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

rust/src/http2/decompression.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ fn http2_decompress<'a>(
146146
let mut offset = 0;
147147
decoder.get_mut().set_position(0);
148148
output.resize(HTTP2_DECOMPRESSION_CHUNK_SIZE, 0);
149-
let max_len = DEFAULT_BOMB_RATIO * input.len() as u64;
150149
loop {
151150
match decoder.read(&mut output[offset..]) {
152151
Ok(0) => {
@@ -155,8 +154,7 @@ fn http2_decompress<'a>(
155154
Ok(n) => {
156155
offset += n;
157156
if offset == output.len() {
158-
if output.len() + HTTP2_DECOMPRESSION_CHUNK_SIZE > max_len as usize
159-
&& output.len() > unsafe { HTTP2_COMPRESSION_BOMB_LIMIT as usize }
157+
if output.len() > unsafe { HTTP2_COMPRESSION_BOMB_LIMIT as usize }
160158
{
161159
return Err(io::Error::new(
162160
io::ErrorKind::OutOfMemory,

0 commit comments

Comments
 (0)