# URL Redirection to Untrusted Site ('Open Redirect') (CWE-601) A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. **Stack:** Python - Prevalence: 보통 3개 언어 지원 - Impact: 보통 검토 권장 - Prevention: 문서화됨 4개의 수정 예시 **OWASP:** Broken Access Control (A01:2021-Broken Access Control) - #1 ## Description An open redirect vulnerability occurs when an application takes user input and uses it to redirect the user to a different URL. Attackers can exploit this to redirect users to malicious sites. ## Prevention 1개의 Shoulder 탐지 규칙을 기반으로 한 Open Redirect 예방 전략. ### Python Validate redirect URLs against a domain allowlist or use relative paths ## Warning Signs - [MEDIUM] unvalidated redirects using user input ## Consequences - 권한 획득 - 보호 메커니즘 우회 ## Mitigations - URL은 신뢰할 수 있는 도메인의 허용 목록을 기준으로 검증하세요 - URL 매개변수를 직접 노출하기보다 매핑 체계를 사용하세요 - 외부 사이트로 리다이렉트하기 전에 경고 페이지를 표시하세요 ## Detection - Total rules: 4 - Languages: go, javascript, typescript, python ## Rules by Language ### Python (1 rules) - **Open Redirect** [MEDIUM]: Detects unvalidated redirects using user input. - Remediation: Validate redirect URLs against an allowlist of permitted domains. ```python from urllib.parse import urlparse ALLOWED_DOMAINS = {"myapp.com"} if urlparse(url).netloc not in ALLOWED_DOMAINS: url = "/" ``` Learn more: https://shoulder.dev/learn/python/cwe-601/open-redirect