{
  "id": "security/oauth2-refresh-token-rotation-failure-allows-token-theft",
  "signature": "OAuth2 refresh token rotation failure allows token theft",
  "signature_zh": "OAuth2刷新令牌轮换失败导致令牌被盗",
  "regex": "OAuth2 refresh token rotation failure allows token theft",
  "domain": "security",
  "category": "auth_error",
  "subcategory": null,
  "root_cause": "When refresh token rotation is not implemented, a stolen refresh token remains valid indefinitely, allowing an attacker to obtain new access tokens without detection.",
  "root_cause_type": "generic",
  "root_cause_zh": "当未实现刷新令牌轮换时，被盗的刷新令牌无限期有效，使攻击者能够获取新的访问令牌而不被发现。",
  "versions": [
    {
      "version": "OAuth2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Spring Security 5.6+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Keycloak 21.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Okta 2023.07.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Setting a short access token lifetime (e.g., 5 minutes) does not protect against refresh token theft because the attacker can still use the refresh token to get new tokens repeatedly.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Revoking all tokens on logout is insufficient if the attacker already has the refresh token and uses it before logout.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Using a single refresh token with a long lifetime is the default in many OAuth2 implementations, which directly enables this vulnerability.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Implement refresh token rotation: issue a new refresh token each time the old one is used, and invalidate the old token. Example in Spring Security: configure oauth2Client with refreshTokenRotationEnabled(true).",
      "success_rate": 0.9,
      "how": "Implement refresh token rotation: issue a new refresh token each time the old one is used, and invalidate the old token. Example in Spring Security: configure oauth2Client with refreshTokenRotationEnabled(true).",
      "condition": "",
      "sources": []
    },
    {
      "action": "Implement refresh token reuse detection: if a revoked refresh token is used, revoke all tokens for that user and alert. Example in Keycloak: enable 'Revoke Refresh Token' in client settings.",
      "success_rate": 0.85,
      "how": "Implement refresh token reuse detection: if a revoked refresh token is used, revoke all tokens for that user and alert. Example in Keycloak: enable 'Revoke Refresh Token' in client settings.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Set a maximum refresh token lifetime (e.g., 24 hours) and force re-authentication after expiry, combined with rotation.",
      "success_rate": 0.8,
      "how": "Set a maximum refresh token lifetime (e.g., 24 hours) and force re-authentication after expiry, combined with rotation.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Implement refresh token rotation: issue a new refresh token each time the old one is used, and invalidate the old token. Example in Spring Security: configure oauth2Client with refreshTokenRotationEnabled(true).",
    "Implement refresh token reuse detection: if a revoked refresh token is used, revoke all tokens for that user and alert. Example in Keycloak: enable 'Revoke Refresh Token' in client settings.",
    "Set a maximum refresh token lifetime (e.g., 24 hours) and force re-authentication after expiry, combined with rotation."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://datatracker.ietf.org/doc/html/rfc6749#section-10.4",
  "official_doc_section": null,
  "error_code": "OAUTH2_REFRESH_TOKEN_ROTATION_FAILURE",
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.87,
  "resolvable": "true",
  "first_seen": "2023-09-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}