π‘οΈ Sentinel: [HIGH] Fix Event Loop Block in SSRF Validation - #124
π‘οΈ Sentinel: [HIGH] Fix Event Loop Block in SSRF Validation#124d3mocide wants to merge 1 commit into
Conversation
Offloaded the synchronous `validate_safe_url` DNS resolution calls to a thread pool executor in `backend/routers/radio.py`. Previously, these blocking calls ran directly in the async event loop, creating a Denial of Service (DoS) risk where a slow or malicious DNS response could stall the entire FastAPI application. Co-authored-by: d3mocide <136547209+d3mocide@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: The
proxy_streamendpoint inbackend/routers/radio.pyperformed Server-Side Request Forgery (SSRF) validation usingvalidate_safe_url. This function relies onsocket.getaddrinfo, which is a synchronous, blocking network call. Calling it directly within theasync deffunction blocked the entire FastAPI asyncio event loop during DNS resolution.π― Impact: An attacker could provide a stream URL that points to a malicious, non-responsive, or extremely slow DNS server. This would tie up the event loop during resolution, preventing the server from handling any other concurrent requests and causing a Denial of Service (DoS).
π§ Fix: Wrapped the
validate_safe_urlcalls inawait asyncio.get_running_loop().run_in_executor(None, validate_safe_url, ...)to offload the blocking DNS resolution to a separate thread, keeping the main event loop responsive.β Verification: Ran
python3 -m unittest discover backend/tests/and confirmed all 146 tests still pass, including the SSRF validation tests. Checked python syntax and docker configurations.PR created automatically by Jules for task 6798578802006811675 started by @d3mocide