Skip to content

refactor: enforce redirect URL validation - #3

Open
deepsource-dev-autofix[bot] wants to merge 1 commit into
2.6.2-basefrom
deepsource-autofix-8a7034bf
Open

refactor: enforce redirect URL validation#3
deepsource-dev-autofix[bot] wants to merge 1 commit into
2.6.2-basefrom
deepsource-autofix-8a7034bf

Conversation

@deepsource-dev-autofix

Copy link
Copy Markdown

A brief overview of the changes made in this PR:
This update adds strict validation for HTTP redirect URLs by comparing the protocol, host, and port of the redirected URL against the original request URL. Any mismatch now results in an IOException, effectively preventing Server-Side Request Forgery (SSRF) via open redirects.

  • SSRF: The previous implementation opened redirected URLs without any verification, which could be abused to perform SSRF attacks. The fix wraps the new URL in a java.net.URL object and checks that its protocol, host, and port match those of the original URL. If they differ, an IOException is thrown to block the redirect. We assume that only redirects to the exact same host, protocol, and port are valid—please review this constraint to ensure it aligns with your redirect requirements.

This Autofix was generated by AI. Please review the change before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants