Skip to content

Fix/issue 2358 bounded lru captcha#2365

Open
Prateek2007-cmd wants to merge 4 commits into
janavipandole:mainfrom
Prateek2007-cmd:fix/issue-2358-bounded-lru-captcha
Open

Fix/issue 2358 bounded lru captcha#2365
Prateek2007-cmd wants to merge 4 commits into
janavipandole:mainfrom
Prateek2007-cmd:fix/issue-2358-bounded-lru-captcha

Conversation

@Prateek2007-cmd

Copy link
Copy Markdown
Contributor

Description

Resolves Issue #2358 (Unbounded Memory Leak in Captcha Tracking).

The /api/auth/login endpoint utilized an unbounded global Python dictionary (failed_login_attempts) to track failed authentication requests. Because entries were only purged upon a successful login, a distributed botnet firing random email payloads could cause the dictionary footprint to expand infinitely, eventually starving the host environment of memory and crashing the service (DOS).

This PR mitigates the architectural vulnerability by implementing a robust, self-cleaning caching layer.

Changes Made

  • LRU Cache Implementation: Upgraded the standard dictionary to an OrderedDict to take advantage of O(1) .move_to_end() and .popitem(last=False) operations.
  • Memory Bounds Enforcement: Established a strict upper limit of 1000 concurrent tracked emails. If the threshold is breached, the oldest tracked IP/email combination is dynamically purged, capping memory consumption effectively without degrading valid user UX.

Type of Change

  • Security Fix
  • Performance Optimization

@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

@Prateek2007-cmd is attempting to deploy a commit to the janavipandole's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant