Skip to content

Harden docbook branding scripts.js (CodeQL high alerts) - #279

Merged
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:features/docbkx-scripts-security
Jul 21, 2026
Merged

vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:features/docbkx-scripts-security

Conversation

@vharseko

Copy link
Copy Markdown
Member

Summary

Fixes all high-severity CodeQL alerts in the docbook branding stylesheet commons/doc-default-branding/.../docbkx-stylesheets/bootstrap/scripts.js (a generated-documentation asset). Six alerts across three rules, all in this one file.

Changes

  • js/insecure-download (#2031, #2032, #2033) — three $.getScript() calls fetched executable JavaScript from cdnjs.cloudflare.com over plain HTTP, which is open to man-in-the-middle tampering. Switched to HTTPS; cdnjs serves the same paths over TLS.
  • js/xss-through-dom (#2034, #2035, #2036) — wrapConfigurablesFn read an element's text with .text() and re-inserted it with .html(), so any &, < or > in the text was reinterpreted as markup. The text is now passed through a small escapeHtml() helper before the example strings are wrapped.
  • js/incomplete-hostname-regexp (#2039) — the example host was used directly as a RegExp, so its dots matched any character. The pattern is now built through an escapeRegExp() helper so the literal string is matched literally.

Verification

Node smoke test on the patched file:

  • the file parses;
  • HTML metacharacters (<b>, <script>, &) in the source text are escaped;
  • the example strings are still wrapped in their styled spans (behaviour preserved);
  • the escaped host pattern no longer matches unrelated hosts (e.g. openamXexampleYcom).

Fix all high-severity CodeQL findings in the docbook branding stylesheet:

- js/insecure-download: three $.getScript() calls fetched executable
  JavaScript from cdnjs.cloudflare.com over plain HTTP (man-in-the-middle
  tampering). Switch them to HTTPS; cdnjs serves the same paths over TLS.
- js/xss-through-dom: wrapConfigurablesFn read element text with .text()
  and re-inserted it with .html(), reinterpreting any &, < or > in the
  text as markup. Escape those metacharacters first via a small
  escapeHtml() helper before wrapping the example strings.
- js/incomplete-hostname-regexp: the example host was used directly as a
  RegExp, so its dots matched any character. Build the pattern through an
  escapeRegExp() helper so the literal string is matched literally.

Verified with Node: the file parses, HTML metacharacters are escaped, the
example strings are still wrapped in their styled spans, and the escaped
host pattern no longer matches unrelated hosts.
@vharseko
vharseko requested a review from maximthomas July 20, 2026 16:22
@vharseko vharseko added security Security fixes and CVE remediation codeql CodeQL static-analysis findings labels Jul 20, 2026
@vharseko
vharseko merged commit 01d05f0 into OpenIdentityPlatform:master Jul 21, 2026
14 checks passed
@vharseko
vharseko deleted the features/docbkx-scripts-security branch July 21, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codeql CodeQL static-analysis findings security Security fixes and CVE remediation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants