-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
illegal header name from httparse #2534
Comments
I'm also not quite sure how to disable this, I'm still getting after putting
into my any advice? edit: it seems the library will panic unconditionally of |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
It just seems you cannot simply replace external dependency by cloning it and specifying a local path, because there could be other packages depending on it and they will pull unmodified version => hence the conflict Let's get back on track on what would be the best way to fix the panic issue in once again - unconditional panic on bad input in a library is very-very-very bad... |
This comment has been minimized.
This comment has been minimized.
Some actual code that reproduces the issue would be helpful. I believe the logic panics because it expects the logic in the http crate to agree with the logic in the httparse crate with respect to valid syntax. |
The reproduction is in the panic message, which contains the header name sent:
|
Then it seems like this is a bug in httparse somehow producing a "header name" of |
I'm not sure this is applicable to hyper http server, I noticed this issue when using hyper's http client on a broad spectrum of inputs |
It was not supposed to happen ever, that's why it's a panic. |
@let4be Could you give us some code to repro the issue? Maybe the HTTP message that was parsed? That would be helpful. |
This comment has been minimized.
This comment has been minimized.
To help understand what is triggering the problem, could you help us with a little more information? What version of The reason I ask for the full HTTP response is that if I try to make some mock responses with that string as a header name, I just see a The purpose of this panic is to notice if |
I cannot provide an exact dump of http response, this was lost unfortunately and I'm running a locally fixed version right now that does not crash... If we absolutely need this in order to fix an issue I may try to go back and run my crawler on unfixed version of hyper that panics(and probably it will "crash" eventually in a couple of hours of web browsing stumbling on this defective web site again) |
mmm... I'm using
does not seem to work, complaining about I will try to dig more tomorrow |
I believe you should be able to wrap |
Been running for quite a while and finally it paniced again(after like 6h+ of running)... but my
hyper is called a couple of levels deep in
any advice? edit: nvm, my code was compiled with
rerunning with "unwind" |
I think I got it... this code reproduces the issue:
|
Checking Here's start of the response:
|
Thing is we may as well feed complete binary garbage to hyper at any point and it still should handle this gracefully without panicing by returning So I'm cautious there are panics throughout hyper's code... |
Should that be parsed into headers as it's not correct HTTP? I think that should return an error. |
Probably there should be an option somewhere about how strict we want to follow http standard, and if we still can parse something malformed and this option is on( |
Yes, hyper doesn't generally try to panic on garbage data from the network. As explained in an earlier comment, the panic is not that the bytes are bad, the panic is that two parts of hyper disagreed on the validity. You can see this panic as an assertion test of the internals. |
Hyper shouldn't panic regardless. Any non-local assertion should be handled gracefully. That is, if you can determine from the immediate surrounding code that an assertion will never fail, then you might be okay, otherwise, handle it gracefully. There is no excuse for doing otherwise, especially in networked software. |
That said, I think we can change this to something better here. We still want to notice when the two parts disagree, and when under unit tests it probably should still panic, so we notice and fix it. And when not under test, since it's still a bug, it should log an |
I think it's best to keep the panic, personally. There are other cases where we found panics in h2 or hyper or whatever and we just fixed those. Saying that it shouldn't panic ever is in my opinion a little bit grandstanding, as tokio will catch that at task boundary anyway. |
All browsers and many HTTP libs support that, AFAIK most of them do so by default and don't provide a setting. Note that httparse is already more lax than the RFCs, too. |
If we ever replace the panic by a returned error, please at least make that its own error kind and not a normal parse error, make it an error that literally states that this is a bug inside Hyper and/or its dependencies, that an invariant is broken and that this should be investigated ASAP. |
FWIW the bug is fixed in httparse 1.4.1. |
I completely forgot about this but chatting with @Geal this weekend I was reminded that RFC 7230 actually says that LF may also be accepted in addition to CRLF:
So that's why httparse supports LF too (just writing this in case someone is curious about this stuff). |
My saying that hyper should never panic isn't an attempt to gain favor, it's an assertion about what reliable networking software should do. A panic in hyper has disastrous effects, even in the client. Consider the following request handler in some framework. #[get("/")]
fn handler(db: Db, client: &Client) -> Result<()> {
db.start_expensive_computation().await?;
let value = client.get(Uri::from_static("http://some-url.org")).await.unwrap_or_default();
db.end_expensive_computation(value).await?;
Ok(())
} What happens if
And this isn't just the application author misplacing trust in This is bad, and treating it as anything but is unequivocally harmful.
If you continue to disagree and consider panics in hyper okay, then this fact should be documented so that users can make their own decisions about which libraries to use. I am saddened by the handling of this issue. This demonstrates to me an unwillingness to take responsibility for security-sensitive bug reports. My comment indicating the sensitive nature of this bug report is now hidden and marked as "disruptive content," when I would consider it anything but. I restate it now, in hopes that it is not again silenced: "If this report is correct, this needs a CVE and an immediate fix. This is a trivial DoS vector with extreme ease of execution. I am stunned that this issue remains open and ignored." |
Just to make sure I understand, is your position that any bug that could result in a panic in any library that could conceivably be used in a webserver mandates the assignment of a CVE with a high severity score because it "introduces a trivial DoS vulnerability"? |
No, of course not. You've taken my words out of context. I've never stated that all panics "introduce a trivial DoS vulnerability" nor that they merit a higher severity score. There's nothing wrong, security-wise, with hyper panicking before it starts accepting requests, for instance, or in some recoverable book-keeping thread with no importance to serving or handling requests. Debatably, there might be nothing wrong with it panicking ever as long as it is clearly documented. However, if an undocumented panic can occur in the main serving loop and directly impact request serving, then yes, a CVE is merited for the reasons I've outlined above. The severity depends on if, and if so, how easily, the panic can be triggered accidentally or purposefully by the user of the library, external actors, or both. In this case, the panic is likely to occur in a main serving loop, was triggered accidentally, and can be triggered trivially by an external actor, making it particularly bad. To clarify further, when I said "a panic in hyper" in my previous comments, I was implicitly qualifying it as "a panic in hyper [in a component likely to appear in a serving loop]." |
To wrap up, this specific issue (the parse error) is fixed in a new httparse release. You can get by running The problem was that httparse introduced the ability to parse HTTP responses without a reason-phrase, but had a bug in how it handled those when only followed by Because the original issue is fixed, I'm going to close this issue. The other part that has been discussed in this issue is around the internal assertion panicking. I've opened #2546 to track changing that with something more appropriate. |
@seanmonstar What is your stance on issuing a CVE? Do you understand the security implications of this bug? |
Why do we have this defined as a panic?
hyper/src/proto/h1/role.rs
Line 36 in dbea771
hyper/src/proto/h1/role.rs
Line 47 in dbea771
hyper/src/proto/h1/role.rs
Line 60 in dbea771
Even if under
debug_assertions
this library has no right to panic as it's completely normal for it to be used on invalid input(I use it in a broad web crawler and web is full of surprises - good and bad). It should always simply return an error back to the user if anything bad happenedas I understand it
panics
are reserved for unrecoverable errors, and because this is a library it has no right to panic and crash client code... Error "unrecoverability" is completely at library's user discretionThe text was updated successfully, but these errors were encountered: