π‘οΈ Sentinel: [CRITICAL] Fix Resource Exhaustion via subprocess.call Timeout Leak#102
Conversation
β¦imeout Leak When passing a `timeout` parameter to `subprocess.call()`, Python raises a `TimeoutExpired` exception but leaves the underlying child process running indefinitely, tying up system resources (PIDs, memory, file descriptors) which can lead to Denial of Service (DoS) as more timeout events occur. This patch updates `is_reachable` to use `subprocess.run()` instead of `subprocess.call()`, as `subprocess.run()` inherently kills the child process upon timeout, preventing resource leaks. Unit tests have been updated to mock `subprocess.run` instead of `subprocess.call`. Co-authored-by: ManupaKDU <95234271+ManupaKDU@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
CRITICAL
π‘ Vulnerability
The
is_reachablefunction executed thepingutility usingsubprocess.callwith atimeoutparameter. However,subprocess.calldoes not kill the child process when the timeout expires; it only raises aTimeoutExpiredexception. This leaves thepingprocess running indefinitely in the background, which can lead to resource exhaustion (DoS) as more timeout events occur.π― Impact
Denial of Service (DoS) due to resource exhaustion. If many scan requests are made with unresponsive IP addresses, the background
pingprocesses will pile up, consuming process IDs (PIDs), memory, and file descriptors until the host OS limits are hit and the service crashes.π§ Fix
Updated
is_reachableintestping1.pyto usesubprocess.run()instead ofsubprocess.call(), assubprocess.run()inherently kills the child process upon timeout, preventing resource leaks. Also updated the unit tests intest_testping1.pyto mocksubprocess.run.β Verification
python3 -m unittest test_testping1.pyand verify all tests pass.ps aux | grep pingto verify there are no lingering ping processes after the script finishes.PR created automatically by Jules for task 12954097720962151169 started by @ManupaKDU