Security & cost hardening: rate-limit + validate AI/OSM endpoints#3
Open
joaquinOEF wants to merge 1 commit into
Open
Security & cost hardening: rate-limit + validate AI/OSM endpoints#3joaquinOEF wants to merge 1 commit into
joaquinOEF wants to merge 1 commit into
Conversation
… OpenAI timeout The /api/chat/* and /api/osm/* endpoints called OpenAI / Overpass with no auth, no rate limit, no input validation, and no body-size cap — anyone could run up the OpenAI bill, use us as a free proxy, or OOM the server with a huge payload. - express-rate-limit (40/min/IP) on /api/chat and /api/osm - zod-validate /api/chat/query (string ≤500 chars + optional bbox tuple); cap index-assets (≤5000), index-geojson features (≤20000), overpass query length (≤10k) - express.json/urlencoded limit 1mb - OpenAI client timeout 15s + maxRetries 2 (a hung call can't block the server) - health check no longer leaks OPENAI_API_KEY presence - .gitignore .env* Co-Authored-By: Claude Opus 4.8 (1M context) <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.
The
/api/chat/*and/api/osm/*endpoints called OpenAI / Overpass with no rate limit, no input validation, no body-size cap, and no timeout — an attacker could run up the OpenAI bill, use the server as a free OpenAI/Overpass proxy, or OOM it with a huge payload./api/chat+/api/osm(express-rate-limit)/api/chat/query(string ≤500 chars + optional bbox tuple); capindex-assets≤5000,index-geojsonfeatures ≤20000, overpass query ≤10k charsexpress.json/urlencodedcapped at 1 MBOPENAI_API_KEYpresence.gitignorenow ignores.env*Low-risk + additive;
npm run buildpasses. First of four small audit PRs (A security → B perf → C cleanup → D UX).🤖 Generated with Claude Code