You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Validating the security stamp is extending the session if allowRefresh is false #64301
area-authIncludes: authentication, authorization, OAuth, OIDC, and access token validationbugThis issue describes a behavior which is not expected - a bug.help wantedUp for grabs. We would accept a PR to help resolve this issue
@MackinnonBuck Because I asked ChatGPT what the purpose of AllowRefresh is, and it told me that the purpose is to override SlidingExpiration on per request basis. That means, even if SlidingExpiration is true, if AllowRefrsh is false, there should be no session extension.
This rule is respected in the sliding expiration logic, but not in the security stamp logic, seems like an oversight.
This is not causing me any problem, I just noticed it and it looks wrong.
Hi @MackinnonBuck — I'd like to take a look at this if it's confirmed as a bug.
From reading the issue, it seems like the security stamp validation path in SecurityStampValidator may not be checking context.Properties.AllowRefresh before refreshing the cookie, while the sliding expiration path does respect it. If that's the case, the fix would be adding the same AllowRefresh guard to the stamp validation renewal logic.
Before I invest time in a PR — could you confirm this is indeed a bug and not by-design behavior? Happy to dig into the code and submit a fix if so.
The root cause is in SecurityStampValidator.SecurityStampVerified() — it unconditionally sets context.ShouldRenew = true after stamp verification, without checking AllowRefresh. The handler's own CheckForRefreshAsync() does respect AllowRefresh ?? true, so the two are inconsistent.
The fix is a one-liner that mirrors the handler's pattern: context.ShouldRenew = context.Properties.AllowRefresh ?? true. The principal replacement still happens unconditionally (claims stay fresh in-memory), only the cookie rewrite is gated.
I've included tests for both the bug case (AllowRefresh = false → ShouldRenew == false) and default behavior preservation (AllowRefresh not set → ShouldRenew == true).
area-authIncludes: authentication, authorization, OAuth, OIDC, and access token validationbugThis issue describes a behavior which is not expected - a bug.help wantedUp for grabs. We would accept a PR to help resolve this issue
Activity
MackinnonBuck commentedon Nov 12, 2025
Thanks for reaching out, @jgtestw.
Would you mind clarifying why you're setting
SlidingExpirationtotrue, butcontext.Properties.AllowRefreshtofalse? What's the scenario?jgtestw commentedon Nov 12, 2025
@MackinnonBuck Because I asked ChatGPT what the purpose of AllowRefresh is, and it told me that the purpose is to override SlidingExpiration on per request basis. That means, even if SlidingExpiration is true, if AllowRefrsh is false, there should be no session extension.
This rule is respected in the sliding expiration logic, but not in the security stamp logic, seems like an oversight.
This is not causing me any problem, I just noticed it and it looks wrong.
MackinnonBuck commentedon Nov 17, 2025
Thanks for clarifying, @jgtestw!
We're going to move this to the backlog to measure community impact.
matantsach commentedon Feb 14, 2026
Hi @MackinnonBuck — I'd like to take a look at this if it's confirmed as a bug.
From reading the issue, it seems like the security stamp validation path in
SecurityStampValidatormay not be checkingcontext.Properties.AllowRefreshbefore refreshing the cookie, while the sliding expiration path does respect it. If that's the case, the fix would be adding the sameAllowRefreshguard to the stamp validation renewal logic.Before I invest time in a PR — could you confirm this is indeed a bug and not by-design behavior? Happy to dig into the code and submit a fix if so.
Thanks!
Check AllowRefresh before renewing cookie in SecurityStampValidator
matantsach commentedon Mar 17, 2026
Opened a PR for this: #65803
The root cause is in
SecurityStampValidator.SecurityStampVerified()— it unconditionally setscontext.ShouldRenew = trueafter stamp verification, without checkingAllowRefresh. The handler's ownCheckForRefreshAsync()does respectAllowRefresh ?? true, so the two are inconsistent.The fix is a one-liner that mirrors the handler's pattern:
context.ShouldRenew = context.Properties.AllowRefresh ?? true. The principal replacement still happens unconditionally (claims stay fresh in-memory), only the cookie rewrite is gated.I've included tests for both the bug case (
AllowRefresh = false→ShouldRenew == false) and default behavior preservation (AllowRefreshnot set →ShouldRenew == true).