Skip to main content
The credential swap proxy allows the coding agent to run code with real API credentials without ever seeing the actual values. The agent works with “shadow” credentials while the proxy transparently swaps them for real ones.

Architecture

The proxy intercepts all HTTP/HTTPS traffic from the sandbox and performs credential substitution:
Source: ftl/proxy.py:1-22
1

Agent sees shadow credentials

Environment variables contain placeholder values like ftl_shadow_sk_test_...
2

Code makes API request

User code runs and makes HTTP/HTTPS requests with shadow credentials
3

Proxy intercepts traffic

All requests route through the proxy via HTTP_PROXY/HTTPS_PROXY env vars
4

Credentials swapped

Shadow values replaced with real credentials from swap table
5

Request forwarded

Modified request sent to upstream API with real credentials

HTTPS MITM

For HTTPS traffic, the proxy performs man-in-the-middle interception:

Ephemeral CA Certificate

Source: ftl/proxy.py:45-82
The CA certificate is ephemeral (1-day validity) and generated fresh for each session.

Per-Host Leaf Certificates

For each HTTPS host, the proxy generates a leaf certificate signed by the CA:
Source: ftl/proxy.py:182-208

Credential Swapping

The swap happens at the byte level in both headers and body:
Source: ftl/proxy.py:135-146

Installation in Container

The proxy CA must be installed in the container’s trust store:
Source: ftl/proxy.py:377-395
Node.js requires a separate CA file via NODE_EXTRA_CA_CERTS because it doesn’t use the system trust store.

Agent Domain Bypass

The agent’s own API calls bypass the proxy to avoid SSL issues:
Source: ftl/proxy.py:364-376
These domains are added to NO_PROXY to route directly without interception.

Usage Example

Requirements

The proxy requires the cryptography library:
The proxy runs on 127.0.0.1 with a random free port, accessible from Docker via host.docker.internal.

Security Model

Ephemeral CA

CA certificate has 1-day validity and is generated per-session

Memory-Only

Real credentials never written to disk or logs

Agent Isolation

Agent only sees shadow credentials in environment

Selective Bypass

Agent API domains bypass proxy to avoid trust issues