chore(server): restrict gzip deflated body size
Restricts the size of the decompressed request body when using gzip.pull/24376/head
parent
867aba847a
commit
19b0ff284d
|
@ -188,6 +188,10 @@ async fn parse_body(req: hyper::Request<Body>) -> Result<Bytes, ApplicationError
|
|||
if ungzip {
|
||||
use std::io::Read;
|
||||
let decoder = flate2::read::GzDecoder::new(&body[..]);
|
||||
|
||||
// Read at most MAX_SIZE bytes to prevent a decompression bomb based
|
||||
// DoS.
|
||||
let mut decoder = decoder.take(MAX_SIZE as u64);
|
||||
let mut decoded_data = Vec::new();
|
||||
decoder
|
||||
.read_to_end(&mut decoded_data)
|
||||
|
|
Loading…
Reference in New Issue