Repository navigation
bug: stop [REDACTED SECRET] JSON endpoints exposing password hashes and recipients (sfind-7448b854) - #611
Open
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
- UserResource /api/user/all and AppointmentResource /api/appointment/all now return AdminUserView / AdminAppointmentView DTOs with only the fields the AdminPortal renders. - User.getPassword() and User.recipientList are @JsonIgnore; Appointment.user is @JsonIgnore. - User.toString() no longer prints the password hash or associations. - AdminResourceSerializationTest covers both endpoints and the entities. Fixes sfind-7448b8546f40422ea9dbab8d3889cb65
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
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.
Summary
Fixes code-scan finding
sfind-7448b8546f40422ea9dbab8d3889cb65(high):GET /api/user/allandGET /api/appointment/allserialized theUserentity directly, so [REDACTED SECRET]s got every customer's BCrypt hash, fullrecipientList(payee name/email/phone/account number), and account numbers.Admin endpoints now return DTOs (
UserFront/.../resource/dto/) containing only what the AdminPortal renders:The JSON shape the AdminPortal reads (
user.primaryAccount.accountBalance,appointment.user.username, ...) is unchanged, so no frontend change is needed. Dropped from the responses:password,recipientList,authorities/accountNonExpired/etc., accountid/accountNumber, and everything on the embedded appointment user exceptusername.Entity defense-in-depth (in case a
User/Appointmentgets serialized somewhere else later):User.getPassword()->@JsonIgnore(still readable by Spring Security and Thymeleaf; no endpoint deserializesUserfrom JSON)User.recipientList->@JsonIgnore(same as the existingappointmentList/userRoles)Appointment.user->@JsonIgnoreUser.toString()no longer printspassword. I also removedappointmentList/recipientList/userRolesfrom it: printing them triggers lazy loads and would dump recipient PII.Tests: new
AdminResourceSerializationTest(MockMvc standalone + Jackson) checks that both endpoints and both entities leave out the hash,password,recipientListand recipient account number, while keeping the fields the portal uses. It's 5/5 failing onmasterand 5/5 passing on this branch.Verification note: Boot 1.5.4 and its plugins aren't in the offline Maven cache, so I compiled and ran the tests with javac + JUnitCore. The stand-in classpath was Boot 1.5.8 (Spring 4.3.12, Jackson 2.8.10), not a
mvn testrun of the real pom.Duplicate notice: this overlaps open PRs #116 and #123 (both add
@JsonIgnoreon password and edittoString), and #341/#364 (@JsonIgnorerecipientList). It was opened as a new PR under the one-PR-per-ticket rule. Only one of these should land.Devin-Org: engineering
Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/45e3d51148204f80a4e822b766f71bda
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/45e3d51148204f80a4e822b766f71bda?variant=devin
Devin Review