π‘οΈ Sentinel: [HIGH] Fix Event Loop Blocking (DoS) - #102
Conversation
β¦ and asyncio.sleep - Rewrote `verify_password` and `get_password_hash` to be async and offload bcrypt to `run_in_threadpool`. - Updated authentication endpoints to `await` the new async password functions. - Replaced blocking `time.sleep(1)` with `await asyncio.sleep(1)` in the `get_frame_image` endpoint. - Appended a new learning entry to `.jules/sentinel.md` detailing the vulnerability. Co-authored-by: benpiper <4343814+benpiper@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. |
π¨ Severity: HIGH
π‘ Vulnerability:
Synchronous blocking calls (
time.sleepand CPU-boundbcryptoperations) insideasync defroutes block the FastAPI event loop, leading to Denial of Service for all other concurrent requests.π― Impact:
If an attacker repeatedly triggers password hashing (e.g., by spamming login or registration endpoints) or hits the
get_frame_imagepolling loop while it sleeps, it blocks the main event loop, severely degrading the performance and availability of the entire API for all other users.π§ Fix:
bcryptoperations inbackend/auth.pyto a background thread pool usingstarlette.concurrency.run_in_threadpool.backend/main.pyandbackend/auth.pytoawaitthe new async hashing functions.time.sleep(1)inget_frame_imagewithawait asyncio.sleep(1)to yield control back to the event loop..jules/sentinel.mddetailing the learning.β Verification:
cd backend && uv run pytestto ensure all existing backend tests pass.cd backend && uv run ruff check .to verify no linting regressions.PR created automatically by Jules for task 7757078334069749647 started by @benpiper