Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

Add CRLF injection protection to redirect URL validation (#1893)

LearningCircuit50712d37cb2d
diff --git a/src/local_deep_research/security/url_validator.py b/src/local_deep_research/security/url_validator.py
index 0c88b1d403..ba2507de59 100644
--- a/src/local_deep_research/security/url_validator.py
+++ b/src/local_deep_research/security/url_validator.py
@@ -349,6 +349,8 @@ class URLValidator:
Prevents open redirect attacks by ensuring the target URL
is either relative or points to the same host as the application.
+ Also prevents CRLF injection attacks by rejecting URLs containing
+ carriage return or line feed characters.
Uses the standard Flask pattern from:
https://github.com/fengsp/flask-snippets/blob/master/security/redirect_back.py
@@ -363,6 +365,11 @@ class URLValidator:
if not target:
return False
+ # Prevent CRLF injection by rejecting URLs with CR or LF characters
+ if "\r" in target or "\n" in target:
+ logger.warning("CRLF injection attempt detected in redirect URL")
+ return False
+
ref_url = urlparse(host_url)
test_url = urlparse(urljoin(host_url, target))
return (