Repository navigation
Conversation
- Add a CSP <meta> tag: connect-src allows only the Anthropic API (and the page's own origin), remote images are blocked, and scripts load only from FinLens's own files plus five exact CDN file URLs. - Pin Chart.js, PapaParse and Day.js with SRI hashes, moving them from cdnjs to jsDelivr's npm mirror so every hash can be checked against npm. - CLAUDE.md §2/§15, README, CHANGELOG, version bumped to v1.10.6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Z8iBYnr2QiFrzchNxfCti
This was referenced Nov 2, 2026
Open
This was referenced Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two security hardening changes, both in
index.html:<meta>tag limits what the page can load and, more importantly, where it can send data.connect-srcallows onlyhttps://api.anthropic.comand the page's own origin, so code that got into the page (a tampered library, an injection) can't post your data to another server withfetch()or XHR. Remote images are blocked too, which closes image beacons.integrityhash, so a tampered or changed CDN copy would have run with full access to IndexedDB, localStorage and the API key. All five libraries are now pinned and hashed.To make the hashes verifiable, Chart.js, PapaParse and Day.js moved from cdnjs to the same versions on jsDelivr's npm mirror, which serves the npm files byte for byte. Every hash was computed from the npm package (
npm pack+openssl dgst -sha384). As a cross-check, the existing marked and DOMPurify hashes match their npm packages exactly.The policy
default-src 'none'; script-src 'self' 'unsafe-inline' <5 exact CDN file URLs>; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src https://fonts.gstatic.com; img-src 'self' data: blob:; connect-src 'self' https://api.anthropic.com; object-src 'none'; base-uri 'none'; form-action 'none'Limits (honest scope)
'unsafe-inline'stays inscript-src. About 85 inlineonclickhandlers in the views need it. The CSP limits where injected script can send data, not whether it runs. Removing it means converting those handlers toaddEventListener, which is a larger refactor for its own PR.<meta>CSP can't setframe-ancestorsor report violations, and navigations (links,location) aren't covered. Those need HTTP headers, which afile://page doesn't have.Changes
index.html— CSP meta tag; SRI-pinned script tags from jsDelivr.CLAUDE.md— §2 documents the CSP, its limits and how to recompute a hash; §15 says new CDN scripts need a hash and a CSP entry.README.md,CHANGELOG.md,js/views-settings.js— v1.10.6.Not verified
/npm/path serves those files unchanged, but please open the app once and check the console.connect-src, which allows the API.'self', but onlyfile://was tested).Automated checks: earlier run, not re-run · commit not recorded
Moved unchanged from this PR's "Test results" comment on 2026-11-04; not re-run, so not in the new table format. Originally a description section titled "Testing".
Headless Chrome via Playwright, opening
index.htmlasfile://(how FinLens is normally run). The sandbox can't reach the CDNs, so CDN requests were served from the npm packages, which is exactly what the hashes are checked against.'self'matches FinLens's own scripts onfile://.samples/(257 transactions) and opened all 25 views. No CSP violations and no errors, same asmaster.fetch('https://example.com/…')→ blocked byconnect-src; a remote<img>→ blocked byimg-src. Onmasterthe same fetch went through.fetch('https://api.anthropic.com/v1/messages')passes the CSP.Not verified:
/npm/path serves those files unchanged, but please open the app once and check the console.connect-src, which allows the API.'self', but onlyfile://was tested).Manual QA steps
Setup
git checkout csp-and-sri.samples/(on this branch they are still namedally_checking_sample.csv,ally_savings_sample.csv,chase_card_sample.csv) into a new scratch folder (e.g.Desktop\finlens-test). This PR does not change saving, but test 5 writesfinlens-state.json, so keep it away from your real folder.index.htmlfrom disk in Edge.1. The page loads with no CSP or integrity errors
jsdelivrin the filter box.Expected:
cdn.jsdelivr.net(chart.umd.js, papaparse.min.js, marked.min.js, purify.min.js, dayjs.min.js), all status 200.cdnjs.cloudflare.comany more.style-srcandfont-src.Before this fix: Chart.js, PapaParse and Day.js loaded from cdnjs with no
integrityattribute.2. Each library still works (import, dates, charts)
Expected:
'unsafe-inline').3. Data can't be sent to another server
fetch('https://example.com/x').then(()=>console.log('SENT'),e=>console.log('BLOCKED',e.message))and press Enter.var i=new Image(); i.onload=()=>console.log('IMG LOADED'); i.onerror=()=>console.log('IMG BLOCKED'); i.src='https://example.com/a.png'and press Enter.fetch('https://api.anthropic.com/v1/messages',{method:'POST'}).then(r=>console.log('API reachable',r.status),e=>console.log('API BLOCKED',e.message))and press Enter.Expected:
Before this fix: step 1 would print SENT (or a CORS error, but the request still left the browser).
4. AI Analysis still works and renders Markdown
Expected:
finlens-analysis-<date>.mdfile downloads.5. Saving to the folder still works
Expected:
finlens-state.jsonexists in the scratch folder with a current modified time.6. Regression: downloads and theme
Expected:
7. (Optional) A tampered library is blocked
dayjs.min.jsrequest, and choose Override content.//xon a new line at the end and press Ctrl+S.Expected:
Before this fix: the changed Day.js file would run with no warning.
Please check before merging
index.html, hard-reload, and confirm the console has no CSP or integrity errors.master. Open PRs v1.17.0: Settings → Database tab (DB Inspector, DB Schema), rebuilt on the Clarity redesign #10 and v1.12.0: Remove bank names from the app; neutral account codes with a data migration #16–v1.16.0: Clarity redesign, part 4 — Trends, AI Analysis, Settings, Welcome #21 already use v1.11.0–v1.16.0, so merging this first keeps the numbers in order. If one of those merges first, I'll rebase and renumber.Generated by Claude Code
Generated by Claude Code