Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

검증 로직 우회를 통한 Open Redirect 취약점 제보 #582

Closed
Letm3through opened this issue Jun 9, 2024 · 0 comments
Closed

검증 로직 우회를 통한 Open Redirect 취약점 제보 #582

Letm3through opened this issue Jun 9, 2024 · 0 comments

Comments

@Letm3through
Copy link
Contributor

Letm3through commented Jun 9, 2024

검증 로직 우회를 통한 Open Redirect

안녕하세요. 개발중인 SAST 보안 툴을 테스트하다가 취약점을 발견하여 제보드립니다.
조치를 위한 PR을 아래 링크에 작성해두었습니다.

취약한 Version

=< 6.0.4

취약점 설명

미흡한 검증 로직으로 //를 사용하여 방어 로직을 우회하여 로그인시 타 웹사이트로 사용자를 redirect시킬수 있음.
URL 경우 //로 시작할시 도메인으로 인지되기에 이러한 점을 악용하여 취약점을 발생시킬수 있습니다.
해당 취약점은 타 이슈에서도 언급되었듯이 피싱으로 악용될수있습니다.

PoC

http://127.0.0.1:8000/bbs/#?url=//example.com

코드 문제점 및 조치

아래와 같이 현재 // 사용을 확인하는 검증 로직이 누락되어있습니다.

def validate_login_url(request: Request, url: str = Form(default="/")):
"""
로그인할 때 url을 검사하는 함수
"""
allow_urls = []
if (url
and not url.startswith("/")
and not url.startswith(str(request.base_url))
and url not in allow_urls):
raise AlertException("올바르지 않은 URL입니다.", 400)
return url

이는 아래와 같이 조건문을 추가하여 조치가 가능합니다.

    if (url
            or url.startswith("//") # 여기와 같이 검증 조건 추가
            and not url.startswith("/")
            and not url.startswith(str(request.base_url))
            and url not in allow_urls):
        raise AlertException("올바르지 않은 URL입니다.", 400)
    return url

관련 이슈 / PR

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant