{
  "id": "security/oauth2-implicit-grant-token-in-url",
  "signature": "OAuth2 implicit grant flow leaks access token in URL fragment",
  "signature_zh": "OAuth2 隐式授权流程在 URL 片段中泄露访问令牌",
  "regex": "(?:access_token|id_token)=[^&]+#",
  "domain": "security",
  "category": "protocol_error",
  "subcategory": null,
  "root_cause": "The OAuth2 implicit grant flow returns the access token in the URL fragment, which is exposed in browser history, referrer headers, and server logs.",
  "root_cause_type": "generic",
  "root_cause_zh": "OAuth2 隐式授权流程在 URL 片段中返回访问令牌，该片段会暴露在浏览器历史记录、引用标头和服务器日志中。",
  "versions": [
    {
      "version": "OAuth 2.0 RFC 6749",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "OAuth 2.0 Security BCP (RFC 9700)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Removing the token from the URL fragment entirely breaks the flow because the client expects it there.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Using HTTPS alone doesn't prevent token leakage via browser history or referrer headers.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Shortening token expiry doesn't solve the underlying exposure; tokens are still captured in logs.",
      "fail_rate": 0.3,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Migrate from the implicit flow to the authorization code flow with PKCE. Example: `response_type=code&code_challenge=...&code_challenge_method=S256` instead of `response_type=token`.",
      "success_rate": 0.95,
      "how": "Migrate from the implicit flow to the authorization code flow with PKCE. Example: `response_type=code&code_challenge=...&code_challenge_method=S256` instead of `response_type=token`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If migration is not possible, add `Referrer-Policy: no-referrer` headers and discourage browser history retention via `Cache-Control: no-store` on the page.",
      "success_rate": 0.6,
      "how": "If migration is not possible, add `Referrer-Policy: no-referrer` headers and discourage browser history retention via `Cache-Control: no-store` on the page.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a custom scheme for mobile apps to reduce exposure to browser history and referrer leakage.",
      "success_rate": 0.7,
      "how": "Use a custom scheme for mobile apps to reduce exposure to browser history and referrer leakage.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "从隐式流程迁移到带 PKCE 的授权码流程。示例：使用 `response_type=code&code_challenge=...&code_challenge_method=S256` 代替 `response_type=token`。",
    "如果无法迁移，添加 `Referrer-Policy: no-referrer` 标头，并通过页面上的 `Cache-Control: no-store` 阻止浏览器历史记录保留。",
    "对移动应用使用自定义方案，以减少浏览器历史记录和引用标头泄露的风险。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://oauth.net/2/grant-types/implicit/",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.88,
  "resolvable": "true",
  "first_seen": "2023-11-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}