Repository navigation
🔒 [security fix] Fix Unbounded In-Memory Job Storage Leading to Resource Exhaustion - #52
Conversation
…o prevent resource exhaustion * Created bounded InMemoryJobStore implementing Least Recently Used (LRU) eviction. * Added Time-To-Live (TTL) eviction policy for old jobs. * Implemented threading.Lock for full thread safety of job store operations. * Exposed maximum size and TTL via environment variables with secure defaults. * Added unit/integration tests to verify eviction policies, TTL, and thread safety. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 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. |
🎯 What: Unbounded In-Memory Job Storage Leading to Resource Exhaustion
jobs) could grow unbounded as background OCR jobs are created. An attacker could exploit this by spawning a large number of asynchronous jobs, causing high memory usage and eventually triggering an Out of Memory (OOM) crash, leading to a Denial of Service (DoS).🛡️ Solution: Updated the
InMemoryJobStoreclass to be bounded and thread-safe:max_size(default: 1000) andttl_seconds(default: 3600.0s) parameters, configurable via env variables (JOB_STORE_MAX_SIZE,JOB_STORE_TTL_SECONDS).threading.Lockto ensure job store queries and updates are atomic and thread-safe.tests/test_job_store_limits.pyverifying all eviction and synchronization behaviors.PR created automatically by Jules for task 17267331644983903605 started by @chottokun