Security hardening: auth, CSRF, CI, and threat model#1
Conversation
…tection Addresses findings #1 and #2 from security_analysis.md: - Generate random per-launch auth token (secrets.token_urlsafe) - All API endpoints require Bearer token in Authorization header - HTML page embeds token and JS includes it in all fetch() calls - Host header validation rejects non-localhost requests (DNS rebinding) - Origin header validation on POST requests (CSRF protection) - POST /api/resume validates session_id and dirname exist in dataset - Token printed at startup for debugging Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Addresses finding #3 from security_analysis.md: - Pin all GitHub Actions to full commit SHAs (with version comments) - Reduce default workflow permissions to contents: read - Move badge generation to separate job with minimal contents: write - Only the badge job (on main push) gets write permissions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Addresses low-severity finding from security_analysis.md: - Remove generic lsof/kill fallback that could kill unrelated processes - Only stop the subprocess the menubar app actually started - Add kill() fallback if terminate() doesn't work within timeout Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Addresses recommendation from security_analysis.md to document the threat model. Lists all security measures: auth token, host validation, origin validation, session validation, secret masking, and CI hardening. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Security review follow-up:
AI models used for this review:
|
…in tests Addresses PR review feedback: 1. HTML page (/) now requires auth — no longer exposes token to unauthenticated local clients. Flow: browser opens /?token=<secret>, server sets HttpOnly SameSite=Strict cookie and redirects to /. Subsequent requests use cookie automatically. 2. Added regression tests for Host and Origin validation: - test_rejects_invalid_host_header (DNS rebinding) - test_rejects_invalid_origin_on_post (CSRF) - test_allows_localhost_origin_on_post - test_allows_no_origin_on_post (non-browser clients) - test_html_page_requires_auth - test_html_page_token_url_sets_cookie Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Addressed both review items in commit 4796fda: 1. Token disclosure on
2. Missing Host/Origin validation tests (Low)
Plus 2 tests for the new auth-on-HTML behavior:
All 115 tests pass. |
|
Security review outcome: approved in principle. The previously identified blocking findings are addressed, including:
One non-blocking nit:
I couldn't submit a formal GitHub approval because the authenticated account is the PR author, and GitHub does not allow approving your own pull request. |
Remove Authorization header from test_html_page_token_url_sets_cookie so the test proves the /?token=... bootstrap path works on its own, without relying on a Bearer token as a fallback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Addresses all findings from
security_analysis.md:secrets.token_urlsafe(32)generated at startup, required on all API endpoints viaAuthorization: Bearerheader. Token is embedded in the HTML page served to the browser.contents: read, badge generation isolated to a separate job with minimalcontents: writelsof/killfallback that could kill unrelated processes on the same portTest plan
🤖 Generated with Claude Code