Secure Web Gateway (SWG) for AI Agents

Formal Endpoint adds what agent egress needs to your secure web gateway: per-process network rules, TLS inspection and Rego policies that tell an agent's requests from its engineer's, on macOS and Linux machines, Kubernetes pods and ECS tasks.

egress · codex-desktopexample
# rule codex-desktop-egress: process tree contains com.openai.codex
ALLOW  llm    prompt from Codex Desktop
ALLOW  mcp    web-search-mcp (named MCP resource)
BLOCK  http   chatgpt.com/backend-api/codex/alpha/search
BLOCK  http   browser spawned by Codex, unapproved host
# your own browser has no Codex ancestor: not intercepted

The problem

Why do AI agents need their own egress policy?

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 (SWG) that decides by user and URL sees one client. To allowlist what the agent reaches without locking out the engineer, egress control has to know which process opened each connection and what the request says. Formal Endpoint does that on the device, like an agent-based SWG, with rules written for AI agents and the processes they start.

  1. Agents run with the engineer's network access

    Coding agents run shell commands, call model APIs, talk to MCP servers and push code, often through processes they started a few seconds earlier, and every one of those connections carries the engineer's identity.

  2. Policies keyed on user and URL see one client

    A policy keyed on user and destination can't tell the agent's request from the engineer's: same user, same device, same IP.

  3. Sandboxes and Kubernetes jobs with no SWG client

    Agents also run in places an SWG client was never installed: cloud agent VMs, Kubernetes jobs and ECS tasks.

today · no policy on the pathexample
01
maya@acme.com · codexPOST github.com/acme/payments.git/git-receive-packALLOWED
02
maya@acme.comGET chatgpt.com/backend-api/codex/alpha/searchALLOWED
03
grok-bot · linux vmGET mail.google.com/ALLOWED

# Keyed on user and URL, all three go through.

Definition

What is a secure web gateway (SWG)?

secure web gateway (SWG)noun

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.
  • Cloud, appliance or endpoint agent

    Secure web gateway services ship as cloud services, on-premises appliances or endpoint agents, and are often sold inside a SASE or SSE platform.

  • Built around a person browsing

    Most secure web gateway solutions combine TLS inspection, URL filtering by category, malware scanning, threat intelligence feeds and data loss prevention for web traffic. That model still works for employees.

  • What agent traffic needs on top

    A forward proxy on the machine itself that knows which process is talking, which is the job of Formal Endpoint.

How it works

How Formal's agent egress control works

  1. Step 1 of 4

    Install the Endpoint

    Turn on Transparent Mode on macOS or Linux, or add the Endpoint as a sidecar to Kubernetes Pods and ECS tasks. Existing clients don't change.

    WHERE IT RUNSexample
    • macOS or Linux, Transparent Mode on✓
    • Kubernetes Pod, native sidecar✓
    • ECS task, sidecar container✓
  2. Step 2 of 4

    Select flows with network rules

    A CEL rule decides which TCP connections Formal intercepts. Flows that match no rule pass through untouched and aren't logged.

    NETWORK RULESexample
    • Codex Desktop and every process it launchesINTERCEPTED
    • git from known agents and their childrenINTERCEPTED
    • your own browser, no agent ancestorPASSES THROUGH
  3. Step 3 of 4

    Terminate TLS and classify

    Formal terminates TLS for the selected flows and classifies the wire protocol: HTTP, MCP, LLM, SSH, cloud APIs or databases.

    CLASSIFIED PROTOCOLSexample
    • http, mcp and llm✓
    • aws and gcp✓
    • postgres, mysql, mariadb, mongodb and ssh✓
  4. Step 4 of 4

    Enforce policy and log

    Rego policies allow, block or rewrite each request. A Formal block message carries the policy ID, and every intercepted request is logged.

    POLICY · CODEX-DESKTOP-EGRESSexample
    • llm · prompt from Codex DesktopALLOWED
    • mcp · web-search-mcpALLOWED
    • http · chatgpt.com/backend-api/codex/alpha/searchBLOCKED

Agents

What an SWG allowlist misses with agents

An agent doesn’t browse. It runs shell commands, calls model APIs, talks to MCP servers, pulls packages and pushes code. A destination allowlist helps, but every 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. AI DLP policies cover the secrets in prompts.

GitHub takes any push

