Commit 3191390
authored
fix(security): stop curl_command from carrying the bearer token across a redirect (#525)
* fix(security): stop curl_command from carrying the bearer token across a redirect
curl_command() passed -L, so a redirect was followed with the OAuth bearer
token still on curl's configuration input. curl fixed the cross-host case in
7.58.0 as CVE-2018-1000007, which leaves roughly 7.30 through 7.57 exposed.
Measured against the live API: every endpoint curl_command touches answers in a
single hop on the correct region, including download-installer/v3 and the
registry tags list. So -L never fired on a correct-region run.
-L only did work when FALCON_CLOUD named the wrong region, because the API
answers a wrong region with a 308 to the right one. That never worked on a curl
that strips the header, which is every supported version: on curl 7.29.0 and
8.5.0 the redirect was followed, the header was dropped, the call came back 401
and the run died with a misleading "No sensor found for OS" error. The only
versions where -L produced a working request are the same versions that leak the
token.
Dropped -L, and with it --proto-redir, keeping the convention from #521 that
--proto-redir appears only next to -L. The wrong-region case is now handled the
way the OAuth token request already handles it: the x-cs-region hint is adopted
instead of the redirect being followed, so it works on every curl version rather
than only the leaky band. The warning naming the real region still prints.
falcon-container-sensor-pull.sh already adopted the hint; install, uninstall and
migrate only warned and kept the wrong region.
Fixes #523
* fix(security): handle the region redirect in curl_command instead of following it
Dropping -L closed the leak but left the wrong-region case relying on
get_oauth_token having corrected cs_falcon_cloud first. That only covers the
client id and secret path: with FALCON_ACCESS_TOKEN there is no token POST, so
there is no x-cs-region to read, and every API call went to the wrong region.
curl_command now reads x-cs-region off the un-followed redirect and re-issues
against that region, resolved through cs_cloud(), so the retry host always comes
from a closed allowlist and never from Location. Region correction now covers
every request that carries the token, whichever way the token was obtained.
There is no scope-free way to discover this up front: the 308 only comes back on
a real routable path. An unknown path answers 404 with no x-cs-region, and the
redirect is emitted after authentication, so an unauthenticated probe gets 401.
The retry therefore rides on the caller's own request rather than a probe.
The body is buffered because the redirect body is 107 bytes, not empty, so
emitting it would corrupt the value the caller captures. Buffering is safe for
the -o callers too: curl writes their file itself and stdout stays empty.
The status is read from the last HTTP status line, because a proxy CONNECT dumps
one of its own first. The exit code is captured and returned so behaviour under
set -e is unchanged and #526's call-site guards still receive the real code -
measured: rc=5 for an unresolvable proxy, both under set +e and through a
command substitution.
Verified against the live API on curl 7.29.0 and 8.5.0, with client credentials
and with FALCON_ACCESS_TOKEN, for us-1, us-2 and eu-1: GET, GET with -o, PATCH
with a JSON body, and the query holding a literal pipe all reach the correct
region. The arg rewrite was checked separately under dash, bash and macOS sh.1 parent dad81bf commit 3191390
4 files changed
Lines changed: 183 additions & 21 deletions
File tree
- bash
- containers/falcon-container-sensor-pull
- install
- migrate
Lines changed: 42 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
287 | | - | |
| 287 | + | |
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
294 | 299 | | |
295 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
296 | 336 | | |
297 | 337 | | |
298 | 338 | | |
299 | | - | |
300 | 339 | | |
301 | 340 | | |
302 | 341 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
704 | 704 | | |
705 | 705 | | |
706 | 706 | | |
707 | | - | |
| 707 | + | |
708 | 708 | | |
709 | 709 | | |
710 | 710 | | |
711 | 711 | | |
712 | 712 | | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
713 | 718 | | |
714 | | - | |
| 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 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
715 | 755 | | |
716 | 756 | | |
717 | 757 | | |
| |||
829 | 869 | | |
830 | 870 | | |
831 | 871 | | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
836 | 877 | | |
837 | 878 | | |
838 | 879 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
| 253 | + | |
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
259 | 264 | | |
260 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
261 | 301 | | |
262 | 302 | | |
263 | 303 | | |
| |||
490 | 530 | | |
491 | 531 | | |
492 | 532 | | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
497 | 538 | | |
498 | 539 | | |
499 | 540 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
237 | 242 | | |
238 | | - | |
| 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 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
239 | 279 | | |
240 | 280 | | |
241 | 281 | | |
| |||
409 | 449 | | |
410 | 450 | | |
411 | 451 | | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
416 | 457 | | |
417 | 458 | | |
418 | 459 | | |
| |||
0 commit comments