forked from Kicksecure/helper-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Handle missing bootstrap progress parsing #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
assisted-by-ai
wants to merge
1
commit into
master
Choose a base branch
from
codex/review-python-scripts-for-security-bugs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Security Review of Python Scripts | ||
|
|
||
| ## Summary | ||
| This review evaluates the Python scripts under `usr/libexec/helper-scripts` and related packages for security concerns. The primary issues center on unbounded network traffic generation and missing input validation that could lead to denial-of-service conditions or unintended network scanning. These behaviors are currently intentional test utilities rather than exploitable vulnerabilities, but they can still be dangerous when used without safeguards. | ||
|
|
||
| ## Findings | ||
|
|
||
| ### Unbounded network scanning in leak test scripts | ||
| * Files: `usr/libexec/helper-scripts/leak-tests/tcp_test.py`, `usr/libexec/helper-scripts/leak-tests/udp_test.py`, `usr/libexec/helper-scripts/leak-tests/exhaustive_ip_send.py` | ||
| * Severity: High (could trigger abuse reports, firewall blocks, or DoS on target networks) | ||
| * Details: These scripts send packets to `scanme.nmap.org` across **all** ports or protocol numbers without throttling or consent. Running them accidentally on a networked host could overwhelm the target or draw unwanted attention. The scripts also import `scapy` with `import *`, making code harder to audit and raising the risk of namespace collisions. While the traffic generation is part of the intended leak testing workflow, the lack of operator confirmation makes accidental misuse more likely. | ||
| * Recommendations: Add explicit rate limiting, target allow-list confirmation, and a mandatory interactive prompt that describes the traffic volume. Replace `import *` with explicit imports to reduce unexpected behaviors. Document the intended usage to clarify that high-volume traffic is expected only in controlled environments. | ||
|
|
||
| ### Lack of response handling in `simple_ping.py` | ||
| * File: `usr/libexec/helper-scripts/leak-tests/simple_ping.py` | ||
| * Severity: Medium (runtime crash risk) | ||
| * Details: The script checks `isinstance(test_ping, types.NoneType)` but never imports `types`, which will raise a `NameError`. That failure can mask actual network reachability results and could cause automated leak tests to misreport status. The crash stems from the current coding style rather than an underlying library bug. | ||
| * Recommendations: Import `types` or, preferably, compare against `None` directly (e.g., `if test_ping is None:`) and handle exceptions from `sr1` to avoid crashes. | ||
|
|
||
| ### Robustness of Tor bootstrap scripts | ||
| * Files: `usr/libexec/helper-scripts/tor_bootstrap_check.py`, `tor_consensus_valid-after.py`, `tor_consensus_valid-until.py` | ||
| * Severity: Low (graceful failure, potential unhandled exceptions) | ||
| * Details: Scripts assume `stem.connect()` succeeds and that controller queries always return valid values. If Tor is unreachable, they may exit with unclear codes or raise exceptions when parsing bootstrap progress (e.g., `re.match` without a None check). | ||
| * Recommendations: Validate connections, wrap controller queries in try/except, and provide clear exit codes and messages when Tor is unavailable. | ||
|
|
||
| ## Conclusion | ||
| The most critical issues are the aggressive traffic generation in the leak test scripts, which should be mitigated with explicit safeguards before any production or automated use. Minor robustness improvements are recommended for the remaining scripts to prevent misleading results during failure scenarios. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Test Run Report | ||
|
|
||
| Command: ./run-tests | ||
|
|
||
| Date: 2025-12-02 04:58:15Z | ||
|
|
||
| Result: Failed (10 failures, 12 passed) | ||
|
|
||
| Notes: | ||
| - Failing cases are primarily in stdisplay utilities (stcat, stcatn, stecho, stprint, stsponge, sttee). | ||
| - Failures include unexpected ANSI escape sequences that were not sanitized and missing terminfo entries (xterm-direct, xterm-old). | ||
| - Terminfo lookup gaps suggest an environment/configuration issue rather than a product bug; rerun after installing the required entries to confirm. | ||
| - See test log in the run output for full details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is likely unnecessary - there are two places in C-Tor's source code that generate the output of a
GETINFO status/bootstrap-phasecommand, one is https://gitlab.torproject.org/tpo/core/tor/-/blob/b5d08ddc09ec785d81e4043d9f9e2f032c9e49ab/src/feature/control/control_bootstrap.c#L165 and the other is https://gitlab.torproject.org/tpo/core/tor/-/blob/b5d08ddc09ec785d81e4043d9f9e2f032c9e49ab/src/feature/control/control_bootstrap.c#L324. Both of them include aPROGRESS=key. We could catch this, but it's probably not worth it.