Skip to content

Security audit hardening - #1

Merged
CZ140 merged 2 commits into
mainfrom
security/audit-hardening
Jun 12, 2026
Merged

CZ140 merged 2 commits into
mainfrom
security/audit-hardening

Conversation

@CZ140

@CZ140 CZ140 commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Addresses findings from a full security review of the app. All changes verified: 96 tests pass, ruff clean.

Fixes

  • H-1 — Safe-by-default binding. Default server.host is now 127.0.0.1 (was 0.0.0.0); a startup warning fires when bound off-box with no auth_token, so a fresh install can't silently expose private conversations to the LAN.
  • H-2 / M-3 — SSRF. New app/netguard.py rejects outbound URLs resolving to loopback/private/link-local/reserved IPs, revalidating every redirect hop; applied to the photo-download path. Not applied to the LLM endpoint (localhost Ollama is legitimate) — the settings-API SSRF lever is closed by the auth default instead.
  • M-1 / M-2 — Upload & zip-bomb caps. Reject oversized uploads early via UploadFile.size, and cap decompressed output during backup restore and character import.
  • L-1 — Auth cookie. SameSite=Strict and Secure (under HTTPS) on the cai_token cookie.
  • I-2 — Security headers. Middleware adds CSP (matched to the no-build frontend), X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy.
  • M-4 — Prompt-injection. Fence untrusted web-search/recall results so small models don't obey instructions or markers embedded in fetched content.

Tests

Adds coverage for the SSRF guard and the decompression-bomb rejection.

Other

Includes removal of the luna sample character (separate commit).

🤖 Generated with Claude Code

CZ140 and others added 2 commits June 12, 2026 00:15
Infrastructure and injection hardening from a full security review:

- H-1: default server.host to 127.0.0.1 (was 0.0.0.0) and warn at startup
  when bound off-box with no auth_token, so a fresh install can't silently
  expose private conversations to the LAN.
- M-3: SSRF guard (app/netguard.py) on the photo-download path — reject URLs
  resolving to loopback/private/link-local/reserved IPs, revalidating every
  redirect hop. Deliberately not applied to the LLM endpoint (localhost Ollama
  is legitimate); the settings-API SSRF lever is closed by the auth default.
- M-1/M-2: cap upload sizes (reject early via UploadFile.size) and decompressed
  output during backup restore and character import, defeating zip bombs.
- L-1: set SameSite=Strict and Secure (under HTTPS) on the auth-token cookie.
- I-2: security-headers middleware (CSP matched to the no-build frontend,
  X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy).
- M-4: fence untrusted web-search and recall results in the prompt so small
  models don't obey instructions/markers embedded in fetched content.

Adds tests for the SSRF guard and the decompression-bomb rejection.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@CZ140
CZ140 merged commit bb91202 into main Jun 12, 2026
4 checks passed
@CZ140
CZ140 deleted the security/audit-hardening branch June 12, 2026 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant