Skip to content

fix(security): add rate limiting to /api/extract to prevent API key exhaustion#968

Open
Vedhant26 wants to merge 1 commit into
Charushi06:mainfrom
Vedhant26:fix/issue-927-rate-limiting
Open

fix(security): add rate limiting to /api/extract to prevent API key exhaustion#968
Vedhant26 wants to merge 1 commit into
Charushi06:mainfrom
Vedhant26:fix/issue-927-rate-limiting

Conversation

@Vedhant26
Copy link
Copy Markdown

🔒 Fix: Add Rate Limiting to AI Extraction Endpoint

Closes #927

Security Issue

The /api/extract endpoint (which connects to the Gemini AI API) was completely unauthenticated and had no rate limiting. This meant a malicious user could spam the endpoint, causing the server to exhaust the GEMINI_API_KEY quota or rack up billing charges, leading to a Denial of Service (DoS) for legitimate users.

Solution

  • Installed express-rate-limit.
  • Added an extractLimiter middleware explicitly applied to app.post('/api/extract', ...).
  • Limited requests to 20 per IP per 15 minutes to allow legitimate usage while strictly blocking automated spam attacks.

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.

bug: [Security] No rate limiting on /api/extract — Gemini API key can be exhausted by abuse

1 participant