Fix client ip for rate limiting - #4009
Open
joemahady-comm wants to merge 1 commit into
Open
Conversation
…-spoofable-headers / uaa ai-assisted=yes Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens UAA rate-limiting client identification by ensuring the client IP used for bucket selection comes exclusively from HttpServletRequest.getRemoteAddr(), relying on trusted proxy/container configuration (e.g., RemoteIpValve / ForwardedHeaderFilter) to securely interpret forwarding headers rather than trusting spoofable request headers directly.
Changes:
- Updated
RequestInfoImpl#getClientIP()to return onlystripToNull(getRemoteAddr()), removingX-Client-IP,X-Real-IP, andX-Forwarded-Forparsing. - Simplified
RequestInfoImplTestto reflect the new client-IP source (remote address) for rate limiting.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| server/src/main/java/org/cloudfoundry/identity/uaa/ratelimiting/core/http/RequestInfoImpl.java | Removes spoofable header-based client IP resolution; uses getRemoteAddr() only for rate limiting identity. |
| server/src/test/java/org/cloudfoundry/identity/uaa/ratelimiting/core/http/RequestInfoImplTest.java | Updates tests to validate remote-address-based client IP behavior after the security change. |
Comment on lines
+41
to
45
| void getClientIP_remoteAddr() { | ||
| when(mockHSRequest.getRemoteAddr()).thenReturn("Mocked-IP-R "); | ||
| RequestInfo requestInfo = RequestInfoImpl.from(mockHSRequest); | ||
| assertThat(requestInfo).isNotNull(); | ||
| assertThat(requestInfo.getClientIP()).isEqualTo("Mocked-IP-R"); |
Member
|
@joemahady-comm you need to rebase this |
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.
Ticket: client-ip-for-rate-limiting-taken-from-spoofable-headers
Fix: Updated RequestInfoImpl to exclusively rely on request.getRemoteAddr() (dropping X-Client-IP, X-Real-IP, X-Forwarded-For), allowing the underlying configured container proxies (RemoteIpValve or ForwardedHeaderFilter) to handle secure header processing instead of blindly trusting spoofable headers for rate limiting buckets.