# 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:** Go - 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 の予防策。 ### Go Validate redirect URLs against an allowlist of trusted domains ## Warning Signs - [MEDIUM] User input flows to redirect without validation ## Consequences - 権限の取得 - 保護メカニズムの回避 ## Mitigations - URL は信頼できるドメインの許可リストと照合して検証する - 直接的な URL パラメータではなく、マッピングシステムを使用する - 外部サイトへリダイレクトする前に警告ページを表示する ## Detection - Total rules: 4 - Languages: go, javascript, typescript, python ## Rules by Language ### Go (1 rules) - **Open Redirect** [MEDIUM]: User-controlled input used in http.Redirect without URL validation. - Remediation: Validate redirect URLs against a whitelist of allowed domains. ```go allowed := map[string]bool{"example.com": true} u, err := url.Parse(redirectURL) if err != nil || !allowed[u.Host] { http.Error(w, "Invalid redirect", 400) return } http.Redirect(w, r, redirectURL, http.StatusFound) ``` Learn more: https://shoulder.dev/learn/go/cwe-601/open-redirect