🔒 Fix DoS Risk in Rate Limiter via Unbounded Memory - #124
Conversation
Migrate `RateLimitFilter` from an unbounded `ConcurrentHashMap` to a size-bounded, time-evicting `Caffeine` cache to prevent memory exhaustion DoS attacks.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🎯 What: Replaced the unbounded
⚠️ Risk: The previous map grew infinitely as new IP addresses and buckets were encountered. An attacker could exploit this by making requests from many spoofed IPs (or just sending varied bucket names, if accessible), leading to rapid memory exhaustion (OOM) and causing a Denial of Service (DoS) for the entire application.
ConcurrentHashMapinRateLimitFilterwith a CaffeineCache.🛡️ Solution: Integrated Caffeine to automatically evict sliding window entries. The cache is configured with a strict upper bound (
maximumSize(100_000)) and an automatic expiration policy (expireAfterAccess(1, TimeUnit.MINUTES)) that perfectly aligns with the rate limit sliding window size. This guarantees that old IPs are cleaned up and memory footprint remains bounded.PR created automatically by Jules for task 4962733754421285856 started by @Sanan507