aboutsummaryrefslogtreecommitdiff
path: root/tests/forms/test_validators.py
diff options
context:
space:
mode:
authorDennis Fink2026-10-30 20:31:43 +0100
committerDennis Fink2026-10-30 20:31:43 +0100
commit13a9d9ddce09230017699bc34ac3bf08ed2f84ed (patch)
tree3715bd13439a61a8cc6896581811a30b62ac1b16 /tests/forms/test_validators.py
parent8c561e702ed15022b17eae81e4185448c021e1cb (diff)
downloadwebmentions-ssg-13a9d9ddce09230017699bc34ac3bf08ed2f84ed.tar.gz
webmentions-ssg-13a9d9ddce09230017699bc34ac3bf08ed2f84ed.zip
fix(core): prevent DNS rebinding in HTTP requests
Pin outbound connections to validated public IP addresses so DNS changes cannot redirect receiver or sender requests onto private or link-local networks. Apply the same protection across redirects, add an overall request deadline, and keep DNS resolution out of synchronous endpoint form validation.
Diffstat (limited to 'tests/forms/test_validators.py')
-rw-r--r--tests/forms/test_validators.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/forms/test_validators.py b/tests/forms/test_validators.py
index 6e26039..2858b4c 100644
--- a/tests/forms/test_validators.py
+++ b/tests/forms/test_validators.py
@@ -112,3 +112,9 @@ def test_public_url_uses_custom_message(monkeypatch: pytest.MonkeyPatch) -> None
with pytest.raises(ValidationError, match="Public URL required"):
PublicURL("Public URL required")(form, form.url)
+
+
+def test_allowed_hostname_handles_invalid_ipv6(app: Flask) -> None:
+ form = URLForm(MultiDict({"url": "http://[::1"}))
+ with app.app_context(), pytest.raises(ValidationError, match="Invalid input"):
+ AllowedHostname()(form, form.url)