Commit dad81bf
fix(security): harden OAuth and fetch_tags redirects, keep region auto-discovery (#521)
* fix(security): harden OAuth and download redirects against credential replay
Stop bash OAuth token POSTs and PowerShell Invoke-FalconAuth from replaying
client_secret on HTTPS redirect hop 2. Pin fetch_tags to HTTPS without -L.
Strip Authorization before following Falcon download CDN redirects.
Follow-on to #520. Live-validated on the fork (CAND-001/002/003/004).
* fix(security): drop download rewrite; keep oauth and fetch_tags redirect hardening
Co-authored-by: Carlos Matos <carlosmmatos@users.noreply.github.com>
* chore: strip verbose oauth and fetch_tags comments
Keep the redirect hardening; drop the multi-line explanatory blocks.
* fix(security): re-issue the OAuth token request instead of following the redirect
Dropping -L and setting -MaximumRedirection 0 stops a 307/308 from replaying the
client secret in the request body, but it also disabled region auto-discovery,
which is what that redirect is for.
Measured against the live API on curl 7.29.0 and 7.76.1: a wrong-region token
request answers 308 with x-cs-region and a Location, and following it with -L
does return a token, so the body is replayed.
bash now reads x-cs-region off the un-followed response and re-issues the
request against that region, resolved through cs_cloud(), which is a closed
allowlist that dies on anything it does not recognise. cs_cloud() takes the
region as an optional argument for that, defaulting to the current one, so every
existing call site is unchanged. The retry dumps headers to a separate file so
the existing region-hint block still reads the first response, and the payload
stays on stdin rather than in argv. cs_cloud() failing is checked rather than
assumed to end the script, because exiting a nested command substitution does
not stop the caller under bash.
Windows PowerShell 5.1 returns a 3xx rather than throwing it, so
ConvertFrom-Json received the redirect body as a Byte[] and the catch reported
an unhandled error. Invoke-FalconAuth now handles the redirect on the success
path as well as in the catch, and reads X-Cs-Region through a helper, because
5.1 gives a WebHeaderCollection with only a string indexer while PowerShell 7
gives HttpResponseHeaders, where that indexer returns empty.
* fix(container-pull): drop the dead redirect pin from fetch_tags
fetch_tags lost -L, so --proto-redir has nothing to act on. Leaving it there
reads as though redirects were considered and handled on that call, which is
misleading in a change about redirects.
Measured with a pass-through curl wrapper over the real --list-tags path: the
registry token request and the tags list both answer 200 in a single hop, as do
the ccid and image-registry-credentials calls, so nothing on that path wants a
redirect. That was against registry.crowdstrike.com; the gov registries were not
reachable from the test environment.
The convention is now uniform across all four scripts: --proto-redir appears on
exactly the curl invocations that pass -L.
* docs(powershell): correct the header-collection note in Get-FalconRegionHeader
The note claimed the success path yields "a Dictionary, so ContainsKey". That was
an assumption. Measured on Windows PowerShell 5.1.26100.9168: Invoke-WebRequest
returns a body-less 3xx as Microsoft.PowerShell.Commands.WebResponseObject, whose
Content is a Byte[] — which is precisely why the old code failed inside
ConvertFrom-Json before it could reach the region logic.
The note now distinguishes what was measured on each platform and path from what
rests on documentation, and no longer names a type nothing verified.
Comment only; no behaviour change. The functional test still passes on
PowerShell 7.6.5 and on 5.1.
* chore: trim verbose comments in oauth redirect hardening
---------
Co-authored-by: Carlos Matos <carlosmmatos@users.noreply.github.com>
Co-authored-by: Carlos Matos <carlos.matos@crowdstrike.com>1 parent 205b919 commit dad81bf
7 files changed
Lines changed: 365 additions & 117 deletions
File tree
- bash
- containers/falcon-container-sensor-pull
- install
- migrate
- powershell
- install
- migrate
Lines changed: 38 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
101 | 103 | | |
102 | | - | |
| 104 | + | |
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
| |||
294 | 296 | | |
295 | 297 | | |
296 | 298 | | |
| 299 | + | |
297 | 300 | | |
298 | | - | |
| 301 | + | |
| 302 | + | |
299 | 303 | | |
300 | 304 | | |
301 | 305 | | |
| |||
676 | 680 | | |
677 | 681 | | |
678 | 682 | | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
679 | 692 | | |
680 | 693 | | |
681 | 694 | | |
682 | 695 | | |
683 | 696 | | |
684 | 697 | | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
691 | 701 | | |
692 | 702 | | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
693 | 722 | | |
694 | 723 | | |
695 | 724 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
648 | 648 | | |
649 | 649 | | |
650 | 650 | | |
651 | | - | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
652 | 654 | | |
653 | 655 | | |
654 | 656 | | |
655 | 657 | | |
656 | 658 | | |
657 | 659 | | |
658 | | - | |
| 660 | + | |
659 | 661 | | |
660 | 662 | | |
661 | 663 | | |
| |||
769 | 771 | | |
770 | 772 | | |
771 | 773 | | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
772 | 783 | | |
773 | 784 | | |
774 | 785 | | |
| |||
777 | 788 | | |
778 | 789 | | |
779 | 790 | | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | | - | |
785 | | - | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
786 | 794 | | |
787 | 795 | | |
788 | 796 | | |
789 | 797 | | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
790 | 817 | | |
791 | 818 | | |
792 | 819 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
205 | 207 | | |
206 | 208 | | |
207 | 209 | | |
208 | 210 | | |
209 | 211 | | |
210 | 212 | | |
211 | | - | |
| 213 | + | |
212 | 214 | | |
213 | 215 | | |
214 | 216 | | |
| |||
430 | 432 | | |
431 | 433 | | |
432 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
433 | 444 | | |
434 | 445 | | |
435 | 446 | | |
| |||
438 | 449 | | |
439 | 450 | | |
440 | 451 | | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
447 | 455 | | |
448 | 456 | | |
449 | 457 | | |
450 | 458 | | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
451 | 478 | | |
452 | 479 | | |
453 | 480 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
295 | 297 | | |
296 | 298 | | |
297 | 299 | | |
298 | 300 | | |
299 | 301 | | |
300 | 302 | | |
301 | | - | |
| 303 | + | |
302 | 304 | | |
303 | 305 | | |
304 | 306 | | |
| |||
342 | 344 | | |
343 | 345 | | |
344 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
345 | 356 | | |
346 | 357 | | |
347 | 358 | | |
| |||
359 | 370 | | |
360 | 371 | | |
361 | 372 | | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
| 373 | + | |
368 | 374 | | |
369 | 375 | | |
370 | 376 | | |
371 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
372 | 397 | | |
373 | 398 | | |
374 | 399 | | |
| |||
0 commit comments