forked from GithubBackups/healthchecks
Fix _allow_redirect function to reject absolute URLs
This fixes a security issue: - attacker can crafts a redirect URL to an external site - attacker gets victim to click on it - victim logs in - after login, Healthchecks redirects victim to the external site The _allow_redirect function now additionally requires the redirect URL is relative (has no scheme or domain).
This commit is contained in:
parent
f85aec225d
commit
7252f2f101
@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
- Fix dark mode styling issues in Cron Syntax Cheatsheet
|
- Fix dark mode styling issues in Cron Syntax Cheatsheet
|
||||||
- Fix a 403 when transferring a project to a read-only team member
|
- Fix a 403 when transferring a project to a read-only team member
|
||||||
|
- Security: fix allow_redirect function to reject absolute URLs
|
||||||
|
|
||||||
## v1.21.0 - 2020-07-02
|
## v1.21.0 - 2020-07-02
|
||||||
|
|
||||||
|
@ -95,7 +95,13 @@ class LoginTestCase(BaseTestCase):
|
|||||||
def test_it_handles_bad_next_parameter(self):
|
def test_it_handles_bad_next_parameter(self):
|
||||||
form = {"action": "login", "email": "alice@example.org", "password": "password"}
|
form = {"action": "login", "email": "alice@example.org", "password": "password"}
|
||||||
|
|
||||||
r = self.client.post("/accounts/login/?next=/evil/", form)
|
samples = [
|
||||||
|
"/evil/",
|
||||||
|
f"https://example.org/projects/{self.project.code}/checks/",
|
||||||
|
]
|
||||||
|
|
||||||
|
for sample in samples:
|
||||||
|
r = self.client.post("/accounts/login/?next=" + sample, form)
|
||||||
self.assertRedirects(r, self.checks_url)
|
self.assertRedirects(r, self.checks_url)
|
||||||
|
|
||||||
def test_it_handles_wrong_password(self):
|
def test_it_handles_wrong_password(self):
|
||||||
|
@ -54,6 +54,10 @@ def _allow_redirect(redirect_url):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
parsed = urlparse(redirect_url)
|
parsed = urlparse(redirect_url)
|
||||||
|
if parsed.netloc:
|
||||||
|
# Allow redirects only to relative URLs
|
||||||
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
match = resolve(parsed.path)
|
match = resolve(parsed.path)
|
||||||
except Resolver404:
|
except Resolver404:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user