Repository navigation
Commit de26fa1
committed
fix(adms): reject blank user_jwt in OBO mode
Blank or whitespace-only user_jwt values triggered a silent fallback from
OBO (per-user) to service (application) credentials due to Python truthy
checks (if self._user_jwt / if _jwt). Empty and whitespace-only strings
are falsy, silently routing to get_token() (service credentials) instead
of exchange_token() (OBO) — an authorization-escalation attack surface.
Fix: add a single enforcement helper _require_non_blank_jwt and apply it
at every public entry point — constructors (conditional on is not None),
with_user_jwt methods (unconditional), and factory functions (conditional).
Correct both truthy-check bug sites to use is not None comparisons.
Behavior contract (before → after):
- create_client()/user_jwt=None → service creds (unchanged)
- create_client(user_jwt='valid') → OBO exchange (unchanged)
- create_client(user_jwt='')/' ' → ValueError
- AdmsHttp(user_jwt=None) → service creds (unchanged)
- AdmsHttp(user_jwt='')/' ' → ValueError
- with_user_jwt('valid') → OBO exchange (unchanged)
- with_user_jwt('')/' '/None → ValueError
BREAKING CHANGE: passing empty or whitespace user_jwt (which previously
silently used service credentials) now raises ValueError. user_jwt=None /
omitted (service mode) is unchanged. Cross-repo scan confirmed zero
external consumers of sap_cloud_sdk.adms.1 parent 78a25f4 commit de26fa1
5 files changed
Lines changed: 267 additions & 5 deletions
File tree
- src/sap_cloud_sdk/adms
- tests/adms/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
49 | 67 | | |
50 | 68 | | |
51 | 69 | | |
| |||
177 | 195 | | |
178 | 196 | | |
179 | 197 | | |
| 198 | + | |
| 199 | + | |
180 | 200 | | |
181 | 201 | | |
182 | 202 | | |
| |||
190 | 210 | | |
191 | 211 | | |
192 | 212 | | |
| 213 | + | |
| 214 | + | |
193 | 215 | | |
194 | 216 | | |
195 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
196 | 221 | | |
| 222 | + | |
197 | 223 | | |
198 | 224 | | |
199 | 225 | | |
| |||
291 | 317 | | |
292 | 318 | | |
293 | 319 | | |
294 | | - | |
| 320 | + | |
295 | 321 | | |
296 | 322 | | |
297 | 323 | | |
| |||
436 | 462 | | |
437 | 463 | | |
438 | 464 | | |
| 465 | + | |
| 466 | + | |
439 | 467 | | |
440 | 468 | | |
441 | 469 | | |
442 | 470 | | |
443 | 471 | | |
444 | 472 | | |
445 | 473 | | |
446 | | - | |
| 474 | + | |
447 | 475 | | |
448 | 476 | | |
449 | 477 | | |
| |||
646 | 674 | | |
647 | 675 | | |
648 | 676 | | |
| 677 | + | |
| 678 | + | |
649 | 679 | | |
650 | 680 | | |
651 | 681 | | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
652 | 685 | | |
| 686 | + | |
653 | 687 | | |
654 | 688 | | |
655 | 689 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
94 | 96 | | |
95 | 97 | | |
96 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
97 | 102 | | |
| 103 | + | |
98 | 104 | | |
99 | 105 | | |
100 | 106 | | |
| |||
129 | 135 | | |
130 | 136 | | |
131 | 137 | | |
| 138 | + | |
| 139 | + | |
132 | 140 | | |
133 | 141 | | |
134 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
135 | 146 | | |
| 147 | + | |
136 | 148 | | |
137 | 149 | | |
138 | 150 | | |
| |||
166 | 178 | | |
167 | 179 | | |
168 | 180 | | |
169 | | - | |
| 181 | + | |
170 | 182 | | |
171 | 183 | | |
172 | 184 | | |
173 | 185 | | |
174 | 186 | | |
| 187 | + | |
| 188 | + | |
175 | 189 | | |
176 | 190 | | |
177 | 191 | | |
| |||
210 | 224 | | |
211 | 225 | | |
212 | 226 | | |
213 | | - | |
| 227 | + | |
214 | 228 | | |
215 | 229 | | |
216 | 230 | | |
217 | 231 | | |
218 | 232 | | |
| 233 | + | |
| 234 | + | |
219 | 235 | | |
220 | 236 | | |
221 | 237 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
81 | 90 | | |
82 | 91 | | |
83 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
143 | 162 | | |
144 | 163 | | |
145 | 164 | | |
| |||
220 | 239 | | |
221 | 240 | | |
222 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
223 | 271 | | |
224 | 272 | | |
225 | 273 | | |
| |||
482 | 530 | | |
483 | 531 | | |
484 | 532 | | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
485 | 550 | | |
486 | 551 | | |
487 | 552 | | |
| |||
0 commit comments