Commit 45efdba
Apply consistent redirect-URI validation on AccountController.SignIn (#3940)
SignIn was missing the IsPercentEncodedSlashBypass guard that Challenge
already had. A redirectUri like /%2fevil.example passes Url.IsLocalUrl
(the framework only checks for literal // and /\), but a normalising
reverse proxy decodes it to //evil.example; browsers then follow it as
a protocol-relative URL after sign-in.
Add !IsPercentEncodedSlashBypass(redirectUri) to the SignIn guard,
matching the guard on Challenge.
Also update the IsPercentEncodedSlashBypass XML doc to note it is a
local copy of RedirectUriHelper.HasPercentEncodedSlashPrefix (internal
in a separate assembly) so future changes keep both in sync.
Tests: two new facts in AccountControllerTests covering the %2f and %5c
variants on the SignIn path, using the realistic IsLocalUrl mock so
removing either guard breaks the tests.
Copilot-Session: 00c4f24d-188f-4bd9-926c-a6d0620eb053
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent f5e30e9 commit 45efdba
2 files changed
Lines changed: 53 additions & 1 deletion
File tree
- src/Microsoft.Identity.Web.UI/Areas/MicrosoftIdentity/Controllers
- tests/Microsoft.Identity.Web.UI.Test/Areas/MicrosoftIdentity/Controllers
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
257 | 263 | | |
258 | 264 | | |
259 | 265 | | |
| |||
tests/Microsoft.Identity.Web.UI.Test/Areas/MicrosoftIdentity/Controllers/AccountControllerTests.cs
Lines changed: 46 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
442 | 488 | | |
443 | 489 | | |
0 commit comments