Repository navigation
[Aikido] Prevent IP spoofing by defaulting trust_proxy() to false - #746
Closed
aikido-autofix[bot] wants to merge 1 commit into
Closed
aikido-autofix[bot] wants to merge 1 commit into
aikido-autofix[bot] wants to merge 1 commit into
Conversation
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.
This patch addresses IP spoofing vulnerabilities by changing the default behavior of the trust_proxy() function to return false, requiring explicit opt-in via the AIKIDO_TRUST_PROXY environment variable to trust forwarding headers. This prevents attackers from bypassing IP-based security controls by spoofing X-Forwarded-For and similar proxy headers. The fix affects aikido_zen/helpers/get_ip_from_request.py and its corresponding test file, with updated test cases validating that proxy headers are not trusted by default and that SSRF detection properly handles untrusted client IPs.
✅ 1 issue fixed by this PR
get_ip_from_request()gives the configured client-IP header precedence over the socket peer whenevertrust_proxy()is true. WhenAIKIDO_TRUST_PROXYis unset,trust_proxy()returns true, and the resolver performs no immediate-peer, trusted-proxy-range, hop-count, or forwarding-chain validation. The WSGI and ASGI adapters pass attacker-supplied headers together with the actual peer address, so a direct client-or a client behind a proxy that preserves the header-can cause the header value to becomeContext.remote_address. Downstream IP-based security decisions use that value as authoritative. In particular, a forged loopback or allowlisted value can satisfy IP-based route authorization, while a forged bypass-listed value skips blocking, rate limiting, firewall checks, vulnerability scanning, and SSRF reporting. Other IP-based controls can be evaded or partitioned using attacker-selected addresses. This does not bypass independent application authentication, and deployments that