fix(security): [HIGH] resolve Open Redirect vulnerability in URL validation#93
fix(security): [HIGH] resolve Open Redirect vulnerability in URL validation#93Tugamer89 wants to merge 1 commit into
Conversation
Modified get_safe_redirect_url to check if scheme is present but netloc is empty, fixing an open redirect bypass via malformed URLs like 'http:evil.com' or 'http:///evil.com'. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|



Severity: HIGH
Vulnerability:
The
get_safe_redirect_urlfunction, designed to prevent Open Redirects, was vulnerable to a bypass. Python'surllib.parse.urlparsetreats URLs likehttp:evil.comorhttp:///evil.comas having a valid scheme (http) but an emptynetloc. The original code only checked thatparsed.netloc != request_host, meaning these malformed URLs would bypass the netloc check completely.Impact:
An attacker could craft a malicious URL with this format, bypass the
get_safe_redirect_urlcheck, and redirect unsuspecting users to a malicious external site.Fix:
Added an explicit check in
core/security.py'sget_safe_redirect_urlfunction to return/ifparsed.schemeis present butparsed.netlocis not. This explicitly blocks these types of malformed URLs.Verification:
http:evil.comandhttp:///evil.com, which correctly return/./dashboardand valid same-host URLs likehttp://localhost/dashboardare allowed.PR created automatically by Jules for task 1480532950398926126 started by @Tugamer89