-
-
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
Debug assertion panics due to invalid URIs from upstream Hyper #1831
Comments
The In a production build this assert is skipped and a 404 error screen is shown. Maybe it would be better not to use an assert, but give more details what the problem is in debug-mode, using an additional error message and just proceed like in production-mode? |
Even debug asserts indicate that some assumption is made in the code, and since that assert is failing it indicates that an assumption is wrong. There is this comment near the assertion: // In debug, make sure we agree with Hyper. Otherwise, cross our fingers
// and trust that it only gives us valid URIs like it's supposed to. I don't think we should be "crossing our fingers" for production. |
Despite its claims, hyper's correctness is an ongoing challenge for Rocket (see #17) which will likely see us moving away from hyper before a 1.0 release. Rocket works around such issues where it can; this is one such case. We implement our own URI parser because we don't trust hyper's. What you're seeing is a failing cross-validation check that was put in place to detect disagreements between hyper and Rocket. In this case, Hyper is wrong.
This isn't a precise enough analysis of what's going on with this
This comment should be taken tongue-in-cheek, not literally. We take security seriously (hence why we have our own, heavily tested, URI parser), so this "crossing our fingers" is an allusion to the fact that we know hyper may be wrong but that even if it is, it's extremely unlikely to cause issues in this case. We'd still like to detect them. After all, if hyper is really wrong, you're liable to have lots of issues that Rocket simply can't ever hope to work-around while keeping hyper around. In all, I see a few paths forward:
I'm inclined to go with 1. |
I'm wondering if there is some disagreement with the whatwg URL spec and the current reality of what is allowed. I did some testing of what characters browsers will automatically percent-encode, and what they wont. It seems that chromium, firefox, and internet explorer all consider |
Yes, this is the case with several major browsers - and it turns out there is an open issue about
Yeah, maybe. It's really unfortunate that it's not possible to validate input against any of the current specifications and also be compatible with the behavior of major browsers. In principle I expect at least WHATWG to eventually match up with browsers, but I don't see a lot of recent interest/progress on this particular point. |
I was implementing a web proxy server for a website and my app was crashing in debug mode because one of the request has '[' in it. However it works on my browser and in release mode. Is it ok to remove the debug assert and replace it with a warn or error log instead? |
Description
Using any rocket server I attempted to visit a url with
[
in the path. I get a "Connection Reset" error in my browser and the rocket log fills with the following:To Reproduce
Visit
http://localhost:8000/[
Expected Behavior
Rocket returns a 404 since the route does not exist.
Environment:
Additional Context
This came up due to a malformed js
fetch
that accidentally requestedhttp://localhost:8000/[object%20Object]
. I reduced the url to the part that causes the panic.The text was updated successfully, but these errors were encountered: