π‘οΈ Sentinel: [CRITICAL/HIGH] Fix Log and Argument Injection via IPv6 scope_id#47
Conversation
β¦scope_id Validates the `scope_id` of IPv6 addresses using regex `re.fullmatch(r'[\w\-]+', ...)` to prevent arbitrary command injection or log spoofing. Also includes rigorous unit testing and a journal entry. 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/HIGH
π‘ Vulnerability: Log and Argument Injection via unhandled IPv6
scope_idThe Python
ipaddressmodule's parsing mechanism allows arbitrary strings (including shell metacharacters like;,&,\n) to be embedded within thescope_idof IPv6 addresses. Since this field wasn't validated, passing these IPv6 objects tosubprocess.callor logging them directly exposed the system to severe injection attacks.π― Impact:
fe80::1%eth0; rm -rf /) could inject arbitrary arguments into thepingcommand executed bysubprocess.call.\n) in thescope_idpermitted spoofing of system logs, potentially masking malicious activity or creating false alerts.π§ Fix:
Implemented a strict validation check directly after the
ipaddress.ip_addressinstantiation:getattr(ip_obj, 'scope_id', None)to safely determine if the object is an IPv6 address with a specified scope.re.fullmatch(r'[\w\-]+', ip_obj.scope_id)to restrict interface names to alphanumeric characters and hyphens, strictly blocking all metacharacters and control characters.scope_idtriggers a safe, sanitized log error usingrepr()and rejects the ping request.β Verification:
Added comprehensive unit tests simulating malicious
scope_idpayloads with both argument injection syntax (eth0; ls) and log injection syntax (\nERROR...). Verified thatis_reachablecorrectly detects and rejects these payloads without invokingsubprocess.callor evaluating the log injection vectors. Run the tests usingpython3 -m unittest test_testping1.py.PR created automatically by Jules for task 14720639480865181532 started by @ManupaKDU