GitHub takes a push to any repository the engineer can write to.

codex for mayagit push acme/infrastructure.gitALLOWED

A model API takes any prompt

A model API takes a prompt with an API key pasted in.

claude-code for mayaPOST /v1/messages, API key in the promptALLOWED

Every allowed domain is a channel

“Going from 0.0.0.0/0 to an allowlist felt like progress, until we realized every allowed domain is still an exfiltration channel.”
Kevin Qiu, Lead Security Engineer, Latent Health
production agentupload to an allowed domainALLOWED

# A destination allowlist lets all three through.

TLS inspection

How do TLS inspection and egress filtering work in Formal?

Formal Endpoint does the break and inspect (TLS interception) on the machine that opens the connection, and only for the flows you select. Transparent Mode intercepts outbound traffic without changes to client applications, and network rules written in CEL choose which TCP connections to intercept, in up to three stages.

  • pre_tcp

    Sees the connecting process, its ancestors and the destination port.

    macOS only
  • pre_tls

    Sees the destination hostname and port, the process tree, its command line and the user, plus the code signature on macOS. If any pre_tls condition matches a TLS flow, Formal terminates TLS with a certificate from the Formal local CA.

    TLS terminated
  • post_tls

    Sees the protocol once TLS is off, one of http, mcp, llm, aws, gcp, postgres, mysql, mariadb, mongodb or ssh.

    Protocol known
  • Rego policies

    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.

    Allow, block, rewrite
  • No rule matched

    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 below does.

    Passes through

formal ca trust adds the Formal CA to the OS trust store, which browsers and Go programs read. Node.js and most Python HTTP clients ship their own roots and ignore it. On macOS, runtime_ca_env = "all" sets NODE_EXTRA_CA_CERTS, SSL_CERT_FILE and the other runtime variables in your login session, and Claude Code gets the first three in its settings unless you turn that off (Runtime TLS trust). The general model (default deny vs default permit, layer 3/4 vs layer 7 rules) is in our guide to egress filtering, and our TLS inspection guide explains which other clients break and how to scope interception.

Capabilities

Egress control by process and request

Network rules select flows by hostname, port, user and groups, process name, command line and parent processes, plus code signature on macOS. Formal recognizes 22 AI agents and coding tools by name, including Claude Code, Codex, Cursor and Devin, and every process they spawn, so a rule can target the agent and leave the engineer alone.

Agent egress allowlist

Let a coding agent reach its model and approved MCP servers, nothing else

A network rule intercepts Codex Desktop and every process it launches. A request-stage policy allows LLM traffic and named MCP resources, and blocks direct web search and browsers that Codex spawns. Your own browser has no Codex ancestor, so it stays off this path.

  • Child processes: matching the signed bundle ID on the process or an ancestor covers spawned browsers and helper binaries
  • Named resources as the allowlist: each approved MCP server is a Formal MCP resource; unnamed MCP traffic is blocked
  • Recipe: the Control Plane recipe creates the network rule and the policy for you (macOS)
Restrict Codex Desktop to LLM and MCP ›
egress · codex-desktopexample
llmCodex DesktoppromptALLOWED
mcpCodex Desktopweb-search-mcp (named MCP resource)ALLOWED
httpCodex Desktopchatgpt.com/backend-api/codex/alpha/searchBLOCKED
httpbrowser spawned by Codexunapproved hostBLOCKED
Human or agent

Block agent pushes to sensitive repositories, not engineer pushes

Git reaches GitHub over SSH, SSH on port 443 and HTTPS, so one network rule selects git traffic from known agents and their children on all three transports, and one policy blocks git-receive-pack for the repositories you list. Clones keep working.

  • Same machine, two answers: the same push from the engineer’s own terminal doesn’t match the rule and goes through
  • Or ask the human: swap the block for the mfa action and the engineer confirms the push on their device
  • Platform: uses code-signed process identity on macOS
Block agent git pushes ›
egress · github-agent-gitexample
sshagentgit-upload-pack 'acme/infrastructure.git'ALLOWED
sshagentgit-receive-pack 'acme/infrastructure.git'BLOCKED
httpagentPOST github.com/acme/payments.git/git-receive-packBLOCKED
sshmaya · own terminalgit push, rule not matchedALLOWED
Agent sandboxes

