fix(security): tighten recovery-download grant window (reject stale/non-int/future)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>feat/v1-foundation
parent
57a3dd51b6
commit
5ab665321f
|
|
@ -64,7 +64,9 @@ Route::middleware('auth')->group(function () {
|
|||
// unused grant cannot linger and be replayed later in the session. ->block() below
|
||||
// serializes racing reads of the grant.
|
||||
$grantedAt = session()->pull('2fa.download_grant');
|
||||
abort_unless(is_int($grantedAt) && now()->timestamp - $grantedAt <= 600, 403);
|
||||
$age = is_int($grantedAt) ? now()->timestamp - $grantedAt : null;
|
||||
// Valid only within [now-600s, now]: rejects stale, non-timestamp, and future grants.
|
||||
abort_unless($age !== null && $age >= 0 && $age <= 600, 403);
|
||||
|
||||
$codes = AuthFacade::user()->recoveryCodes();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue