-
Notifications
You must be signed in to change notification settings - Fork 11
Clarify outbound pr #562
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
Clarify outbound pr #562
Changes from all commits
b31dd83
af72a38
25d48ad
1252057
c60502e
7490e5a
7465701
d531546
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| from aikido_zen.thread.thread_cache import get_cache | ||
|
|
||
|
|
||
| def should_block_outbound_domain(hostname, port): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should_block_outbound_domain both records hostnames (side-effect) and returns a boolean. Rename or separate recording from the predicate, or add clear docstring describing the side-effect. Details✨ AI Reasoning 🔧 How do I fix it? More info - Comment |
||
| process_cache = get_cache() | ||
| if not process_cache: | ||
| return False | ||
|
|
||
| # We store the hostname before checking the blocking status | ||
| # This is because if we are in lockdown mode and blocking all new hostnames, it should still | ||
| # show up in the dashboard. This allows the user to allow traffic to newly detected hostnames. | ||
| process_cache.hostnames.add(hostname, port) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. process_cache.hostnames.add(...) mutates shared cache without synchronization; protect hostnames updates with a lock or use a thread-safe collection. Details✨ AI Reasoning 🔧 How do I fix it? More info - Comment |
||
|
|
||
| return process_cache.config.should_block_outgoing_request(hostname) | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
Calling should_block_outbound_domain(...) from socket.getaddrinfo path causes unsynchronized mutation of shared cache; invoke only with proper synchronization or use a thread-safe API.
Details
✨ AI Reasoning
The socket getaddrinfo after-wrapper (_getaddrinfo_after) was modified to call should_block_outbound_domain(hostname, port). That call can mutate process_cache.hostnames (see added function). Because socket.getaddrinfo is commonly invoked from multiple threads, invoking a function that mutates shared state without synchronization increases the risk of concurrent modifications and related race conditions. The change moved from the previous report_and_check_hostname behavior to storing hostname and performing a blocking check that now performs mutation; this worsens thread-safety at the call site.
🔧 How do I fix it?
Use locks, concurrent collections, or atomic operations when accessing shared mutable state. Avoid modifying collections during iteration. Use proper synchronization primitives like mutex, lock, or thread-safe data structures.
More info - Comment
@AikidoSec feedback: [FEEDBACK]to get better review comments in the future.