Put the same egress policy on Linux VMs, pods and ECS tasks

Agents increasingly run where no desktop client is installed: cloud agent VMs, Kubernetes jobs, ECS tasks. The headless Linux package, the Kubernetes native sidecar and the ECS sidecar run the same Endpoint, so one set of policies covers the laptop and the sandbox.

  • On a Linux VM in Transparent Mode, a rule stops Grok Bot opening Gmail
  • Chrome shows the Formal block page with the policy, session and request IDs
  • Cursor Cloud Agents and Devin sign in with short-lived OIDC tokens instead of stored keys
Formal Endpoint in cloud agents ›
egress · grok-bot linux vmexample
httpGrok BotGET mail.google.com/BLOCKED
httpGrok BotGET gmail.com/BLOCKED
Rollout

Try every rule in dry-run, next to your SWG

Scope network rules to agents and the processes they spawn, and they don’t collide with the SWG your employees browse through. Dry-run triggers appear in Logs with their policy status, so you see what a rule would block before it blocks anything.

  • Block message: block_with_formal_message returns the policy, session and request IDs to whoever hit it
  • SIEM: Endpoint logs carry the source desktop and forward through your log integrations to AWS S3, Datadog, Splunk or Panther
Logs docs ›
logs · desktopexample
agentCodex DesktopGET chatgpt.com/backend-api/codex/alpha/searchDRY RUN
policycodex-desktop-egresswould block; request sentDRY RUN

Platforms

Where Formal Endpoint runs

How traffic reaches the Endpoint depends on the platform.

  • macOS

    Transparent Mode through a network extension. Agent and browser identity from code signatures; the pre_tcp stage is available.

    Code signatures
  • Linux (Debian, Ubuntu; amd64, arm64)

    Transparent Mode, enabled in ~/.formal/config.toml. Agents matched by process name; explicit proxy mode where NET_ADMIN isn’t allowed.

    Process names
  • Kubernetes

    A native sidecar in each Pod. Needs Kubernetes 1.29+, NET_ADMIN and the Privileged Pod Security Standard.

    Native sidecar
  • Amazon ECS

    A sidecar container in each task. EC2 and Managed Instances intercept all TCP; Fargate proxies HTTP and HTTPS.

    Sidecar container
  • Cloud agents

    The headless Debian package runs in Cursor Cloud Agent and Devin environments and signs in with the platform’s short-lived OIDC token.

    OIDC
  • Windows (64-bit x86-64)

    Not intercepted: Transparent Mode and network rules aren’t available on Windows yet. It connects to Formal resources through local listeners with formal connect; there’s no Arm64 package (Windows docs).

    Not intercepted

Sandboxes and pods

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 with an API key you store in a Kubernetes Secret, and the Helm chart injects it, along with the Formal CA, into Pods with this label.

  • Native sidecar on Kubernetes 1.29+, injected by label with the Helm chart (Kubernetes 1.36+) or added to your Pod spec
  • With a shared process namespace, logs add the PID, name and command line of each connection
  • 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
Kubernetes egress guide ›
pod.yamlyaml
metadata:
  labels:
    formal.ai/kubernetes-egress-inject: "true"

Next to your SWG

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. SASE and secure web gateways compared and Formal vs Cloudflare show where each tool sits.

Your secure web gatewayFormal Endpoint
TrafficEmployee browsingAI agents and the processes they spawn
Selects byUser and URLProcess tree, command line, user and groups, and code signature on macOS
Runs onDevices with its client, or a tunnel to its cloudmacOS and Linux machines, Kubernetes pods, ECS tasks and cloud agent VMs
Decides onThe web requestRego policies on the classified protocol: HTTP, MCP, LLM, SSH, cloud APIs or databases
URL categories, malware scanning, remote browser isolation, threat intelligenceStay with your SWGNot something Formal does

Works with

Works with your agents, machines and SIEM

Existing clients don’t change: the Endpoint intercepts their connections and applies your rules where the traffic starts.

Formal Endpoint and Transparent Mode ›

Architecture

One egress policy on laptops, pods, tasks and cloud agents

Formal Endpoint architecture: an egress proxy on laptops, VMs and agent sandboxes that applies network rules and Rego policies before AI agent traffic reaches LLM providers, MCP servers and SaaS APIs.
Formal Endpoint sits in the agent's path and applies policy before a request leaves the machine.

