mirror of
https://github.com/phishingclub/phishingclub.git
synced 2026-10-05 15:07:24 +02:00
fix potential reuse of oauth on failure to mark as used
Signed-off-by: Ronni Skansing <rskansing@gmail.com>
This commit is contained in:
1 parent
b7d440b183
commit
2fb7ff72f3
1 file changed
+5
-3
@@ -479,11 +479,13 @@ func (o *OAuthProvider) ExchangeCodeForTokens(
|
||||
return errs.Wrap(err)
|
||||
}
|
||||
|
||||
// mark state token as used
|
||||
// mark state token as used before exchanging the code — if this fails the token
|
||||
// remains unused and could be replayed within the 10-minute expiry window, so
|
||||
// we must abort rather than continue
|
||||
stateID := oauthState.ID.MustGet()
|
||||
if err := o.OAuthStateRepository.MarkAsUsed(ctx, stateID); err != nil {
|
||||
o.Logger.Errorw("failed to mark state token as used", "error", err)
|
||||
// continue anyway - token exchange is more important
|
||||
o.Logger.Errorw("failed to mark state token as used, aborting token exchange to prevent replay", "error", err)
|
||||
return errs.Wrap(err)
|
||||
}
|
||||
|
||||
// get client secret
|
||||
|
||||
Reference in new issue
Block a user