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

Dynamic OAuth Callback URL Constructed from Host Header

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

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
52/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

Hướng nghiên cứu

Bắt đầu bằng cách đọc các dòng 63-68 trong src/asfquart/generics.py và entry point setup_oauth() để theo dõi cách URL callback được tạo từ quart.request.host_url. Triển khai cấu hình OAUTH_CALLBACK_HOST cố định và cập nhật luồng OAuth, các test, tài liệu và hướng dẫn deployment được nêu trong các tiêu chí nghiệm thu. Công việc được hoàn tất khi header Host không thể thay đổi URL callback và URL cố định được bao phủ bởi các unit test và integration test.

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

Mô tả

ASVS

Issue: FINDING-164 - Dynamic OAuth Callback URL Constructed from Host Header

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

ASVS Level(s): L1

Description:

Summary

The OAuth redirect_uri parameter is dynamically derived from the HTTP Host header (callback_host = quart.request.host_url.replace('http://', 'https://')). This violates ASVS 10.4.1 because: (1) The client sends a variable callback URL instead of a fixed, pre-registered one; (2) If the deployment violates the documented ProxyPreserveHost On assumption, an attacker controlling the Host header can craft an arbitrary callback URL; (3) If the authorization server uses pattern-based or prefix matching instead of exact string comparison, the authorization code could be redirected to an attacker-controlled domain. This could lead to authorization code theft and account takeover, contingent on AS redirect URI validation strictness and deployment configuration.

Details

The vulnerability exists in src/asfquart/generics.py lines 63-68, where the callback URL is constructed from quart.request.host_url. This creates a dynamic redirect URI that varies based on the incoming request's Host header.

Recommended Remediation

Pre-configure the callback host using an environment variable instead of deriving it from the request:

import os
import urllib.parse

# In configuration
CALLBACK_HOST = os.environ.get('OAUTH_CALLBACK_HOST', 'https://myapp.apache.org')

# Modify setup_oauth() to accept callback_host parameter
def setup_oauth(app, uri: str, callback_host: str):
    @app.route(uri)
    async def oauth_endpoint():
        state = secrets.token_urlsafe(16)
        # Use fixed callback_host instead of request.host_url
        callback_url = urllib.parse.urljoin(callback_host, f'{uri}?state={state}')
        # ... rest of implementation

This ensures the callback URL is fixed and can be pre-registered with exact string matching at the Authorization Server.

Acceptance Criteria
  • OAUTH_CALLBACK_HOST environment variable added to configuration
  • setup_oauth() modified to accept callback_host parameter
  • Callback URL constructed from fixed configuration instead of Host header
  • Unit tests verify callback URL is not affected by Host header
  • Integration tests verify OAuth flow with fixed callback URL
  • Documentation updated with required environment variable
  • Deployment guide updated to emphasize fixed callback URL registration
References
  • Source reports: L1:10.4.1.md
  • Related findings: FINDING-273
  • ASVS sections: 10.4.1
  • CWE: CWE-601
Priority

Medium

Ngôn ngữ chính
Python
Star
7
Fork
14
Merge trung bình
11 giờ 58 phút
Pull request đã merge (30 ngày)
1

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.