Commit 931b66a
fix(security): close 3 low-severity account/side-channel findings
Security review of the auth flows surfaced three low-severity issues, all
fixed here:
- pk-auth-persistence-dynamodb: refresh-token rotation gated the atomic
ConditionExpression on `expiresAtIso > :now`, a lexicographic compare of
variable-precision Instant.toString() values (the fractional-seconds field
is dropped when zero), so "...:00Z" sorts after "...:00.000001Z" and a
just-expired token could rotate within the rotate TOCTOU window. Compare
the numeric epoch-second `ttl` attribute instead. Fails closed now.
- pk-auth-jwt: PkAuthJwtValidator in stateful mode guarded the AccessTokenStore
lookup with `jti != null`, so a validly-signed, in-issuer/-audience, unexpired
token with no jti bypassed the revocation gate. Reject jti-less tokens with
MissingClaim("jti") when a non-noop store is bound. The library's own tokens
always carry a jti, so behavior is unchanged for them.
- pk-auth-magic-link: corrected the MagicLinkService.startLogin javadoc, which
falsely claimed timing-side-channel resistance; the not-found path returns
before JWT issuance and email dispatch, so latency still enables enumeration.
Documentation only; no behavior change.
All affected modules pass spotlessCheck, unit tests, and the DynamoDB Local
refresh-token integration suite (incl. concurrent-rotation and expired-token
cases).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 6b9dec1 commit 931b66a
5 files changed
Lines changed: 73 additions & 15 deletions
File tree
- pk-auth-jwt/src/main/java/com/codeheadsystems/pkauth/jwt
- pk-auth-magic-link/src/main/java/com/codeheadsystems/pkauth/magiclink
- pk-auth-persistence-dynamodb/src/main/java/com/codeheadsystems/pkauth/persistence/dynamodb
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 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 | + | |
14 | 47 | | |
15 | 48 | | |
16 | 49 | | |
| |||
112 | 145 | | |
113 | 146 | | |
114 | 147 | | |
115 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
116 | 151 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
Lines changed: 14 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| 92 | + | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| |||
167 | 169 | | |
168 | 170 | | |
169 | 171 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
174 | 184 | | |
175 | 185 | | |
176 | 186 | | |
| |||
Lines changed: 14 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
235 | 242 | | |
236 | 243 | | |
237 | 244 | | |
| |||
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
141 | 145 | | |
142 | 146 | | |
143 | 147 | | |
144 | 148 | | |
145 | | - | |
146 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
147 | 153 | | |
148 | 154 | | |
149 | 155 | | |
| |||
0 commit comments