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

Panic in server when sending non-ASCII header value #187

Open
5225225 opened this issue Apr 26, 2021 · 5 comments
Open

Panic in server when sending non-ASCII header value #187

5225225 opened this issue Apr 26, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@5225225
Copy link

5225225 commented Apr 26, 2021

Found via fuzzing.

Steps to reproduce:

  1. run the server example (cargo run --example=server)
  2. feed it the bad input (cat crash | nc localhost 8080)

crash is

GET https://example.com HTTP/1.1
Host:ȃ

and as base64 (to avoid encoding issues)

R0VUIGh0dHBzOi8vZXhhbXBsZS5jb20gSFRUUC8xLjEKSG9zdDrIgw0KDQo=

Full backtrace is long, I put it in the below gist.

https://gist.github.com/5225225/dd931721233609b6e6ce39d0705b0119

@Fishrock123
Copy link
Member

We should not accept non-ASCII characters in headers (it is against the http spec as fare as I am aware), but it should be checked before we do things which make this assumption. This is a bug.

@Fishrock123 Fishrock123 added the bug Something isn't working label Apr 29, 2021
@pepoviola
Copy link
Contributor

Hi 👋, I can check the spec and try to draft a pr to fix is non-ascii aren't allowed.

Thx!

@jbr
Copy link
Member

jbr commented Apr 30, 2021

I believe the point about the spec is correct but that means we should respond with an error code, not panic. We should never panic regardless of the spec

@jbr
Copy link
Member

jbr commented May 1, 2021

I believe #172 represents the same issue

@kyrias
Copy link

kyrias commented Sep 9, 2022

The spec currently recommends against non-ASCII header values but the only requirement is that the value is in an encoding that is a superset of ASCII and doesn't contain null, so UTF-8 values are completely valid just discouraged.

It's not unreasonable to handle it by explicitly returning an error though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants