# 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 - URLs को विश्वसनीय डोमेन की allowlist के विरुद्ध सत्यापित करें - सीधे 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