Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Open Redirect via Backslash Normalization in OAuth Redirect URI Validation

オープン
#90 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
74/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
python

調査の方向性

src/asfquart/generics.py の login と logout の redirect の検証および使用箇所から始め、続いて tests/generics.py の 53-58 行付近を確認します。既存の generics テストを実行し、両方のフローで raw のバックスラッシュと URL エンコードされたバックスラッシュを対象とするカバレッジを追加します。バックスラッシュベースの redirect が拒否され、有効な相対 redirect が引き続き機能すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

ASVS

Issue: FINDING-114 - Open Redirect via Backslash Normalization in OAuth Redirect URI Validation

Labels: bug, security, priority:medium, asvs-level:L2

ASVS Level(s): [L2-only]

Description:

Summary

The OAuth redirect URI validation in the login and logout flows rejects URIs that don't start with '/' or that start with '//', but does not account for the WHATWG URL Standard backslash normalization. Per the spec (§4.4 'relative slash' state), when a URL parser encounters '' after an initial '/' in a special URL scheme (http/https), it treats '' identically to '/'. Thus '' acts as a path separator, and '/\evil.com' is parsed as '//evil.com', a protocol-relative URL pointing to evil.com. The validation passes '/\evil.com' because it starts with '/' and doesn't start with '//', but browsers normalize this to '//evil.com', causing an open redirect.

Details

Affected locations:

  • src/asfquart/generics.py lines 48-53: Login redirect validation
  • src/asfquart/generics.py lines 69-75: Login redirect usage
  • src/asfquart/generics.py lines 113-119: Logout redirect validation
  • src/asfquart/generics.py lines 164-172: Logout redirect usage
  • tests/generics.py lines 53-58: Tests don't cover backslash case

Impact includes post-authentication phishing where users complete OAuth login and are then redirected to an attacker's site mimicking the application.

Recommended Remediation

Add backslash normalization check to redirect URI validation. Create a helper function _is_safe_redirect:

def _is_safe_redirect(uri: str) -> bool:
    """Validate redirect URI is safe (relative, same-origin only)."""
    if not uri.startswith("/"):
        return False
    if uri.startswith("//"):
        return False
    # Block backslash and URL-encoded backslash
    if "\\" in uri or "%5c" in uri.lower() or "%5C" in uri:
        return False
    # Verify no netloc present after parsing
    parsed = urllib.parse.urlsplit(uri)
    if parsed.netloc:
        return False
    return True

Add test cases in tests/generics.py to verify rejection of '/%5Cevil.com' and '/\evil.com' for both login and logout flows.

Acceptance Criteria
  • Backslash-based open redirects are blocked
  • URL-encoded backslashes are blocked
  • Test cases verify backslash rejection
  • Both login and logout flows are protected
  • Unit test verifying the fix
References
  • Source reports: L2:3.5.4.md
  • Related findings: None
  • ASVS sections: 3.5.4
Priority

Medium

主要言語
Python
スター
7
フォーク
13
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/infrastructure-asfquart のほかの issue

apache/infrastructure-asfquart の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。