Skip to content

Escape evidence and case-file text in the interface; serve it with a Content-Security-Policy - #188

Merged
switch-nz merged 2 commits into
mainfrom
claude/escape-ui-and-csp
Nov 14, 2026
Merged

switch-nz merged 2 commits into
mainfrom
claude/escape-ui-and-csp

Conversation

@switch-nz

Copy link
Copy Markdown
Owner

What changes for examiners

Text that comes from evidence, a case file or a folder name is shown as text everywhere it was found being written into the page as markup:

  • the event viewer's event ID and record number (the parser returns whatever the log holds, not a number),
  • the audit dialog's time and action for each entry, as stored in the case file,
  • the parent folder's path in the file browser.

The interface's own pages are now served with a Content-Security-Policy that runs only Strata's own script files (script-src 'self', no inline script), plus nosniff. A place that is missed later displays the text rather than running it.

The change

  • web/app.js: six interpolations escaped.
  • engine/server.py: CSP_APP, sent on static responses. Styles keep 'unsafe-inline' because the interface sets inline styles itself; images allow data: for previews; frames and media are same-origin only.
  • tests/test_ui_escaping.py (7 tests): the escapes, that the event parser really does return text, that the page has no inline script or handlers for the policy to break, the policy's rules, and that static pages are served with it. 5 fail on the old code.

Verification

  • Full suite 1433 tests OK (14 skipped); smoke test passes.
  • Driven in Chromium against a running server: with hostile values fed to the audit dialog and file browser, the old code runs the injected handler; the new code shows the text and nothing runs. With the policy on, opening the tree, 12 file previews and several dialogs (including submitting one with Enter) produced no policy violations.

Not in this PR: timestamps written unescaped into the HTML report, the Office DOCTYPE check's 4 KB window, and the unbounded request body. Those are smaller and separate.


Generated by Claude Code

The event viewer wrote an event's ID and record number, the audit dialog
wrote each entry's time and action, and the file browser wrote the parent
folder's path into the page unescaped. All are escaped now. Static pages
carry a Content-Security-Policy that allows only the interface's own
script files, plus nosniff.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017DPjyZZHvaivtvJ3N4hZhz

Copy link
Copy Markdown
Owner Author

Three checks are red and none is caused by this change: Unit tests (Python 3.8), Smoke test (ubuntu-latest, Python 3.8) and Smoke test (ubuntu-latest, Python 3.9).

Each fails in actions/setup-python, before any test runs: The version '3.8' with architecture 'x64' was not found for Ubuntu 26.04. ubuntu-latest now resolves to Ubuntu 26.04, which has no Python 3.8 or 3.9 builds. The same jobs will fail on main at its next run; nothing in this diff touches CI.

No fix exists yet. Proposed patch, as its own change: run the 3.8 and 3.9 Linux jobs on ubuntu-24.04 (which still carries both) and leave the rest on ubuntu-latest. The alternative is to drop 3.8/3.9 from the matrix, which changes the "Python 3.8 or later" promise in the README and is the maintainer's call.


Generated by Claude Code

ubuntu-latest now resolves to Ubuntu 26.04, for which setup-python has no
3.8 or 3.9 builds, so those jobs failed before any test ran. Job names are
unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017DPjyZZHvaivtvJ3N4hZhz
@switch-nz
switch-nz merged commit 796a44b into main Nov 14, 2026
33 checks passed
@switch-nz
switch-nz deleted the claude/escape-ui-and-csp branch November 14, 2026 22:24
@switch-nz switch-nz mentioned this pull request Nov 14, 2026
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