Skip to content

Fix client ip for rate limiting - #4009

Open
joemahady-comm wants to merge 1 commit into
cloudfoundry:developfrom
joemahady-comm:TNZGOV-15480
Open

Fix client ip for rate limiting#4009
joemahady-comm wants to merge 1 commit into
cloudfoundry:developfrom
joemahady-comm:TNZGOV-15480

Conversation

@joemahady-comm

@joemahady-comm joemahady-comm commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

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.

…-spoofable-headers / uaa ai-assisted=yes

Co-authored-by: Cursor <cursoragent@cursor.com>
@joemahady-comm joemahady-comm changed the title Implement AI Scan -- MEDIUM -- client-ip-for-rate-limiting-taken-from… Fix client ip for rate limiting Jul 29, 2026
@duanemay
duanemay requested a review from Copilot July 29, 2026 20:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 only stripToNull(getRemoteAddr()), removing X-Client-IP, X-Real-IP, and X-Forwarded-For parsing.
  • Simplified RequestInfoImplTest to 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");
@strehle

strehle commented Jul 30, 2026

Copy link
Copy Markdown
Member

@joemahady-comm you need to rebase this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants