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.

fix(security): don't leak URL-parse exception in notification test error (CodeQL #4775) (#4835)

LearningCircuitfb1d8f9c39b1
diff --git a/src/local_deep_research/security/notification_validator.py b/src/local_deep_research/security/notification_validator.py
index 2c56a41cfd..219850c811 100644
--- a/src/local_deep_research/security/notification_validator.py
+++ b/src/local_deep_research/security/notification_validator.py
@@ -278,9 +278,14 @@ class NotificationURLValidator:
# Parse URL
try:
parsed = urlparse(url)
- except Exception as e:
- logger.warning("Failed to parse service URL")
- return False, f"Invalid URL format: {e}"
+ except Exception:
+ # Log the parser exception (with traceback) server-side for
+ # debugging, but never echo it back to the caller: this error
+ # string is surfaced to the user by the test-URL endpoint, and the
+ # exception text can carry parser internals / stack-trace fragments
+ # (CWE-209, py/stack-trace-exposure).
+ logger.exception("Failed to parse service URL")
+ return False, "Invalid URL format"
# Check for scheme
if not parsed.scheme:
diff --git a/tests/security/test_notification_validator.py b/tests/security/test_notification_validator.py
index 3940a9f3b6..649e94c02e 100644
--- a/tests/security/test_notification_validator.py
+++ b/tests/security/test_notification_validator.py
@@ -142,6 +142,24 @@ class TestValidateServiceUrl:
assert is_valid is False
assert "must have a protocol" in error
+ def test_parse_error_does_not_leak_exception_text(self):
+ """A urlparse failure must return a generic message, not the
+ exception text. The validator error is surfaced to the user by the
+ /api/notifications/test-url endpoint, so leaking the exception would
+ expose stack-trace fragments (CWE-209, CodeQL py/stack-trace-exposure,
+ alert #4775)."""
+ secret_marker = "INTERNAL-PARSER-DETAIL-do-not-leak"
+ with patch(
+ "local_deep_research.security.notification_validator.urlparse",
+ side_effect=ValueError(secret_marker),
+ ):
+ is_valid, error = NotificationURLValidator.validate_service_url(
+ "https://example.com/webhook"
+ )
+ assert is_valid is False
+ assert secret_marker not in error
+ assert error == "Invalid URL format"
+
def test_file_scheme_blocked(self):
"""Should block file:// scheme."""
is_valid, error = NotificationURLValidator.validate_service_url(