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: Address CodeQL security vulnerabilities

LearningCircuit1506523e73ab
diff --git a/src/local_deep_research/web/auth/routes.py b/src/local_deep_research/web/auth/routes.py
index 71b56a4d17..e03a87fb9d 100644
--- a/src/local_deep_research/web/auth/routes.py
+++ b/src/local_deep_research/web/auth/routes.py
@@ -159,7 +159,7 @@ def login():
# Check if it's in the whitelist or is a safe relative path
if parsed_url.path in allowed_paths:
- safe_redirect = next_page
+ safe_redirect = parsed_url.path # Use parsed path, not raw input
elif (
parsed_url.path
and parsed_url.path.startswith("/")
@@ -167,7 +167,9 @@ def login():
):
# Additional checks for safety
if ".." not in parsed_url.path and normalized_path.startswith("/"):
- safe_redirect = next_page
+ safe_redirect = (
+ parsed_url.path
+ ) # Use parsed path, not raw input
else:
logger.warning(
f"Blocked potentially unsafe redirect with path traversal: {next_page}"
diff --git a/src/local_deep_research/web/static/js/services/pdf.js b/src/local_deep_research/web/static/js/services/pdf.js
index fa5228922e..7d981139f3 100644
--- a/src/local_deep_research/web/static/js/services/pdf.js
+++ b/src/local_deep_research/web/static/js/services/pdf.js
@@ -860,14 +860,18 @@ async function downloadPdf(titleOrData, content, metadata = {}) {
.replace(/<h3[^>]*>(.*?)<\/h3>/gi, '### $1\n\n')
.replace(/<p[^>]*>(.*?)<\/p>/gi, '$1\n\n')
.replace(/<li[^>]*>(.*?)<\/li>/gi, '- $1\n')
- .replace(/<br\s*\/?>/gi, '\n')
- .replace(/<(?:.|\n)*?>/gm, '') // Remove remaining HTML tags
+ .replace(/<br\s*\/?>/gi, '\n');
+
+ // Use DOM-based HTML stripping for security (prevents XSS)
+ const tempDiv = document.createElement('div');
+ tempDiv.innerHTML = pdfContent;
+ pdfContent = (tempDiv.textContent || tempDiv.innerText || '')
.replace(/&nbsp;/gi, ' ')
.replace(/&lt;/gi, '<')
.replace(/&gt;/gi, '>')
- .replace(/&amp;/gi, '&')
.replace(/&quot;/gi, '"')
.replace(/&apos;/gi, "'")
+ .replace(/&amp;/gi, '&') // MUST be last to prevent double-unescaping
.replace(/\n{3,}/g, '\n\n'); // Normalize excessive newlines
} else {
// Last resort: stringify the entire object