Overview
| Artifact ID: | 2b2db7e73502712eb4e43b6abc8fff44450b9dd4bffb5887e76468eca6eacc8b |
|---|---|
| Ticket: | 3b0939bad2dd72e9fd91a979d4d2f931ae6fe7a4
Adopt a strict CSP: datastar CSP mode, nonces, and the untrusted-expression audit |
| User & Date: | ai-local on 2026-08-31 17:12:06 |
Changes
- Untracked field cmimetype: "text/x-markdown"
- comment changed to:
quarry sets NO page CSP today. The only Content-Security-Policy in the tree is on attachment downloads (default-src none; sandbox), which is right for uploaded files and says nothing about the app. WHAT BLOCKS A STRICT ONE. Not the data-on:* attributes — those are data attributes, not inline handlers, and script-src does not govern them. The blocker is unsafe-eval: datastar evaluates expressions with the Function() constructor. 1.0.3 (now vendored, e13cb746) adds CSP mode, which applies a per-response nonce at expression-compile time instead, allowing script-src self nonce-... with no unsafe-eval. quarry is well placed: one script tag, zero inline script bodies, already pinned by a test. Two genuine inline handlers remain on the clone-URL widget — onfocus=this.select() and onclick=this.previousElementSibling.select() — which ARE unsafe-inline and must move to data-on:*. Work: (1) move those two handlers; (2) generate a cryptographically secure nonce per full-page response and put it on <html> as data-nonce; (3) set Content-Security-Policy with script-src self nonce; (4) decide the rest of the policy — img-src, style-src now that the sheet is an external asset, connect-src for SSE. THE AUDIT, which is the real work. The datastar docs are blunt: CSP mode does NOT make expressions safe with untrusted content — it applies a nonce, it does not sanitize. quarry renders commit messages, ticket titles and forum posts from MIRRORED upstreams (sqlite, tcl, fossil), so any place an untrusted string is interpolated into a data-* expression is an injection whether or not CSP mode is on. The rule is to pass user values through signals and keep expressions static. Audit every data-* expression for interpolated content and pin the rule with a test. Adjacent and cheap: the JS assets are Cache-Control max-age=86400 with no content hash, so they revalidate daily. The stylesheet is already hashed+immutable (eb4793ee); giving the scripts the same URL shape removes that round trip and is worth more than the 1.3KB brotli would save on the bundle. Acceptance: a strict CSP is served on every page; no unsafe-eval, no unsafe-inline; the interactive surfaces (file windowing, ticket selects, composer preview, live timeline) all still work in a browser; a test asserts the header is present and that no data-* expression interpolates request or repository content.
- priority changed to: "High"
- severity changed to: "Important"
- status changed to: "Open"
- subsystem changed to: "web"
- title changed to:
Adopt a strict CSP: datastar CSP mode, nonces, and the untrusted-expression audit
- type changed to: "Feature"