Commit 2c939bb
committed
fix(security): make self-proxied transactional persist methods protected (not package-private)
registerNewUserAccount, changeUserPassword, and setInitialPassword route their DB
write back through the @lazy self proxy (self.persistNewUserAccount /
persistChangedPassword / persistInitialPassword) so the short @transactional applies
after the bcrypt hash runs outside any transaction. Those persist* methods were
package-private. In Spring Framework 7 the CGLIB proxy subclass is generated in a
different package, so it cannot override package-private methods: self.persistX(...)
then executes the inherited body on the proxy instance — whose @Autowired fields are
never injected — throwing NullPointerException ("this.userRepository is null") and
silently dropping the transaction. This broke registration, password change, password
reset, and set-initial-password for consumers.
Caught by the demo-app Playwright E2E (Spring Boot 4.0.4); the library's own CI runs
4.0.6, where the behavior is masked — so a @SpringBootTest on the pinned CI version
cannot be relied on to catch it. Fix by making the three methods protected (CGLIB
overrides public/protected across packages; matches the already-correct protected
GdprDeletionService.executeUserDeletion and public UserEmailService.createPasswordResetTokenForUser).
Add SelfProxiedMethodVisibilityTest: a version-independent, bytecode-level guard that
fails fast if any self-proxied method is ever made package-private/private again.1 parent fb9694a commit 2c939bb
2 files changed
Lines changed: 98 additions & 11 deletions
File tree
- src
- main/java/com/digitalsanctuary/spring/user/service
- test/java/com/digitalsanctuary/spring/user/architecture
Lines changed: 20 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
379 | 382 | | |
380 | 383 | | |
381 | 384 | | |
382 | 385 | | |
383 | 386 | | |
384 | 387 | | |
385 | 388 | | |
386 | | - | |
| 389 | + | |
387 | 390 | | |
388 | 391 | | |
389 | 392 | | |
| |||
755 | 758 | | |
756 | 759 | | |
757 | 760 | | |
758 | | - | |
759 | | - | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
760 | 766 | | |
761 | 767 | | |
762 | 768 | | |
763 | 769 | | |
764 | 770 | | |
765 | 771 | | |
766 | | - | |
| 772 | + | |
767 | 773 | | |
768 | 774 | | |
769 | 775 | | |
| |||
856 | 862 | | |
857 | 863 | | |
858 | 864 | | |
859 | | - | |
860 | | - | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
861 | 870 | | |
862 | 871 | | |
863 | 872 | | |
864 | 873 | | |
865 | 874 | | |
866 | 875 | | |
867 | | - | |
| 876 | + | |
868 | 877 | | |
869 | 878 | | |
870 | 879 | | |
| |||
Lines changed: 78 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
0 commit comments