Email captcha rate limiting fix && CORS tightening via configuration

This commit is contained in:
Liujian committed 2025-11-26 16:58:54 +08:00
1 parent 798082934e
commit 19f646c318
6 files changed
+44 -21

No files matched your search

+9
View File
@@ -188,6 +188,15 @@ class HttpUtils:
if headers:
request_headers.update(headers)
# Basic SSRF protections: only allow http/https and block localhost/private IPs
parsed = urlparse(url)
if parsed.scheme not in ("http", "https"):
raise ValidationException("URL scheme must be http or https")
host = (parsed.hostname or "").lower()
private_prefixes = ("127.", "10.", "192.168.")
if host in ("localhost", "127.0.0.1") or host.startswith(private_prefixes) or host.startswith("172."):
raise ValidationException("Access to local/private addresses is not allowed")
async with aiohttp.ClientSession(
timeout=aiohttp.ClientTimeout(total=timeout),
headers=request_headers