Open redirect (ARCH2122)
هذا المحتوى غير متوفر بلغتك بعد.
Key python.security.open-redirect · Severity warning · Category security · CWE CWE-601
Taking a redirect target from user input without validation lets attackers run phishing attacks through a trusted domain redirect.
Incorrect
Section titled “Incorrect”from flask import request, redirect
def go(): return redirect(request.args["next"])Correct
Section titled “Correct”from urllib.parse import urlparsefrom flask import request, redirect
def go(): target = request.args["next"] if urlparse(target).netloc: return redirect("/") return redirect(target)Restrict redirect targets to relative paths only, or validate them against an allowlist.