fix(security): critical security fixes (Phase 1) - #67
Open
saadamjad wants to merge 1 commit into
Open
Conversation
Addresses the CRITICAL and highest-impact HIGH findings from the production-grade security audit: - Fix OTP plaintext logging in production when SMTP is unconfigured - Fix CORS wildcard + credentials (invalid combo, silently rejected by browsers); origins now read from CORS_ORIGINS - Fix user enumeration in POST /v1/auth/request-otp (was 409 vs 404) - Add restart: unless-stopped to every Docker Compose service - Bind Postgres/Qdrant/Redis ports to 127.0.0.1 instead of 0.0.0.0 - Fix deploy script to poll /health/deep instead of /health (always 200) - Add NEXT_PUBLIC_DEV_MODE=true production deploy guard - Add non-root USER to core/Dockerfile + core/.dockerignore - Fix client_ip() to only trust X-Forwarded-For from a trusted proxy, closing a rate-limit bypass via header spoofing - Refuse to start if DEV_API_KEY is set while ENV=production; remove the compose default that could silently re-enable the dev auth bypass - Add CHANGELOG.md and PR template Co-Authored-By: Claude Sonnet 5 <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.
What does this PR do?
Phase 1 of the security audit remediation plan — fixes the CRITICAL and highest-impact HIGH findings that would cause embarrassing failures on day-1 of public launch.
allow_origins=["*"]+allow_credentials=Trueis an invalid combination browsers silently reject. Origins now come fromCORS_ORIGINSenv varPOST /v1/auth/request-otpreturned 409 for existing emails and 404 for unknown ones. Both cases now return an identical 200 responserestart: unless-stoppedto every Docker Compose service127.0.0.1onlyinfra/deploy-production.shnow polls/health/deep(real dependency check) instead of/health(always 200)NEXT_PUBLIC_DEV_MODEfootgun: deploy script now refuses to deploy if this is stilltrue(bypasses dashboard OTP login)USER+core/.dockerignoreclient_ip()spoofing:X-Forwarded-Foris now only trusted from a configured trusted proxy address, closing a rate-limit bypassDEV_API_KEYis set whileENV=production; removed the compose default that could silently re-enable the bypassCHANGELOG.mdand.github/PULL_REQUEST_TEMPLATE.mdHow to test
Manual checks:
curl -s -o /dev/null -w "%{http_code}" -X POST http://localhost:8000/v1/auth/request-otp -H "Content-Type: application/json" -d '{"email":"nobody@example.com"}'→ 200ENV=production+DEV_API_KEY=zizkadb_dev_local→ app refuses to startChecklist
pytest core/tests/ -m "not integration" -v— 136 passed)ruff check core/ sdk/python/ mcp/ integrations/)npm run lint)allow_origins=["*"]+allow_credentials=TruecombinationsCHANGELOG.mdupdated under[Unreleased]🤖 Generated with Claude Code