Agent daybook is a web application that allows tracking multiple feeds of artifacts (reports, notes, log items etc. etc.) - all the things that AI agents would be producing all day long.
Find a file
peter e3c5773e8f Fix #014: sanitize themed text kinds + script-blocking CSP (stored XSS)
markdown/deck/html_fragment rendered author-influenced content verbatim,
so <script>/<img onerror>/etc. executed on the Daybook origin — self-XSS
against the owner's session, and (post-sharing) unauthenticated via /s/.

Two layers, both in artifacts/views.py:
- Create-time allowlist sanitization via nh3 (maintained ammonia/Rust
  sanitizer, not deprecated bleach). Keeps formatting/tables/links/images
  (incl. relative /assets URLs) and codehilite markup; drops script, on*
  handlers, style, unknown tags, and javascript:/data: URLs. html_full is
  deliberately NOT sanitized (documented verbatim escape hatch).
- Serve-time CSP (script-src 'none') for the sanitized kinds, on both
  /a/{id} and the unauthenticated /s/{token} route. Being a response
  header, it also neutralizes scripts in artifacts stored before this fix.
  Not applied to html_full or json/csv (json/csv data is already escaped;
  their viewers need their own JS).

Verified live across all kinds; 7 regression tests added. 102 tests pass.

Not addressed (noted in the issue): CSV formula injection,
CSRF_COOKIE_HTTPONLY (moot with XSS closed), nonce CSP for json/csv/full.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-03 10:44:49 +01:00
.claude/commands Initial public commit 2026-09-01 21:55:02 +01:00
artifacts Fix #014: sanitize themed text kinds + script-blocking CSP (stored XSS) 2026-09-03 10:44:49 +01:00
daybook_project Fix concurrent posts racing past quota (issue #010) 2026-09-02 15:22:37 +01:00
deploy Close out issue 001: document CSRF/reverse-proxy requirement 2026-09-02 12:28:41 +01:00
docs Fix #014: sanitize themed text kinds + script-blocking CSP (stored XSS) 2026-09-03 10:44:49 +01:00
issues Fix #014: sanitize themed text kinds + script-blocking CSP (stored XSS) 2026-09-03 10:44:49 +01:00
scripts Initial public commit 2026-09-01 21:55:02 +01:00
skills/daybook-posting Fix #014: sanitize themed text kinds + script-blocking CSP (stored XSS) 2026-09-03 10:44:49 +01:00
static Add light/dark mode toggle for the UI 2026-09-02 17:14:56 +01:00
templates/artifacts Add light/dark mode toggle for the UI 2026-09-02 17:14:56 +01:00
tests Fix #014: sanitize themed text kinds + script-blocking CSP (stored XSS) 2026-09-03 10:44:49 +01:00
.dockerignore Initial public commit 2026-09-01 21:55:02 +01:00
.gitignore Initial public commit 2026-09-01 21:55:02 +01:00
CLAUDE.md Add per-artifact public sharing 2026-09-02 16:00:39 +01:00
manage.py Initial public commit 2026-09-01 21:55:02 +01:00
requirements.txt Fix #014: sanitize themed text kinds + script-blocking CSP (stored XSS) 2026-09-03 10:44:49 +01:00