Skip to content

Security: DOM-based Theme Injection via Unsanitized Input in Template Literal#633

Open
barttran2k wants to merge 1 commit intooffa:masterfrom
barttran2k:contribai/fix/security/dom-based-theme-injection-via-unsanitize
Open

Security: DOM-based Theme Injection via Unsanitized Input in Template Literal#633
barttran2k wants to merge 1 commit intooffa:masterfrom
barttran2k:contribai/fix/security/dom-based-theme-injection-via-unsanitize

Conversation

@barttran2k
Copy link
Copy Markdown
Contributor

Problem

The changeCSS() function directly interpolates its theme parameter into a URL template literal without validation. While currently called only from a <select> element with fixed <option> values, if invoked programmatically with a crafted value (e.g., via browser console or future code changes), it could load an arbitrary external stylesheet by manipulating the URL path.

Severity: low
File: index.html

Solution

Validate the theme parameter against an allowlist of known theme names before constructing the URL: const allowedThemes = ['darkly', 'united', 'flatly', 'quartz']; if (!allowedThemes.includes(theme)) return;.

Changes

  • index.html (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

The `changeCSS()` function directly interpolates its `theme` parameter into a URL template literal without validation. While currently called only from a `<select>` element with fixed `<option>` values, if invoked programmatically with a crafted value (e.g., via browser console or future code changes), it could load an arbitrary external stylesheet by manipulating the URL path.

Affected files: index.html

Signed-off-by: Trần Bách <45133811+barttran2k@users.noreply.github.com>
@offa
Copy link
Copy Markdown
Owner

offa commented Apr 7, 2026

What's different than #629?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants