On a developer laptop, a coding agent and the engineer who started it share one user, one device and one IP address. A secure web gateway that decides by user and URL sees one client. To allowlist what the agent reaches without locking out the engineer, the egress policy has to know which process opened each connection.

What is a secure web gateway (SWG)?

A secure web gateway (SWG) is a proxy between your users and the internet that applies security policy to outbound traffic: which sites and services can be reached, what can be sent, and what gets logged. Secure web gateway services ship as cloud services, on-premises appliances or endpoint agents, and are often sold inside a SASE or SSE platform.

Most secure web gateway solutions combine TLS inspection, URL and category filtering, malware scanning and data loss prevention for web traffic, built around a person browsing the web. That model still works for employees. What agent traffic needs on top of it is a forward proxy on the machine itself that knows which process is talking, which is the job of Formal Endpoint.

Why does agent traffic need more than an SWG allowlist?

An agent doesn’t browse. It runs shell commands, calls model APIs, talks to MCP servers, pulls packages and pushes code, often from processes it spawned a few seconds earlier. Every one of those connections leaves with the engineer’s identity, so a policy keyed on user, device and destination can’t treat the agent differently from the person. Allowlists alone don’t close the gap either. An allowed domain still accepts uploads, so the control has to look inside the request: the method, the path, the MCP tool call, the git command. And agents increasingly run in places an SWG client was never installed: cloud agent VMs, Kubernetes jobs and ECS tasks.

How do TLS inspection and egress filtering work in Formal?

Formal Endpoint intercepts outbound traffic in Transparent Mode, without changes to client applications. Network rules written in CEL choose which TCP connections to intercept, in up to three stages:

  • pre_tcp (macOS only) sees the connecting process, its ancestors and the destination port.
  • pre_tls sees the destination hostname and port, the process tree, its command line and the user. If any pre_tls condition matches a TLS flow, Formal terminates TLS with a certificate from the Formal local CA.
  • post_tls sees the protocol once TLS is off, one of http, mcp, llm, aws, gcp, postgres, mysql, mariadb, mongodb or ssh.

Intercepted traffic is evaluated against your Rego policies, which can allow, block or rewrite a request (headers, path or body for HTTP, LLM and MCP traffic). A block with block_with_formal_message returns the policy ID plus the session and request IDs, so the person or agent who hit it can hand those to the security team.

You choose what Formal intercepts. A connection that no rule selects passes through untouched and stays out of Logs, so an allowlist starts by selecting everything a given agent sends, then blocking what the policy doesn’t allow, as the Codex Desktop example above does. For the general model (default deny vs default permit, layer 3/4 vs layer 7 rules), see what is egress filtering.

The Endpoint points Node.js and Python at the Formal CA for you (Runtime TLS trust); what SSL/TLS inspection is covers the rest.

Where Formal Endpoint runs

How traffic reaches the Endpoint depends on the platform:

PlatformHow traffic is interceptedWhat to know
macOSTransparent Mode through a network extensionAgent and browser identity from code signatures; pre_tcp stage available
Linux (Debian, Ubuntu; amd64, arm64)Transparent Mode, enabled in ~/.formal/config.tomlAgents matched by process name; explicit proxy mode where NET_ADMIN isn’t allowed
KubernetesNative sidecar in each PodKubernetes 1.29+, NET_ADMIN, Privileged Pod Security Standard
Amazon ECSSidecar container in each taskEC2 and Managed Instances intercept all TCP; Fargate proxies HTTP and HTTPS

Egress from agent sandboxes and Kubernetes pods

On Kubernetes, the Endpoint runs as a native sidecar next to the application container, not on the host, and acts as the egress proxy for that Pod. It authenticates as a Formal machine user, and the Helm chart injects it into Pods labeled formal.ai/kubernetes-egress-inject: "true" along with the Formal CA. With a shared process namespace, logs add the PID, name and command line of each connection. See the Kubernetes egress guide.

On Amazon ECS, a Terraform module adds the sidecar and signs it in with the task role over OIDC, so there’s no API key to rotate. Application containers start only after the Endpoint has loaded your policies, so their first request is already inspected. Cloud agents follow the same pattern, as described in giving cloud agents production access with OIDC.

How does Formal fit next to your existing SWG?

Keep your secure web gateway for employee browsing. Scope Formal’s network rules to agents and the processes they spawn, and the two don’t collide: in the Codex Desktop example, a developer’s own browser never matches the rule. Policies, identities and audit logs live on the shared Formal platform, alongside the Connector that protects databases and internal services.

Because the Endpoint classifies the protocols agents use most, the same deployment also covers:

  • Model traffic: prompts and responses to LLM providers, covered on the AI gateway page.
  • Tool calls: MCP requests to approved and unknown servers, covered on the MCP gateway page.
  • Unapproved tools: discovering AI tools, MCP servers and skills nobody approved, covered on the shadow AI page.
  • Coding agents: rules per agent, keys held at the proxy and cloud agents tied to their owner, covered on the AI coding agent security page.
  • Package registries: npm, PyPI and other registry traffic can be routed through a Socket Registry Firewall, which scans packages while Formal applies access policy.