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): dismiss false-positive Bearer alerts #6916 and #6020 (#2343)

LearningCircuit428108cd1456
diff --git a/.github/workflows/bearer.yml b/.github/workflows/bearer.yml
index 09b2940672..356975d5b3 100644
--- a/.github/workflows/bearer.yml
+++ b/.github/workflows/bearer.yml
@@ -32,6 +32,7 @@ jobs:
uses: bearer/bearer-action@828eeb928ce2f4a7ca5ed57fb8b59508cb8c79bc # v2
with:
scanner: sast,secrets
+ config-file: bearer.yml
format: sarif
output: bearer-results.sarif
exit-code: 0 # Report findings but don't fail the build
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 f6f1d17370..cc4793b475 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
@@ -171,6 +171,10 @@ function safeCreateElement(tagName, text = '', attributes = {}, classNames = [])
if (!SAFE_TAGS.has(normalizedTag)) {
throw new Error('safeCreateElement: disallowed tag "' + tagName + '"');
}
+ if (!hasDOMPurify()) {
+ throw new Error('safeCreateElement requires DOMPurify to be loaded');
+ }
+
// bearer:disable javascript_lang_dangerous_insert_html — tag validated against SAFE_TAGS whitelist
const element = document.createElement(normalizedTag);
@@ -178,10 +182,9 @@ function safeCreateElement(tagName, text = '', attributes = {}, classNames = [])
element.textContent = text;
}
- // setAttribute is inherently safe per OWASP — no HTML interpretation
Object.entries(attributes).forEach(([key, value]) => {
if (key && value !== null && value !== undefined) {
- element.setAttribute(key, String(value));
+ element.setAttribute(String(key), String(value));
}
});
@@ -189,7 +192,13 @@ function safeCreateElement(tagName, text = '', attributes = {}, classNames = [])
element.className = classNames.join(' ');
}
- return element;
+ // Let DOMPurify sanitize attributes (on*, javascript:/data: URIs, etc.)
+ const clean = DOMPurify.sanitize(element.outerHTML, {
+ ALLOWED_TAGS: [normalizedTag],
+ RETURN_DOM_FRAGMENT: true,
+ });
+
+ return clean.firstChild || element;
}
/**