Commit 3250b3e
Harden OIDC token validation, lock and issuer-path pin
Three defects in the OIDC token-provider work.
The ILP HTTP sender skipped token validation whenever the provider
returned the same CharSequence instance it had validated before, on
the theory that an instance never changes content. HttpTokenProvider
makes no such promise: a provider that reuses one buffer (the idiomatic
zero-alloc style) and mutates it in place between flushes had its
mutated token spliced verbatim into the Authorization header, which
request.authToken writes with no CR/LF filtering - a header-injection
bypass of the very check validateToken exists to enforce. The sender
now validates every pulled token; the scan is O(token length) and is
dwarfed by the flush's network round-trip, matching what the WebSocket
auth path already does on every pull.
getToken() acquired its lock with the interruptible timed tryLock even
on the uncontended fast path. That overload throws InterruptedException
the moment the calling thread merely carries a set interrupt flag -
even on a free lock - and the handler re-arms the flag, so every later
getToken() on that thread failed with a valid token sitting in the
cache. ILP producers commonly run on pooled or managed threads where
interrupt is the standard cancellation signal. An untimed tryLock now
handles the uncontended case; the timed poll remains only for genuine
contention behind a peer's silent refresh.
The issuer-path pin rejected a "." or ".." path segment but not "..;":
a server or proxy that strips RFC 3986 matrix parameters resolves
/realms/acme/..;/evil to /realms/evil, a different realm on the same
host, redirecting the device code and refresh token to a sibling
tenant. The dot-segment check now strips a ";suffix" from each decoded
segment before comparing.
Each fix gets a regression test proven to fail when the fix is
reverted.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 82b8bab commit 3250b3e
4 files changed
Lines changed: 138 additions & 29 deletions
File tree
- core/src
- main/java/io/questdb/client/cutlass
- auth
- line/http
- test/java/io/questdb/client/test/cutlass
- auth
- line
Lines changed: 29 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
797 | 797 | | |
798 | 798 | | |
799 | 799 | | |
800 | | - | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
801 | 810 | | |
802 | 811 | | |
803 | 812 | | |
| |||
1036 | 1045 | | |
1037 | 1046 | | |
1038 | 1047 | | |
1039 | | - | |
1040 | | - | |
1041 | | - | |
1042 | | - | |
1043 | | - | |
1044 | | - | |
1045 | | - | |
1046 | | - | |
1047 | | - | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
1048 | 1067 | | |
1049 | 1068 | | |
1050 | 1069 | | |
| |||
Lines changed: 7 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | 97 | | |
101 | 98 | | |
102 | 99 | | |
| |||
835 | 832 | | |
836 | 833 | | |
837 | 834 | | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | | - | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
842 | 841 | | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
| 842 | + | |
851 | 843 | | |
852 | 844 | | |
853 | 845 | | |
| |||
Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1541 | 1541 | | |
1542 | 1542 | | |
1543 | 1543 | | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
1544 | 1576 | | |
1545 | 1577 | | |
1546 | 1578 | | |
| |||
1971 | 2003 | | |
1972 | 2004 | | |
1973 | 2005 | | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
1974 | 2034 | | |
1975 | 2035 | | |
1976 | 2036 | | |
| |||
Lines changed: 42 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
214 | 252 | | |
215 | 253 | | |
216 | 254 | | |
| |||
0 commit comments