-
Notifications
You must be signed in to change notification settings - Fork 45
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
Handle invalid URIs #68
Comments
Would changing the patch in #64 to simply |
The problem with returning If the request is for an invalid URL, I'm not sure how this should be handled, since we won't be able to properly identify the correct scheme or path. One way that I've looked at handling this is to ignore the It seems to me the safest approach is to simply continue to have invalid requests result in a 500 error. If you need different behavior, maybe a separate middleware to handle a redirect to a known-safe URL if the requested URL is invalid would be appropriate. |
We've had a few events in our error monitoring due to an automatic scanner checking for log4j vulnerabilities using
X-Forwarded-For
:This happens because this
request_uri
does not handle the URI being invalid:rack-canonical-host/lib/rack/canonical_host/redirect.rb
Lines 86 to 88 in 134f76f
I think instead what should probably happen is that the error is caught and the request considered not canonical (thus triggering a redirect) since implicitly the canonical URL must be a valid URI so whatever the requests current url is cannot be canonical.
I'm happy to have a go at a PR for this if folks agree it should be addressed here
The text was updated successfully, but these errors were encountered: