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: resolve CodeQL security alerts

LearningCircuita5a65313554a
diff --git a/src/local_deep_research/research_library/routes/rag_routes.py b/src/local_deep_research/research_library/routes/rag_routes.py
index 5db9facbbb..aa0895bf0f 100644
--- a/src/local_deep_research/research_library/routes/rag_routes.py
+++ b/src/local_deep_research/research_library/routes/rag_routes.py
@@ -984,6 +984,12 @@ def index_local_library():
logger.warning(f"Path validation failed for '{folder_path}': {e}")
return jsonify({"success": False, "error": "Invalid path"}), 400
+ # Explicit safety check for static analyzers - path was validated above
+ path_str = str(path)
+ if ".." in path_str or not path.is_absolute():
+ logger.warning(f"Path safety check failed for: {path_str}")
+ return jsonify({"success": False, "error": "Invalid path"}), 400
+
# Check path exists and is a directory
if not path.exists():
return jsonify({"success": False, "error": "Path does not exist"}), 400
diff --git a/src/local_deep_research/security/path_validator.py b/src/local_deep_research/security/path_validator.py
index bfa6109766..f97fb253ff 100644
--- a/src/local_deep_research/security/path_validator.py
+++ b/src/local_deep_research/security/path_validator.py
@@ -132,6 +132,11 @@ class PathValidator:
):
raise ValueError("Malformed Windows path input")
+ # Block path traversal patterns before resolving
+ # This explicit check helps static analyzers understand the security intent
+ if ".." in user_path:
+ raise ValueError("Path traversal patterns not allowed")
+
# Resolve the path - this normalizes and makes absolute
# Security is enforced via restricted_dirs check below
validated_path = Path(user_path).resolve()
diff --git a/src/local_deep_research/web/routes/settings_routes.py b/src/local_deep_research/web/routes/settings_routes.py
index 048872551f..d87f93f9d3 100644
--- a/src/local_deep_research/web/routes/settings_routes.py
+++ b/src/local_deep_research/web/routes/settings_routes.py
@@ -2378,7 +2378,13 @@ def api_test_notification_url():
notification_service = NotificationService()
result = notification_service.test_service(service_url)
- return jsonify(result)
+ # Only return expected fields to prevent information leakage
+ safe_response = {
+ "success": result.get("success", False),
+ "message": result.get("message", ""),
+ "error": result.get("error", ""),
+ }
+ return jsonify(safe_response)
except Exception:
logger.exception("Error testing notification URL")
diff --git a/src/local_deep_research/web/static/js/embedding_settings.js b/src/local_deep_research/web/static/js/embedding_settings.js
index a2a29477d8..8c7f88d3fa 100644
--- a/src/local_deep_research/web/static/js/embedding_settings.js
+++ b/src/local_deep_research/web/static/js/embedding_settings.js
@@ -513,10 +513,10 @@ async function testConfiguration() {
testResult.innerHTML = `
<div class="ldr-alert ldr-alert-success">
<i class="fas fa-check-circle"></i> <strong>Test Passed!</strong><br>
- Model: ${model}<br>
- Provider: ${provider}<br>
- Embedding dimension: ${data.dimension}<br>
- Response time: ${data.response_time_ms}ms
+ Model: ${window.XSSProtection.escapeHtml(model)}<br>
+ Provider: ${window.XSSProtection.escapeHtml(provider)}<br>
+ Embedding dimension: ${window.XSSProtection.escapeHtml(data.dimension)}<br>
+ Response time: ${window.XSSProtection.escapeHtml(data.response_time_ms)}ms
</div>
`;
showSuccess('Embedding test passed!');
@@ -524,19 +524,19 @@ async function testConfiguration() {
testResult.innerHTML = `
<div class="ldr-alert ldr-alert-danger">
<i class="fas fa-times-circle"></i> <strong>Test Failed!</strong><br>
- Error: ${data.error || 'Unknown error'}
+ Error: ${window.XSSProtection.escapeHtml(data.error || 'Unknown error')}
</div>
`;
- showError('Embedding test failed: ' + (data.error || 'Unknown error'));
+ showError('Embedding test failed: ' + window.XSSProtection.escapeHtml(data.error || 'Unknown error'));
}
} catch (error) {
testResult.innerHTML = `
<div class="ldr-alert ldr-alert-danger">
<i class="fas fa-times-circle"></i> <strong>Test Failed!</strong><br>
- Error: ${error.message}
+ Error: ${window.XSSProtection.escapeHtml(error.message)}
</div>
`;
- showError('Test failed: ' + error.message);
+ showError('Test failed: ' + window.XSSProtection.escapeHtml(error.message));
} finally {
// Re-enable button
testBtn.disabled = false;