fix: address critical security and performance findings from audit #001#3
Merged
Conversation
- CORS: restrict origins to env-configured list (default: localhost:3000/5173) - Upload: sanitize filename with Path.name to prevent path traversal - Upload: reject files larger than 50MB (HTTP 413) - SQLite: add index on messages(session_id) to avoid full table scans - LLM: add 60s timeout to litellm.acompletion to prevent hung requests - .env.example: document new COMPASS_ALLOWED_ORIGINS variable Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Upload tests: - path traversal: verify ../../etc/passwd.md is sanitized to passwd.md - file size: verify 413 on >50MB, 201 at exactly 50MB Database tests (new test_database.py, 7 tests): - schema: messages table and session_id index exist after init_db - save/get: isolation by session, chronological order, limit behavior Also fix: change ORDER BY timestamp DESC to ORDER BY id DESC in get_session_messages — timestamp has second precision and is non-deterministic when messages are inserted rapidly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Resolves all 5 critical findings from `audits/001_2026-04-06_audit_report.md`.
Also includes:
Tests added (38 total, up from 26)
`test_api.py` — 3 new upload tests:
`test_database.py` — 7 new tests (new file):
Test plan
🤖 Generated with Claude Code