diff --git a/CHANGELOG.md b/CHANGELOG.md index a41488d..622f6e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). --- +## [1.10.6] — 2026-11-02 + +### Security +- **A Content Security Policy limits where FinLens can send your data.** `index.html` now starts with a CSP `` tag. Its key rule is `connect-src`: scripts can only reach the Anthropic API (and the page's own origin), so code that got into the page, from a tampered library or an injection, can't post your transactions to another server with `fetch()` or XHR. Remote images are blocked too, which closes image beacons. Scripts can load only from FinLens's own files and five exact CDN file URLs. + - **Limit:** `'unsafe-inline'` stays in `script-src`, because many views use inline `onclick` handlers. The CSP restricts where injected inline script can send data, not whether it runs. Removing it is a larger refactor. +- **Every CDN script is pinned with an SRI hash.** Chart.js, PapaParse and Day.js had none, so a tampered or changed CDN copy would have run with full access to your data. All three now have `integrity` attributes, like marked and DOMPurify already did. A file that doesn't match is blocked instead of run. +- **All five libraries now load from jsDelivr's npm mirror.** Chart.js, PapaParse and Day.js moved from cdnjs to the same versions on jsDelivr, which serves the published npm files byte for byte. Each hash was computed from the npm package and can be re-checked the same way; the existing marked and DOMPurify hashes match their npm packages too. + +### Docs +- **CLAUDE.md §2** — SRI on every CDN script, how to recompute a hash, the CSP and its limits; **§15** — new CDN scripts need a hash and a CSP entry. + +--- + ## [1.10.5] — 2026-11-02 ### Fixed diff --git a/CLAUDE.md b/CLAUDE.md index d895c1b..c4d79cc 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -59,7 +59,7 @@ Until then, this section is the rule. FinLens is a **single-origin, zero-build, vanilla JavaScript personal finance dashboard** that runs entirely in the browser. There is no server, no npm, no bundler, no framework, and no TypeScript. The entry point is `index.html`; everything else is a plain `.js` file in the `js/` folder. -**Current version:** v1.10.5 (updated in `index.html` footer, `README.md`, and `CHANGELOG.md` on every release). +**Current version:** v1.10.6 (updated in `index.html` footer, `README.md`, and `CHANGELOG.md` on every release). **What it does:** Imports CSV exports from Ally Bank (Checking + Savings) and Chase credit cards, parses and normalizes them into a unified transaction model, and renders a multi-tab financial dashboard with budgeting, debt tracking, savings forecasting, investment planning, and Claude-powered AI analysis. @@ -71,16 +71,32 @@ FinLens is a **single-origin, zero-build, vanilla JavaScript personal finance da |---|---|---| | Markup + CSS | Vanilla HTML5 / CSS custom properties | `index.html` | | JavaScript | Vanilla ES2020+ (global scope) | `js/*.js` | -| CSV parsing | PapaParse | CDN 5.4.1 | -| Charts | Chart.js | CDN 4.4.1 | -| Date formatting | Day.js | CDN 1.11.10 | +| CSV parsing | PapaParse | jsDelivr 5.4.1 (pinned + SRI) | +| Charts | Chart.js | jsDelivr 4.4.1 (pinned + SRI) | +| Date formatting | Day.js | jsDelivr 1.11.10 (pinned + SRI) | | Markdown render | marked.js | jsDelivr 15.0.12 (pinned + SRI) | | HTML sanitizer | DOMPurify | jsDelivr 3.4.17 (pinned + SRI) | | AI | Anthropic Messages API (`claude-sonnet-5-5`, `AI_MODEL` in `views-ai.js`) | Direct browser fetch | | Persistence | `finlens-state.json` via File System Access API → IndexedDB → `localStorage` (see §4.5) | Browser native | | IndexedDB | Native — `finlens_db` (all app data, §19) and `finlens_fs` (CSV folder handle, §14) | Browser native | -Scripts that render model output (marked, DOMPurify) are version-pinned with `integrity`/`crossorigin` attributes. When bumping either, recompute the SRI hash from the exact file and update both `index.html` and this table. +**Every CDN script is version-pinned with `integrity`/`crossorigin` attributes (v1.10.6),** and all five come from jsDelivr's npm mirror (`cdn.jsdelivr.net/npm/@/`), which serves the published npm files byte for byte. That makes each hash checkable without the CDN: `npm pack @`, then `openssl dgst -sha384 -binary | openssl base64 -A`. A file that doesn't match its hash is blocked and the app breaks visibly, which is the point: it fails closed. + +**Content Security Policy (v1.10.6).** A `` at the top of `index.html` limits what the page can load and where it can send data: + +| Directive | Allows | Why | +|---|---|---| +| `default-src` | nothing | Anything not listed below is blocked | +| `script-src` | `'self'`, `'unsafe-inline'`, the five exact CDN file URLs | Own scripts, inline handlers (§12), pinned libraries only | +| `style-src` | `'self'`, `'unsafe-inline'`, Google Fonts CSS | All CSS is inline (§6) | +| `font-src` | Google Fonts files | | +| `img-src` | `'self'`, `data:`, `blob:` | Favicon is a `data:` URL; no remote images, so no image beacons | +| `connect-src` | `'self'`, `https://api.anthropic.com` | **The key line:** `fetch`/XHR can only reach the Anthropic API (and the page's own origin, for AI Eval samples over HTTP) | +| `object-src`, `base-uri`, `form-action` | nothing | | + +- **When adding or bumping a library,** update the script tag, its hash, the exact URL in `script-src` and this table together. A URL missing from `script-src` is blocked even with a correct hash. +- **When calling a new remote API,** add its origin to `connect-src`, or the call is blocked with a console error. +- **Limits:** `'unsafe-inline'` means injected inline script would still run; the CSP limits where it can send data, not whether it runs. Dropping it needs every inline `onclick` replaced with `addEventListener`. A `` CSP can't set `frame-ancestors` or report violations; those need HTTP headers, which a `file://` page doesn't have. Navigations (links, `location`) aren't covered by CSP. **No build step.** Open `index.html` in Chrome/Edge/Arc/Brave and it just works. Safari and Firefox are supported but degrade gracefully on File System Access API features. @@ -704,7 +720,7 @@ The handle lives in a separate `finlens_fs` database (distinct from `finlens_db` - **Do not add npm, a bundler, or a build step.** The project is intentionally zero-dependency local. - **Do not use ES module `import/export`** — all files share global scope by design. - **Do not use `async`/`await` in view render functions** — renders are synchronous. Async work (API calls, file I/O) belongs in handler functions, not in the `registerView` callback. -- **Do not add new CDN scripts without adding them to `index.html`** and documenting the version in this file. +- **Do not add new CDN scripts without adding them to `index.html`** with an SRI hash, adding the exact URL to the CSP `script-src`, and documenting the version in §2. - **Do not call `localStorage` directly** — always use `lsSet`/`lsGet`. - **Do not create CSS files** — all CSS belongs in the `