{
  "id": "security/oauth2-redirect-uri-validation-weak",
  "signature": "OAuth2 redirect_uri validation allows path traversal or subdomain confusion",
  "signature_zh": "OAuth2 redirect_uri验证允许路径遍历或子域名混淆",
  "regex": "redirect_uri.*validation|redirect_uri.*mismatch|open redirect.*OAuth",
  "domain": "security",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The OAuth2 server validates the redirect_uri by checking if it starts with the registered URI string instead of performing exact or strict prefix matching, allowing an attacker to register a malicious redirect URI that passes validation.",
  "root_cause_type": "generic",
  "root_cause_zh": "OAuth2服务器通过检查redirect_uri是否以注册URI字符串开头来验证，而不是执行精确或严格前缀匹配，允许攻击者注册一个通过验证的恶意重定向URI。",
  "versions": [
    {
      "version": "Spring Authorization Server 1.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Keycloak 22.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Ory Hydra 2.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Simply adding more registered URIs to the allowlist doesn't fix the validation logic flaw; attackers can still craft URIs that pass the flawed check.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Blocking specific known malicious URIs is a reactive approach and cannot cover all possible bypasses.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Turning off redirect_uri validation entirely is dangerous and allows open redirect attacks.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Implement exact string matching for the redirect_uri against the registered value. In Spring Security, use a custom RedirectUriValidator that compares the full URI string.",
      "success_rate": 0.95,
      "how": "Implement exact string matching for the redirect_uri against the registered value. In Spring Security, use a custom RedirectUriValidator that compares the full URI string.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a strict prefix match that includes the path and query, not just the host. For example, in Node.js: if (redirectUri !== registeredUri) { reject(); }",
      "success_rate": 0.9,
      "how": "Use a strict prefix match that includes the path and query, not just the host. For example, in Node.js: if (redirectUri !== registeredUri) { reject(); }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Normalize the redirect_uri before validation by removing trailing slashes, default ports, and case-folding the scheme and host.",
      "success_rate": 0.85,
      "how": "Normalize the redirect_uri before validation by removing trailing slashes, default ports, and case-folding the scheme and host.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "对redirect_uri与注册值实现精确字符串匹配。在Spring Security中，使用自定义RedirectUriValidator比较完整URI字符串。",
    "使用包含路径和查询的严格前缀匹配，而不仅仅是主机。例如，在Node.js中：if (redirectUri !== registeredUri) { reject(); }",
    "在验证前标准化redirect_uri，去除尾部斜杠、默认端口，并对方案和主机进行大小写折叠。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://datatracker.ietf.org/doc/html/rfc6749#section-3.1.2",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2024-05-22",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}