Skip to content

Security: Theme selection via DOM input without validation#629

Merged
offa merged 1 commit intooffa:masterfrom
barttran2k:contribai/fix/security/theme-selection-via-dom-input-without-va
Apr 7, 2026
Merged

Security: Theme selection via DOM input without validation#629
offa merged 1 commit intooffa:masterfrom
barttran2k:contribai/fix/security/theme-selection-via-dom-input-without-va

Conversation

@barttran2k
Copy link
Copy Markdown
Contributor

Problem

The changeCSS function constructs a URL by interpolating user-controlled input (theme parameter from the <select> element) directly into a CDN URL template. While the current <select> restricts values, if the function were called programmatically (e.g., via browser console or if the DOM is manipulated), an attacker could inject an arbitrary path into the stylesheet URL, potentially loading a malicious CSS file from the CDN.

Severity: low
File: index.html

Solution

Validate the theme parameter against an allowlist of known themes 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 constructs a URL by interpolating user-controlled input (`theme` parameter from the `<select>` element) directly into a CDN URL template. While the current `<select>` restricts values, if the function were called programmatically (e.g., via browser console or if the DOM is manipulated), an attacker could inject an arbitrary path into the stylesheet URL, potentially loading a malicious CSS file from the CDN.

Affected files: index.html

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

@offa offa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@offa offa merged commit 67d3746 into offa:master Apr 7, 2026
4 checks passed
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