{
  "id": "security/oauth2-token-reuse-detection-failure-allows-replay-attack",
  "signature": "OAuth2 token reuse detection failure allows replay attack",
  "signature_zh": "OAuth2令牌重用检测失败允许重放攻击",
  "regex": "OAuth2 token reuse detected: same authorization code used more than once",
  "domain": "security",
  "category": "auth_error",
  "subcategory": null,
  "root_cause": "When the authorization server does not track whether an authorization code or access token has already been used, an attacker can replay a captured token to gain unauthorized access.",
  "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 22.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Auth0 2024.02",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Relying on short token lifetimes (e.g., 5 minutes) does not prevent replay within that window; an attacker can replay the token immediately after capture.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Using a nonce in the request is insufficient if the authorization server does not track nonces per token; an attacker can reuse the same nonce.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Encrypting the token does not prevent replay because the attacker can still send the same encrypted token.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Implement token reuse detection on the authorization server: store a flag or timestamp for each authorization code and access token, and reject requests that use an already-used code or token. Example in Spring Security: configure OAuth2AuthorizationService with a persistent store that marks codes as used.",
      "success_rate": 0.95,
      "how": "Implement token reuse detection on the authorization server: store a flag or timestamp for each authorization code and access token, and reject requests that use an already-used code or token. Example in Spring Security: configure OAuth2AuthorizationService with a persistent store that marks codes as used.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use short-lived authorization codes (e.g., 1 minute) and access tokens (e.g., 5 minutes) combined with reuse detection to minimize the replay window.",
      "success_rate": 0.9,
      "how": "Use short-lived authorization codes (e.g., 1 minute) and access tokens (e.g., 5 minutes) combined with reuse detection to minimize the replay window.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Implement token binding (e.g., via DPoP or mTLS) to tie tokens to a specific client, preventing replay from other clients.",
      "success_rate": 0.85,
      "how": "Implement token binding (e.g., via DPoP or mTLS) to tie tokens to a specific client, preventing replay from other clients.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Implement token reuse detection on the authorization server: store a flag or timestamp for each authorization code and access token, and reject requests that use an already-used code or token. Example in Spring Security: configure OAuth2AuthorizationService with a persistent store that marks codes as used.",
    "Use short-lived authorization codes (e.g., 1 minute) and access tokens (e.g., 5 minutes) combined with reuse detection to minimize the replay window.",
    "Implement token binding (e.g., via DPoP or mTLS) to tie tokens to a specific client, preventing replay from other clients."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://datatracker.ietf.org/doc/html/rfc6749#section-10.5",
  "official_doc_section": null,
  "error_code": "OAUTH2_TOKEN_REUSE_DETECTION_FAILURE",
  "verification_tier": "ai_generated",
  "confidence": 0.81,
  "fix_success_rate": 0.89,
  "resolvable": "true",
  "first_seen": "2024-02-14",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}