Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gzip / zip bomb mitigation #1178

Open
chelyabinsk opened this issue May 11, 2024 · 1 comment
Open

gzip / zip bomb mitigation #1178

chelyabinsk opened this issue May 11, 2024 · 1 comment

Comments

@chelyabinsk
Copy link

chelyabinsk commented May 11, 2024

I think it is a good idea to have a similar check implemented by Python's WebSocket library, as it is a very easy attack. Mainly, check that decompressed size does not exceed some kind of limit when executing HTTP.decode .

A simple example.

First, generate a gzip file. I lifted code from this repo

time dd if=/dev/zero bs=1M count=$((20*1024)) | gzip > ./cake.gzip

When I execute the following I observe a jump in the resource usage, eventually leading to a crash of the julia process.

using HTTP

data = read("cake.gzip")

server = HTTP.serve!() do request::HTTP.Request
   @show request
   @show request.method
   @show HTTP.header(request, "Content-Type")
   @show request.body
   try
       return HTTP.Response(data)
   catch e
       return HTTP.Response(400, "Error: $e")
   end
end

r = HTTP.get("http://127.0.0.1:8081/"; decompress=false)

HTTP.decode(r, "gzip")

Happy to provide further details. I can also try to implement a solution if that's gong to be easier :)

@chelyabinsk chelyabinsk changed the title gzip / zip bomb gzip / zip bomb mitigation May 11, 2024
@bryaan
Copy link

bryaan commented Jun 6, 2024

This also needs to be done for websockets.

#1181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants