Commit bbf6688
fix(security): require auth on GET /accounts/:email (enumeration)
GET /api/accounts/:email had no auth middleware, so it could be called
anonymously. An earlier fix (finding #1) stopped it leaking the bcrypt
password hash, but left the endpoint reachable without a session -- so
it could still be used to confirm which emails have an account (200 vs
404) and to read that account's id, name, confirmation status and
creation date (security audit finding #10).
Server:
- Gate the route with jwtSession.validateUserHasRequiredRoles, using the
same role set as GET "/" (admin, security_admin, data_entry,
global_admin). GET "/" already exposes strictly more account data to
those roles, so this adds no new exposure for authenticated staff and
removes all anonymous access.
Client:
- The only public caller was ForgotPassword's per-keystroke existence
check, which is removed. It relied on the endpoint being anonymous and
is redundant: the "account not found, please register" feedback is
already surfaced on submit from the forgotPassword response
(FORGOT_PASSWORD_ACCOUNT_NOT_FOUND).
- The admin Features screen (isAdmin) is unaffected; it sends the jwt
cookie automatically.
Tests:
- Add controller-level tests asserting the route's role guard rejects an
unauthenticated caller (401), rejects an authenticated caller without a
permitted role (401), and lets an admin through.
tsc and lint pass clean on both workspaces.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent a207cba commit bbf6688
3 files changed
Lines changed: 88 additions & 28 deletions
File tree
- client/src/components/Account
- server
- __test__
- app/routes
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
58 | 45 | | |
59 | 46 | | |
60 | 47 | | |
| |||
134 | 121 | | |
135 | 122 | | |
136 | 123 | | |
137 | | - | |
138 | 124 | | |
139 | 125 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | 126 | | |
147 | 127 | | |
148 | 128 | | |
| |||
172 | 152 | | |
173 | 153 | | |
174 | 154 | | |
175 | | - | |
| 155 | + | |
176 | 156 | | |
177 | 157 | | |
178 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| |||
775 | 777 | | |
776 | 778 | | |
777 | 779 | | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
55 | 71 | | |
56 | 72 | | |
0 commit comments