【发布时间】:2025-12-13 06:25:01
【问题描述】:
场景是:你有一个有效期较长的刷新令牌和一个有效期较短的访问令牌。
设置:有客户端、应用服务器和认证服务器。
- 客户端存储访问令牌。
- 应用程序服务器存储刷新令牌。
- 身份验证服务器分发刷新 + 访问令牌。
其中一个优点是被盗的访问令牌只能在其有效时间内使用。
假设黑客窃取了有效期为 30 分钟的访问令牌。当黑客在 30 分钟后使用有效但已过期的被盗访问令牌发出请求时,应用服务器会使用刷新令牌对其进行刷新,从而使黑客获得一个新的有效且未过期的访问令牌。
如何预防?
【问题讨论】:
-
嘿@Arthur。如果你找到了这个问题的最佳解决方案,请告诉我。我对这条线很困惑,如何防止这种情况? :-->
Say a hacker steals the access token that is valid for 30 minutes. When the hacker makes a request with the valid but expired stolen access token after 30 minutes, the application server refreshes it with the refresh token, thus the hacker gaining a new valid and not expired access token.
标签: oauth-2.0 jwt token access-token refresh-token