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

content-encoding negotiation should be disabled when the response headers already contain content-encoding #151

Closed
derek-zhou opened this issue May 22, 2023 · 3 comments

Comments

@derek-zhou
Copy link

If the response has content-length but not content-encoding, Bandit will go ahead to compress the response body, but leak the original uncompressed content-length. This results in client seeing the response as truncated.

If the response has content-encoding as gzip already, Bandit seems to do a second compression.

Ideally, Bandit should detect the presence of content-encoding in the response header, and skip compression if it is present. When there is no content-encoding in the headers, Bandit should remove the old content-length header, if any, and replace it with the compressed content-length.

According to:

https://ninenines.eu/docs/en/cowboy/2.6/manual/cowboy_compress_h/

Cowboy does it. As of now, I have to disable compression globally, which is sub-optimal.

@derek-zhou derek-zhou changed the title content-encoding negotiation should be disabled when the response headers already contains content-encoding/content-length content-encoding negotiation should be disabled when the response headers already contain content-encoding May 22, 2023
@mtrudel
Copy link
Owner

mtrudel commented May 24, 2023

Yep, agreed that this should be better handled as you suggest. I'm also having to be more aware of the returned headers (specifically Connection: close) for the issue underlying #149, so I'll make sure to fold both of these into a consolidated solution coming the next release (a few days away, I think).

Thanks!

@mtrudel
Copy link
Owner

mtrudel commented Jun 12, 2023

Slated to be fixed in #165

@mtrudel
Copy link
Owner

mtrudel commented Jun 14, 2023

Fixed in #165. Please reopen if further work here is required!

@mtrudel mtrudel closed this as completed Jun 14, 2023
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