Skip to content

πŸ›‘οΈ Sentinel: [HIGH] Fix Event Loop Blocking (DoS) - #102

Open
benpiper wants to merge 1 commit into
mainfrom
sentinel/fix-event-loop-dos-7757078334069749647
Open

πŸ›‘οΈ Sentinel: [HIGH] Fix Event Loop Blocking (DoS)#102
benpiper wants to merge 1 commit into
mainfrom
sentinel/fix-event-loop-dos-7757078334069749647

Conversation

@benpiper

Copy link
Copy Markdown
Owner

🚨 Severity: HIGH

πŸ’‘ Vulnerability:
Synchronous blocking calls (time.sleep and CPU-bound bcrypt operations) inside async def routes 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_image polling 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:

  1. Offloaded the CPU-bound bcrypt operations in backend/auth.py to a background thread pool using starlette.concurrency.run_in_threadpool.
  2. Updated all caller routes in backend/main.py and backend/auth.py to await the new async hashing functions.
  3. Replaced the blocking time.sleep(1) in get_frame_image with await asyncio.sleep(1) to yield control back to the event loop.
  4. Added an entry to .jules/sentinel.md detailing the learning.

βœ… Verification:

  1. Ran cd backend && uv run pytest to ensure all existing backend tests pass.
  2. Ran cd backend && uv run ruff check . to verify no linting regressions.

PR created automatically by Jules for task 7757078334069749647 started by @benpiper

… 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>
@google-labs-jules

Copy link
Copy Markdown
Contributor

πŸ‘‹ 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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.

1 participant