Commit 9be7c28
Harden token-store load and key validation
FileTokenStore.load read the file with Files.readAllBytes after a
separate Files.size check. Because the file is attacker-writable, a
concurrent grow between the two would make readAllBytes allocate
gigabytes and throw OutOfMemoryError - an Error that the best-effort
RuntimeException guard in OidcDeviceAuth.maybeLoadFromStore does not
catch, so a bad file aborted sign-in instead of degrading. A new
readBounded reads through a FileChannel into a buffer capped at the
reported size (already bounded by MAX_FILE_BYTES) plus one byte, so a
file that grew past its reported size is rejected, never allocated.
TokenFileParser tracked only object depth, so an array-wrapped object
([ {..} ]) extracted its fields through the depth gate. The parser now
marks any array as malformed and parseAndVerify rejects a shape that is
not a single flat JSON object, keeping the on-disk format strict.
TokenStoreKey now rejects a null clientId, tokenEndpoint,
deviceAuthorizationEndpoint or scope with a clear OidcAuthException
instead of surfacing a raw NullPointerException deep in a store's
serialize/fingerprint path, and normalises an empty audience to null so
getAudience(), hash() and the save/load round-trip agree that an absent
audience is null (an empty audience previously broke its own round-trip).
parseAndVerify now bulk-copies the file bytes into native memory via a
new DirectUtf8Sink.put(byte[], int, int) instead of a byte-by-byte loop.
Add tests for the array-wrapped reject, the empty-audience
normalisation, and the null-required-field rejection; each was proven to
fail with its fix reverted.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 71e01f2 commit 9be7c28
4 files changed
Lines changed: 150 additions & 17 deletions
File tree
- core/src
- main/java/io/questdb/client
- cutlass/auth
- std/str
- test/java/io/questdb/client/test/cutlass/auth
Lines changed: 45 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
| 231 | + | |
240 | 232 | | |
241 | 233 | | |
242 | 234 | | |
243 | 235 | | |
244 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
245 | 240 | | |
246 | 241 | | |
247 | 242 | | |
| |||
313 | 308 | | |
314 | 309 | | |
315 | 310 | | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
| 311 | + | |
| 312 | + | |
320 | 313 | | |
321 | 314 | | |
322 | 315 | | |
| |||
325 | 318 | | |
326 | 319 | | |
327 | 320 | | |
328 | | - | |
329 | | - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
330 | 324 | | |
331 | 325 | | |
332 | 326 | | |
| |||
411 | 405 | | |
412 | 406 | | |
413 | 407 | | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
414 | 437 | | |
415 | 438 | | |
416 | 439 | | |
| |||
623 | 646 | | |
624 | 647 | | |
625 | 648 | | |
| 649 | + | |
626 | 650 | | |
627 | 651 | | |
628 | 652 | | |
629 | 653 | | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
630 | 660 | | |
631 | 661 | | |
632 | 662 | | |
| |||
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
73 | 81 | | |
74 | 82 | | |
75 | 83 | | |
76 | 84 | | |
77 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
78 | 89 | | |
79 | | - | |
| 90 | + | |
80 | 91 | | |
81 | 92 | | |
82 | 93 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
106 | 123 | | |
107 | 124 | | |
108 | 125 | | |
| |||
Lines changed: 75 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
106 | 127 | | |
107 | 128 | | |
108 | 129 | | |
| |||
181 | 202 | | |
182 | 203 | | |
183 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
184 | 227 | | |
185 | 228 | | |
186 | 229 | | |
| |||
666 | 709 | | |
667 | 710 | | |
668 | 711 | | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
669 | 744 | | |
670 | 745 | | |
671 | 746 | | |
| |||
0 commit comments