Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Open Redirect via Backslash Normalization in OAuth Redirect URI Validation

Đang mở
#90 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
74/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python
Lĩnh vực
authentication, security

Hướng nghiên cứu

Bắt đầu trong src/asfquart/generics.py tại các vị trí xác thực và sử dụng redirect của login và logout, sau đó xem lại tests/generics.py quanh các dòng 53-58. Chạy các kiểm thử generics hiện có và bổ sung coverage cho dấu gạch chéo ngược dạng thô và được mã hóa URL trong cả hai luồng. Hoàn tất khi các redirect dựa trên dấu gạch chéo ngược bị từ chối, trong khi các redirect tương đối hợp lệ vẫn tiếp tục hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Python
Star
7
Fork
14
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/infrastructure-asfquart

Tất cả issue của apache/infrastructure-asfquart

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.