Skip to content

fix(security): CSP script-src must include unsafe-inline for inline event handlers - #209

Merged
nesquena-hermes merged 1 commit into
masterfrom
fix/csp-unsafe-inline
Apr 10, 2026
Merged

fix(security): CSP script-src must include unsafe-inline for inline event handlers#209
nesquena-hermes merged 1 commit into
masterfrom
fix/csp-unsafe-inline

Conversation

@nesquena-hermes

Copy link
Copy Markdown
Collaborator

Bug found during full QA browser sanity check: The CSP script-src 'self' policy introduced in PR #197 blocks all inline onclick= event handlers in index.html. The app has 55+ inline handlers (toggleSettings(), switchPanel(), filterSessions(), clearConversation(), etc.) — all are blocked, making the settings panel, sidebar navigation, and most interactive controls non-functional.

Evidence from browser console:

Executing inline event handler violates the following Content Security Policy directive 'script-src 'self''. Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required.

Fix: Added 'unsafe-inline' to script-src. This is consistent with style-src which already has 'unsafe-inline' for the theme system. Using hash-based CSP would require computing and maintaining SHA256 for 55+ event handlers — not practical for this codebase.

Also restores https://cdn.jsdelivr.net to script-src and style-src (needed for Mermaid.js and Prism.js) which was dropped in the v0.42.1 commit.

564 tests passing.

The CSP script-src 'self' policy blocked all inline onclick= event handlers
in index.html (55+ handlers including toggleSettings(), switchPanel(),
filterSessions() etc.), making the settings panel, sidebar navigation, and
most interactive UI elements non-functional.

Also restores https://cdn.jsdelivr.net to both script-src and style-src
(required for Mermaid.js dynamic load in ui.js and Prism.js static load
in index.html). This was present in the original PR #197 merge but was
dropped in the v0.42.1 commit.

script-src additions:
- 'unsafe-inline': required for onclick=/oninput=/onchange= attributes
- https://cdn.jsdelivr.net: Mermaid (dynamic) and Prism (static with SRI)

style-src: retains 'unsafe-inline' + cdn.jsdelivr.net (Prism CSS)
@nesquena-hermes
nesquena-hermes merged commit cc8cbc4 into master Apr 10, 2026
@nesquena-hermes
nesquena-hermes deleted the fix/csp-unsafe-inline branch April 10, 2026 02:07
JKJameson pushed a commit to JKJameson/hermes-webui that referenced this pull request Apr 25, 2026
…esquena#209)

The CSP script-src 'self' policy blocked all inline onclick= event handlers
in index.html (55+ handlers including toggleSettings(), switchPanel(),
filterSessions() etc.), making the settings panel, sidebar navigation, and
most interactive UI elements non-functional.

Also restores https://cdn.jsdelivr.net to both script-src and style-src
(required for Mermaid.js dynamic load in ui.js and Prism.js static load
in index.html). This was present in the original PR nesquena#197 merge but was
dropped in the v0.42.1 commit.

script-src additions:
- 'unsafe-inline': required for onclick=/oninput=/onchange= attributes
- https://cdn.jsdelivr.net: Mermaid (dynamic) and Prism (static with SRI)

style-src: retains 'unsafe-inline' + cdn.jsdelivr.net (Prism CSS)

Co-authored-by: Nathan Esquenazi <nesquena@gmail.com>
SysAdminDoc pushed a commit to SysAdminDoc/hermes-webui that referenced this pull request Jun 26, 2026
…esquena#209)

The CSP script-src 'self' policy blocked all inline onclick= event handlers
in index.html (55+ handlers including toggleSettings(), switchPanel(),
filterSessions() etc.), making the settings panel, sidebar navigation, and
most interactive UI elements non-functional.

Also restores https://cdn.jsdelivr.net to both script-src and style-src
(required for Mermaid.js dynamic load in ui.js and Prism.js static load
in index.html). This was present in the original PR nesquena#197 merge but was
dropped in the v0.42.1 commit.

script-src additions:
- 'unsafe-inline': required for onclick=/oninput=/onchange= attributes
- https://cdn.jsdelivr.net: Mermaid (dynamic) and Prism (static with SRI)

style-src: retains 'unsafe-inline' + cdn.jsdelivr.net (Prism CSS)

Co-authored-by: Nathan Esquenazi <nesquena@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants