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): repair non-functional Bearer suppressions in JS (9 false positives) (#4799)

LearningCircuitfb849cd94000
diff --git a/src/local_deep_research/web/static/js/components/chat.js b/src/local_deep_research/web/static/js/components/chat.js
index 28acd20afb..decea47c7f 100644
--- a/src/local_deep_research/web/static/js/components/chat.js
+++ b/src/local_deep_research/web/static/js/components/chat.js
@@ -1301,14 +1301,17 @@
const group = document.createElement('div');
group.className = 'ldr-chat-steps-group';
group.dataset.live = 'true';
- // bearer:disable javascript_lang_insufficiently_random_values — DOM element id for aria-controls wiring only; not security-sensitive (collision is at most a duplicate id)
+ // DOM element id for aria-controls wiring only; not security-sensitive
+ // (a collision is at most a duplicate id) -- Bearer false positive.
+ // bearer:disable javascript_lang_insufficiently_random_values
const contentId = `ldr-chat-steps-content-${Date.now()}-${Math.floor(Math.random() * 1e6)}`;
const header = document.createElement('button');
header.className = 'ldr-chat-steps-header';
header.setAttribute('aria-expanded', 'true');
header.setAttribute('aria-controls', contentId);
header.type = 'button';
- // bearer:disable javascript_lang_dangerous_insert_html — static literal markup only, no user/LLM input
+ // static literal markup only, no user/LLM input -- Bearer false positive.
+ // bearer:disable javascript_lang_dangerous_insert_html
header.innerHTML =
'<i class="fas fa-chevron-right ldr-chat-steps-chevron"></i>' +
'<i class="fas fa-flask"></i>' +
@@ -1413,7 +1416,9 @@
// accordions are wrapped in the same millisecond (rare but
// possible during fast reload), so combine with a counter
// suffix via Math.random.
- // bearer:disable javascript_lang_insufficiently_random_values — DOM element id for aria-controls wiring only; not security-sensitive (collision is at most a duplicate id)
+ // DOM element id for aria-controls wiring only; not security-sensitive
+ // (a collision is at most a duplicate id) -- Bearer false positive.
+ // bearer:disable javascript_lang_insufficiently_random_values
const contentId = `ldr-chat-steps-content-${Date.now()}-${Math.floor(Math.random() * 1e6)}`;
// Header — button for keyboard accessibility
const header = document.createElement('button');
@@ -1421,7 +1426,10 @@
header.setAttribute('aria-expanded', 'false');
header.setAttribute('aria-controls', contentId);
header.type = 'button';
- // bearer:disable javascript_lang_dangerous_insert_html — static literals + integer stepElements.length, no user/LLM input
+ // static literals + integer stepElements.length, no user/LLM input --
+ // Bearer false positive. (Bare rule id on its own line; the eslint
+ // directive below must stay adjacent to the innerHTML assignment.)
+ // bearer:disable javascript_lang_dangerous_insert_html
// eslint-disable-next-line no-unsanitized/property -- audited: all content is static strings, no user input
header.innerHTML =
'<i class="fas fa-chevron-right ldr-chat-steps-chevron"></i>' +
diff --git a/src/local_deep_research/web/static/js/components/progress.js b/src/local_deep_research/web/static/js/components/progress.js
index a050c62893..e09dfff1e7 100644
--- a/src/local_deep_research/web/static/js/components/progress.js
+++ b/src/local_deep_research/web/static/js/components/progress.js
@@ -1281,6 +1281,10 @@
// Create the step element
const step = document.createElement('div');
step.className = `ldr-agent-step ldr-${stepType}`;
+ // label and stepContent are the only interpolations and both pass
+ // through escapeHtml(); everything else is static markup -- Bearer
+ // false positive.
+ // bearer:disable javascript_lang_dangerous_insert_html
step.innerHTML = `
<div class="ldr-agent-step-label">${escapeHtml(label)}</div>
<div class="ldr-agent-step-content">${escapeHtml(stepContent)}</div>
diff --git a/src/local_deep_research/web/static/js/pages/news.js b/src/local_deep_research/web/static/js/pages/news.js
index ffaec83091..0097cbc847 100644
--- a/src/local_deep_research/web/static/js/pages/news.js
+++ b/src/local_deep_research/web/static/js/pages/news.js
@@ -3467,8 +3467,11 @@ function useNewsTemplate(templateId) {
name: modalName,
template: templateId
});
- // bearer:disable javascript_lang_open_redirect — hardcoded path /news, only query params are dynamic
- window.location.href = `/news/subscriptions/new?${params.toString()}`; // bearer:disable javascript_lang_open_redirect
+ // The destination is the hardcoded literal path /news/subscriptions/new;
+ // only the query string is dynamic, so the origin/host cannot be
+ // attacker-controlled -- Bearer false positive (not an open redirect).
+ // bearer:disable javascript_lang_open_redirect
+ window.location.href = `/news/subscriptions/new?${params.toString()}`;
}
}
diff --git a/src/local_deep_research/web/static/js/security/xss-protection.js b/src/local_deep_research/web/static/js/security/xss-protection.js
index 32262a2690..5f2e387715 100644
--- a/src/local_deep_research/web/static/js/security/xss-protection.js
+++ b/src/local_deep_research/web/static/js/security/xss-protection.js
@@ -181,7 +181,9 @@ function safeCreateElement(tagName, text = '', attributes = {}, classNames = [])
throw new Error('safeCreateElement requires DOMPurify to be loaded');
}
- // bearer:disable javascript_lang_dangerous_insert_html — tag validated against SAFE_TAGS whitelist
+ // normalizedTag is validated against the SAFE_TAGS whitelist above (throws
+ // otherwise) and createElement does not parse HTML -- Bearer false positive.
+ // bearer:disable javascript_lang_dangerous_insert_html
const element = document.createElement(normalizedTag);
if (text) {
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 7fd88774af..5f7f35d680 100644
--- a/src/local_deep_research/web/static/js/services/pdf.js
+++ b/src/local_deep_research/web/static/js/services/pdf.js
@@ -26,12 +26,18 @@ function replaceKatexWithLatex(container) {
if (!ann) return;
const p = document.createElement('p');
p.textContent = `$$${ann.textContent}$$`;
- // bearer:disable javascript_lang_dangerous_insert_html -- replaceWith receives a Node built via textContent, not an HTML string; no parsing occurs
+ // replaceWith receives a Node built via textContent, not an HTML
+ // string, so no HTML parsing occurs -- Bearer false positive.
+ // (Directive must be the bare rule id on its own line; trailing
+ // prose after the rule id makes Bearer ignore it.)
+ // bearer:disable javascript_lang_dangerous_insert_html
el.replaceWith(p);
});
container.querySelectorAll('.katex').forEach((el) => {
const ann = el.querySelector('annotation[encoding="application/x-tex"]');
- // bearer:disable javascript_lang_dangerous_insert_html -- replaceWith receives a TextNode via createTextNode, not an HTML string; no parsing occurs
+ // replaceWith receives a TextNode via createTextNode, not an HTML
+ // string, so no HTML parsing occurs -- Bearer false positive.
+ // bearer:disable javascript_lang_dangerous_insert_html
if (ann) el.replaceWith(document.createTextNode(`$${ann.textContent}$`));
});
}
diff --git a/src/local_deep_research/web/static/js/utils/form-validation.js b/src/local_deep_research/web/static/js/utils/form-validation.js
index 28f3b47f06..8a425c922a 100644
--- a/src/local_deep_research/web/static/js/utils/form-validation.js
+++ b/src/local_deep_research/web/static/js/utils/form-validation.js
@@ -32,6 +32,9 @@
// Ensure the field has an ID for aria-describedby
if (!element.id) {
+ // DOM element id for aria-describedby wiring only; not
+ // security-sensitive -- Bearer false positive.
+ // bearer:disable javascript_lang_insufficiently_random_values
element.id = `form-field-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
}