Deployment

Agent egress control on the systems you already run

Formal Endpoint on laptops

Transparent Mode on macOS and Linux; roll it out to Macs with your MDM. Existing clients keep working without a base URL change (Endpoint docs).

Formal Endpoint in pods and tasks

A native sidecar in Kubernetes Pods, injected by label with the Helm chart, and a sidecar container in Amazon ECS tasks (Kubernetes egress).

Formal Endpoint in cloud agents

The headless Debian package runs in Cursor Cloud Agent and Devin environments and signs in with the platform’s short-lived OIDC token (cloud agents guide).

Your identity provider

People sign in with SSO, and SCIM keeps users and groups in sync. Policies use the groups you already manage.

Logs in your SIEM

Log integrations forward Formal logs to AWS S3, Google Cloud Storage, Azure Blob Storage, Datadog, Splunk or Panther.

Policy and configuration as code

Policies are written in Rego. Manage Formal with Terraform, Pulumi or the Kubernetes Operator.

Audited controls

Formal holds SOC 2 Type II and ISO/IEC 27001. The reports are on security.formal.ai.

Customer proof

Technologies secured
10+
Resources secured
1,000+
Logs per week
40M+
Sessions per week
600K+
“Without Formal, we couldn't have agents with access to sensitive data. With Formal, because we are able to inspect all traffic and enforce controls, we are able to provide a safe environment for the agents to get the job done.”
Travis McPeak
Travis McPeak
Head of Security, Cursor
Read the Cursor story ›

FAQ

Questions about secure web gateways and agents

Buying and fit

How does a secure web gateway work?

Traffic from a device reaches the gateway through a local agent, a proxy setting or a tunnel. The gateway terminates TLS with a certificate the device trusts, inspects the request, applies policy (allow, block, rewrite) and logs the decision. Formal Endpoint does the same on the machine or in the Pod, with a network rule choosing which flows it inspects.

Is an SWG a firewall?

Not in the classic sense. A network firewall filters by IP address, port and protocol. An SWG works at the application layer: it reads the HTTP request (host, path, method, body) and decides on that. Formal Endpoint sits closer to the SWG side: it selects TCP flows, then evaluates policy on the classified protocol, such as HTTP, MCP, LLM or SSH.

What is the difference between SWG and CASB?

A secure web gateway controls outbound web traffic as it leaves the user. A cloud access security broker (CASB) governs how people use SaaS applications and the data stored in them, often through the SaaS vendor’s APIs. Many vendors sell both inside one SASE or SSE platform. Formal sits on the SWG side and controls traffic in flight from machines and agents.

Does Formal replace our existing secure web gateway?

No, it runs next to it. Keep your SWG for employee browsing, URL categories and malware scanning, which Formal doesn’t do. Formal adds per-process egress control for agents and the processes they spawn, in pods and sandboxes as well as laptops, with policies managed on the Formal platform. If you run Zscaler today, Formal vs Zscaler maps what each one covers.

Is Formal Endpoint a cloud secure web gateway?

Formal Endpoint inspects traffic on the machine, VM or Pod that sends it and evaluates policy there, where a cloud secure web gateway inspects traffic in the provider’s points of presence. A network rule can also forward HTTP, MCP and LLM traffic to a Formal Connector that you run, which then evaluates it. You manage both from one Control Plane.

AI agents

Agent-based vs proxy SWG: which one is Formal?

In SWG buying, “agent-based” means software on the device, as opposed to a cloud proxy the device reaches through a tunnel or a PAC file. Formal Endpoint is agent-based in that sense, and it’s built for AI agents. Running on the device is what lets it see the process behind each connection: code signature on macOS, process name on Linux, plus the parent chain, so process.has_agent_ancestor matches an agent and everything it spawns. The known agent identities table lists each one.

Product

Does Formal work on Windows?

Formal Endpoint installs on 64-bit Windows on x86-64 (there’s no Arm64 package) and connects you to Formal resources through local listeners with formal connect. Transparent Mode and network rules aren’t available on Windows yet, so it doesn’t inspect a Windows machine’s egress. Use macOS or Linux machines, or the Kubernetes and ECS sidecars, for the egress rules on this page.

Give agents their own egress policy

Per-process egress rules, TLS inspection and request-level policy for agents, next to the SWG you already run.