Skip to content

fix(export): escape remaining role sinks + nonce-based CSP in HTML session export - #61769

Merged
teknium1 merged 3 commits into
mainfrom
salvage/export-hardening
Jul 10, 2026
Merged

fix(export): escape remaining role sinks + nonce-based CSP in HTML session export#61769
teknium1 merged 3 commits into
mainfrom
salvage/export-hardening

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Completes the HTML session-export hardening that #61345 started: the two remaining externally-influenced sinks (role badge, message CSS class) are now escaped/sanitized, and the export ships a nonce-based Content-Security-Policy so any markup that slips a future sink is inert.

Consolidates two contributor PRs (cherry-picked, authorship preserved):

Changes

  • hermes_cli/session_export_html.py: role escaped in badge, role reduced to a single safe CSS token for the class attribute; nonce CSP meta + nonce'd inline script
  • tests/hermes_cli/test_session_export_html_escape.py (new) + additions to test_session_export.py
  • scripts/release.py: AUTHOR_MAP for kohoj

Validation

Before After
Hostile role (<img onerror=…>) executes on export open escaped, inert
Injected markup via any future sink executes blocked by CSP (nonce-only script)
Export tests 23/23 green across all 4 export test files
E2E hostile role + tool name inert; nonce consistent single+multi; switcher works

Infographic

infographic

briandevans and others added 3 commits July 9, 2026 18:47
Addresses Copilot review on #61348: the HTML-escaped role, while safe from
injection (quotes are escaped), still contains whitespace when a crafted role
is supplied, which splits the class attribute into several unintended CSS
classes. Keep the escaped role for the display badge, and reduce the raw role
to a single safe CSS token (alnum/-/_) for the class name. Real roles
(user/assistant/system/tool) are unchanged, so the existing .message-<role>
rules still match.
@alt-glitch alt-glitch added type/security Security vulnerability or hardening P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Jul 10, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related: completes the HTML session-export XSS hardening from merged #61345 (which escaped only the tool-call name), consolidating OPEN #61348 (@briandevans — role escaping) and #61667 (@kohoj — nonce CSP), against issue #61343. Verified the message role is still interpolated raw on main (session_export_html.py:686/:694). Consolidation with authorship preserved — related, not a duplicate; a maintainer should pick this consolidated PR vs the individual #61348/#61667.

@teknium1
teknium1 merged commit c49d51b into main Jul 10, 2026
31 checks passed
@teknium1
teknium1 deleted the salvage/export-hardening branch July 10, 2026 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants