handlers: tighten up /redirect-to target validation - #266
Merged
Conversation
Noticed some very malicious requests getting successful 302 responses from /redirect-to instead of the 403s I expected while peeking at live traffic to https://httpbingo.org, e.g.: /redirect-to?url=http%253A//%255B%253A%253Affff%253A169.254.169.254%255D/latest/meta-data/ /redirect-to?url=http%253A%252F%252F169.254.169.254%252Flatest%252Fmeta-data%252Fiam%252Fsecurity-credentials%252F /redirect-to?url=http%253A%252F%252Flocalhost%253A8080%252Factuator%252Fenv&status_code=302 This tightens up the redirect target validation to require either an absolute or a root-relative URL.
/redirect-to target validation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #266 +/- ##
==========================================
+ Coverage 94.81% 94.83% +0.01%
==========================================
Files 9 9
Lines 2027 2032 +5
==========================================
+ Hits 1922 1927 +5
Misses 62 62
Partials 43 43
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Noticed some very malicious requests getting successful 302 responses from /redirect-to instead of the 403s I expected while peeking at live traffic to https://httpbingo.org, e.g.:
This tightens up the redirect target validation to require either an absolute or a root-relative URL.
Note: This is technically a breaking change.