Skip to content

Add outbound blocking - #264

Merged
bitterpanda63 merged 32 commits into
mainfrom
add-outbound-blocking
Mar 10, 2026
Merged

Add outbound blocking#264
bitterpanda63 merged 32 commits into
mainfrom
add-outbound-blocking

Conversation

@bitterpanda63

@bitterpanda63 bitterpanda63 commented Dec 2, 2025

Copy link
Copy Markdown
Collaborator

Summary by Aikido

Security Issues: 0 🔍 Quality Issues: 2 Resolved Issues: 0

🚀 New Features

  • Implemented outbound domain blocking feature and integrated it into config.

⚡ Enhancements

  • Added thread-local pending hostnames bridge between URL and DNS collectors.

🔧 Refactors

  • Removed Context hostnames, moved clearing and CI hosts addition.

More info

Comment thread agent_api/src/main/java/dev/aikido/agent_api/collectors/URLCollector.java Outdated
Comment thread agent_api/src/main/java/dev/aikido/agent_api/collectors/URLCollector.java Outdated
Comment thread agent_api/src/main/java/dev/aikido/agent_api/storage/ServiceConfiguration.java Outdated
Comment thread agent_api/src/main/java/dev/aikido/agent_api/storage/ServiceConfiguration.java Outdated
Comment thread agent_api/src/main/java/dev/aikido/agent_api/storage/ServiceConfiguration.java Outdated
Comment thread agent_api/src/main/java/dev/aikido/agent_api/storage/ServiceConfiguration.java Outdated
@bitterpanda63
bitterpanda63 marked this pull request as ready for review March 5, 2026 13:16
StatisticsStore.registerCall("java.net.InetAddress.getAllByName", OperationKind.OUTGOING_HTTP_OP);

// Block if the hostname is in the blocked domains list
if (ServiceConfigStore.shouldBlockOutgoingRequest(hostname)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DNSRecordCollector.report now performs enforcement (may throw BlockedOutboundException) in addition to reporting. Rename or document the method to reflect enforcement, or move blocking logic to a separate method.

Details

✨ AI Reasoning
​The DNSRecordCollector.report method was changed to both report DNS records and enforce blocking by throwing BlockedOutboundException when a hostname is blocked. The method name 'report' no longer fully conveys that it can perform enforcement side-effects. Mixing collection/reporting with blocking logic makes the purpose less self-evident and can surprise callers expecting a pure reporter method. This harms readability and makes error handling assumptions unclear to callers.

🔧 How do I fix it?
Use descriptive verb-noun function names, add docstrings explaining the function's purpose, or provide meaningful return type hints.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

@codecov

codecov Bot commented Mar 5, 2026

Copy link
Copy Markdown

Comment thread agent_api/src/main/java/dev/aikido/agent_api/context/Context.java Outdated
The clear in the Context.set was clearing this bridge and breaking redirect protectiosn
ServiceConfiguration config = getConfig();
Context.reset(); // clear context

// clear context

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

report() now calls PendingHostnamesStore.clear(), introducing an unexpected side-effect and mixing responsibilities. Move this clearing to a clearly named method or document/rename report() to reflect the additional behavior.

Details

✨ AI Reasoning
​The WebRequestCollector.report method previously handled initial request context setup and basic blocking checks. The change adds a call to clear a global/thread-local PendingHostnamesStore, which introduces a side-effect unrelated to the method's documented purpose. This mixes responsibilities and makes the function's purpose less self-evident: a caller expecting only context/reporting behavior may be surprised that pending hostnames are flushed here. The doc comment for report was not updated to reflect this new behavior, so the purpose is now unclear without reading implementation.

🔧 How do I fix it?
Use descriptive verb-noun function names, add docstrings explaining the function's purpose, or provide meaningful return type hints.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

@bitterpanda63
bitterpanda63 merged commit c4f4553 into main Mar 10, 2026
208 of 209 checks passed
@bitterpanda63
bitterpanda63 deleted the add-outbound-blocking branch March 10, 2026 10:09
Mishenevd pushed a commit that referenced this pull request Jul 10, 2026
…l site

Private IP literal hostnames with no pending port (resolver bootstrap
noise, network capability probing, etc.) flood the outbound-connections
dashboard - skip recording those specifically. Outbound domain blocking
and SSRF detection stay fully unconditional either way.

Known-port HTTP client calls now record their dashboard hit directly at
the call site (URLCollector), matching every other Zen agent (Go, Node,
Ruby, .NET, PHP) and restoring the original architecture from #264.
DNS-resolution-time recording is now only a fallback for hostnames that
never reached an instrumented HTTP client (JDBC, raw sockets, etc.) -
which is also the only place the private-IP noise gate applies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants