π‘οΈ Sentinel: [HIGH] Fix Boolean Type Confusion (CWE-843) - #132
π‘οΈ Sentinel: [HIGH] Fix Boolean Type Confusion (CWE-843)#132ManupaKDU wants to merge 1 commit into
Conversation
In Python, the `bool` class inherits from `int`. If boolean values like `True` or `False` are passed to `ipaddress.ip_address()`, it processes them using `isinstance(val, int)`, resulting in `True` evaluating to `0.0.0.1` and `False` to `0.0.0.0`. This commit adds explicit type checks (`type(val) is bool`) to the main execution block of `testping1.py` to intercept and safely reject booleans before they can bypass range validation and be parsed as IPs. A test case (`test_main_block_type_confusion_bool`) has been added to prevent regressions. 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: HIGH
π‘ Vulnerability: Type Confusion (CWE-843) leading to bounds check bypass. Python's
boolclass inherits fromint. While explicittype(val) is intchecks safely block booleans, functions likeipaddress.ip_address()rely onisinstance(val, int). This discrepancy means that a boolean value ofTruesuccessfully evades integer boundary checks, yet is still consumed byipaddressas the integer1(which resolves to IP0.0.0.1).π― Impact: This allowed arbitrary booleans to be passed into the main network scanner execution flow, circumventing strict range constraints and resource exhaustion safeguards.
π§ Fix: Explicitly checked for
type(ip) is boolprior to any bounds evaluations in the__main__block, matching the existing security logic in the module's utility functions. Added a corresponding unit test to verify input rejection.β Verification: Ran
python -m unittest test_testping1.pysuccessfully.PR created automatically by Jules for task 8135435342945081871 started by @ManupaKDU