Repository navigation
Turn proxy trust off for no, off and unknown AIKIDO_TRUST_PROXY values - #812
Open
iacobdaniel wants to merge 1 commit into
Open
iacobdaniel wants to merge 1 commit into
iacobdaniel wants to merge 1 commit into
Conversation
Only 0 and false turned it off, so no, n, off or a typo kept trusting a header any client can set. As with false, the SSRF check then stops treating requests to the app's own host as safe. Numbers and ranges keep trusting the header.
Comment on lines
+56
to
+58
| # Hop counts and proxy ranges trust the header, but don't change which IP is picked. | ||
| is_hop_count = value.isdecimal() and value != "0" | ||
| return is_hop_count or "." in value or ":" in value |
Contributor
There was a problem hiding this comment.
🟡 Medium - Malformed proxy settings containing punctuation still trust spoofable headers
An invalid AIKIDO_TRUST_PROXY value that contains a dot or colon, such as not.a.valid.setting, still makes trust_proxy() return true because the parser tests characters rather than validating an IP range. On a directly exposed deployment, a client can then supply X-Forwarded-For and have that value used as its remote address, allowing it to rotate IPs and bypass per-IP rate limits despite the change's fail-closed intent.
Show fix
Suggested change
| # Hop counts and proxy ranges trust the header, but don't change which IP is picked. | |
| is_hop_count = value.isdecimal() and value != "0" | |
| return is_hop_count or "." in value or ":" in value | |
| # Hop counts and valid proxy ranges trust the header, but don't change which IP is picked. | |
| is_hop_count = value.isdecimal() and value != "0" | |
| if is_hop_count: | |
| return True | |
| try: | |
| import ipaddress | |
| ipaddress.ip_network(value, strict=False) | |
| return True | |
| except ValueError: | |
| return False |
More info - Reply on this comment to give feedback or ignore the issue.
This branch has not been deployed
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.
Only
0andfalseturned off trust in the client IP header.no,n,offor a typo kept trusting a header any client can set.