Commit 2128e54
Tighten token-store hardening and hygiene
Sanitize the warnPersistence detail. An IO error from the store can
carry the operator-supplied store path (questdb.client.oidc.token.store.dir
or user.home), which could itself hold terminal-spoofing characters, so
route cause.getMessage() through the null-safe sanitizeForDisplay before
printing to System.err - matching how every other untrusted display
string is sanitized.
Reap orphan temp files. A crash between createTempFile and the atomic
rename leaves a <hash>*.tmp holding a valid-at-the-time refresh token;
nothing ever steals it, so they would accumulate across crashes. save()
now best-effort sweeps <hash>*.tmp older than lockStaleMillis, leaving a
concurrent writer's fresh temp (recent mtime) untouched - so the random
per-writer suffix that keeps concurrent saves from colliding stays.
Chmod the store directory only on drift. ensureDirectory re-tightens a
pre-existing directory on every save and every inLock; read the
permissions first and only setPosixFilePermissions when they actually
differ, dropping a redundant write syscall in the common case while
keeping the re-tighten defense and the non-POSIX fallback.
Compare the schema version as a long. The parser narrowed it to an int,
so a tampered "v" of 1 + 2^32 truncated to SCHEMA_VERSION and passed the
gate; keep the full long and compare as a long.
Add tests for the temp-file sweep and the version-overflow reject; each
was proven to fail with its fix reverted.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 9be7c28 commit 2128e54
3 files changed
Lines changed: 82 additions & 9 deletions
File tree
- core/src
- main/java/io/questdb/client/cutlass/auth
- test/java/io/questdb/client/test/cutlass/auth
Lines changed: 36 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
245 | 246 | | |
246 | 247 | | |
247 | 248 | | |
| 249 | + | |
248 | 250 | | |
249 | 251 | | |
250 | 252 | | |
| |||
457 | 459 | | |
458 | 460 | | |
459 | 461 | | |
460 | | - | |
461 | | - | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
462 | 466 | | |
463 | 467 | | |
464 | | - | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
465 | 471 | | |
466 | 472 | | |
467 | 473 | | |
468 | 474 | | |
469 | | - | |
| 475 | + | |
470 | 476 | | |
471 | 477 | | |
472 | 478 | | |
| |||
614 | 620 | | |
615 | 621 | | |
616 | 622 | | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
617 | 645 | | |
618 | 646 | | |
619 | 647 | | |
| |||
643 | 671 | | |
644 | 672 | | |
645 | 673 | | |
646 | | - | |
| 674 | + | |
647 | 675 | | |
648 | 676 | | |
649 | 677 | | |
| |||
698 | 726 | | |
699 | 727 | | |
700 | 728 | | |
701 | | - | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
702 | 732 | | |
703 | 733 | | |
704 | 734 | | |
| |||
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1499 | 1499 | | |
1500 | 1500 | | |
1501 | 1501 | | |
1502 | | - | |
1503 | | - | |
1504 | | - | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
1505 | 1507 | | |
1506 | 1508 | | |
1507 | 1509 | | |
| |||
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
709 | 709 | | |
710 | 710 | | |
711 | 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 | + | |
712 | 736 | | |
713 | 737 | | |
714 | 738 | | |
| |||
757 | 781 | | |
758 | 782 | | |
759 | 783 | | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
760 | 801 | | |
761 | 802 | | |
762 | 803 | | |
| |||
0 commit comments