Repository navigation
fix(OFJAVA-021): CU-17tkuw60ee6 Apple OAuth response Map (including refresh_token) is passed unmasked in warn log via exception message - #2421
Conversation
…s passed unmasked in warn log via exception message
| log.warn("Apple authorization-code exchange failed for client '{}': HTTP status {}", bundleId, e.getRawStatusCode()); | ||
| throw invalidGrant("Apple rejected the authorization code."); | ||
| } catch (Exception e) { | ||
| log.warn("Apple authorization-code exchange failed for client '{}': {}", bundleId, e.getMessage()); |
There was a problem hiding this comment.
🦩 🔴 Apple OAuth response Map (including refresh_token) is passed unmasked in warn log via exception message
In AppleAuthorizationCodeClient.redeemAndVerify, the catch block that previously logged e.getMessage() (which for RestClientResponseException includes the raw HTTP response body, potentially containing sensitive Apple error diagnostics) was split into two catches: a specific catch (RestClientResponseException e) that logs only the HTTP status code via e.getRawStatusCode(), and a fallback catch (Exception e) that logs only e.getClass().getSimpleName() instead of the exception message. Neither branch logs e.getMessage() or any part of the request/response body, eliminating the risk of leaking client_secret, code, or refresh_token via exception message text. Added the org.springframework.web.client.RestClientResponseException import (already available transitively via Spring's RestClient dependency, no new module required).
🤖 Prompt for AI agents
In openframe-authorization-service-core/src/main/java/com/openframe/authz/service/sso/apple/AppleAuthorizationCodeClient.java around line 80, review and complete this code-review fix: Apple OAuth response Map (including refresh_token) is passed unmasked in warn log via exception message.
What the draft fix changed: In AppleAuthorizationCodeClient.redeemAndVerify, the catch block that previously logged `e.getMessage()` (which for RestClientResponseException includes the raw HTTP response body, potentially containing sensitive Apple error diagnostics) was split into two catches: a specific `catch (RestClientResponseException e)` that logs only the HTTP status code via `e.getRawStatusCode()`, and a fallback `catch (Exception e)` that logs only `e.getClass().getSimpleName()` instead of the exception message. Neither branch logs `e.getMessage()` or any part of the request/response body, eliminating the risk of leaking `client_secret`, `code`, or `refresh_token` via exception message text. Added the `org.springframework.web.client.RestClientResponseException` import (already available transitively via Spring's RestClient dependency, no new module required).
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 92 high — react 👍/👎 to teach the reviewer
Pull request was closed
Closes findings from rule OFJAVA-021 — Apple OAuth response Map (including refresh_token) is passed unmasked in warn log via exception message.
Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.
openframe-authorization-service-core/src/main/java/com/openframe/authz/service/sso/apple/AppleAuthorizationCodeClient.java:80What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.
Run: https://product-hub.flamingo.so/admin/code-review
Run id:
9a25c19f-a499-4571-bb37-da3cba9b8394Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.
ClickUp task: CU-17tkuw60ee6 Sensitive data exposure in application logs (OFJAVA-021) (1 PRs)