Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat(agent-vault): proxy CA download and E2B guide (#9035)
Saif Ur Rahmanbb34b11d9b00
diff --git a/backend/e2e-test/routes/v1/agent-vault.spec.ts b/backend/e2e-test/routes/v1/agent-vault.spec.tsindex afe0775b7b..d9b19979a0 100644--- a/backend/e2e-test/routes/v1/agent-vault.spec.ts+++ b/backend/e2e-test/routes/v1/agent-vault.spec.ts@@ -7306,6 +7306,119 @@ describe("Agent Vault V1 Router", async () => {expect(row.encryptedRootCaPrivateKey).not.toBeNull();});+ test("the CA download returns the CA the proxy serves, to members as well as admins", async () => {+ const created = await createProxy("ca-download");+ const { rootCa } = JSON.parse((await asProxy(created.proxyToken, "bootstrap", {})).payload) as {+ rootCa: TRootCa;+ };++ const res = await inject("GET", `/api/v1/agent-vault/proxies/${created.proxy.id}/ca`);+ expect(res.statusCode).toBe(200);+ const { ca } = JSON.parse(res.payload) as { ca: { certificate: string; fingerprint: string; expiresAt: string } };+ expect(ca.certificate).toBe(rootCa.certificate);+ expect(ca.fingerprint).toBe(created.proxy.rootCaFingerprint);+ expect(new Date(ca.expiresAt).getTime()).toBe(new x509.X509Certificate(rootCa.certificate).notAfter.getTime());+ expect(res.payload).not.toContain("PRIVATE KEY");++ const member = await createUaIdentity(`av-proxy-ca-member-${Date.now()}`);+ try {+ expect(+ (await inject("POST", "/api/v1/agent-vault/members", { machineIdentityIds: [member.id], role: "member" }))+ .statusCode+ ).toBe(200);+ const asMember = await member.asIdentity("GET", `/api/v1/agent-vault/proxies/${created.proxy.id}/ca`);+ expect(asMember.statusCode).toBe(200);+ expect((JSON.parse(asMember.payload) as { ca: { certificate: string } }).ca.certificate).toBe(+ rootCa.certificate+ );+ } finally {+ await deleteUaIdentity(member.id);+ }+ });++ test("after a rotation the CA download returns the new CA", async () => {+ const created = await createProxy("ca-download-rotate");+ const rotated = await rotate(created.proxy.id);++ const res = await inject("GET", `/api/v1/agent-vault/proxies/${created.proxy.id}/ca`);+ expect(res.statusCode).toBe(200);+ const { ca } = JSON.parse(res.payload) as { ca: { fingerprint: string } };+ expect(ca.fingerprint).toBe(rotated.proxy.rootCaFingerprint);+ expect(ca.fingerprint).not.toBe(created.proxy.rootCaFingerprint);+ });++ test("the CA download is a 409 for a proxy serving its own CA, which Infisical doesn't hold", async () => {+ const created = await createProxy("ca-download-own");+ expect((await asProxy(created.proxyToken, "bootstrap", { servedCaCertificate: await caPem() })).statusCode).toBe(+ 200+ );++ const res = await inject("GET", `/api/v1/agent-vault/proxies/${created.proxy.id}/ca`);+ expect(res.statusCode).toBe(409);+ expect(JSON.parse(res.payload).message).toContain("--ca-cert");+ });++ test("a rotation keeps the CA download a 409 for a proxy serving its own CA", async () => {+ const created = await createProxy("ca-download-own-rotate");+ const own = await caPem();+ expect((await asProxy(created.proxyToken, "bootstrap", { servedCaCertificate: own })).statusCode).toBe(200);++ const rotated = await rotate(created.proxy.id);+ expect(rotated.proxy.rootCaFingerprint).toBe(fingerprintOf(own));+ const res = await inject("GET", `/api/v1/agent-vault/proxies/${created.proxy.id}/ca`);+ expect(res.statusCode).toBe(409);+ expect(JSON.parse(res.payload).message).toContain("--ca-cert");++ // Started on the new token without its own CA, it takes the one the rotation stored.+ const boot = await asProxy(rotated.proxyToken, "bootstrap", {});+ expect(boot.statusCode).toBe(200);+ const { rootCa } = JSON.parse(boot.payload) as { rootCa: TRootCa };+ const after = await inject("GET", `/api/v1/agent-vault/proxies/${created.proxy.id}/ca`);+ expect(after.statusCode).toBe(200);+ expect((JSON.parse(after.payload) as { ca: { certificate: string } }).ca.certificate).toBe(rootCa.certificate);+ });++ test("a proxy enrolled before Infisical stored CAs is told about its ca.crt, and a rotation gives it a CA", async () => {+ const created = await createProxy("ca-download-legacy");+ const legacy = await caPem();+ await agentVaultProxyDALFactory(testDb).updateById(created.proxy.id, {+ rootCaCertificate: null,+ encryptedRootCaPrivateKey: null,+ rootCaFingerprint: fingerprintOf(legacy)+ });++ const res = await inject("GET", `/api/v1/agent-vault/proxies/${created.proxy.id}/ca`);+ expect(res.statusCode).toBe(409);+ expect(JSON.parse(res.payload).message).toContain("ca.crt");++ // Its next start serves the CA the rotation stores, so the rotation records that CA's fingerprint.+ const rotated = await rotate(created.proxy.id);+ expect(rotated.proxy.rootCaFingerprint).not.toBe(fingerprintOf(legacy));+ const after = await inject("GET", `/api/v1/agent-vault/proxies/${created.proxy.id}/ca`);+ expect(after.statusCode).toBe(200);+ expect((JSON.parse(after.payload) as { ca: { fingerprint: string } }).ca.fingerprint).toBe(+ rotated.proxy.rootCaFingerprint+ );+ });++ test("a proxy with no CA at all is told to rotate its token", async () => {+ const created = await createProxy("ca-download-none");+ await agentVaultProxyDALFactory(testDb).updateById(created.proxy.id, {+ rootCaCertificate: null,+ encryptedRootCaPrivateKey: null,+ rootCaFingerprint: null+ });++ const res = await inject("GET", `/api/v1/agent-vault/proxies/${created.proxy.id}/ca`);+ expect(res.statusCode).toBe(409);+ expect(JSON.parse(res.payload).message).toContain("Rotate its proxy token");+ });++ test("the CA download is a 404 for a proxy that doesn't exist", async () => {+ const res = await inject("GET", `/api/v1/agent-vault/proxies/${crypto.randomUUID()}/ca`);+ expect(res.statusCode).toBe(404);+ });+test("a served CA that isn't a CA, or isn't a certificate, is refused and changes nothing", async () => {const created = await createProxy("token-bad-served-ca");const before = await testDb("agent_vault_proxies").where({ id: created.proxy.id }).first();diff --git a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-proxy-router.ts b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-proxy-router.tsindex 31f8fd8861..1b2af25407 100644--- a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-proxy-router.ts+++ b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-proxy-router.ts@@ -79,6 +79,40 @@ export const registerAgentVaultProxyRouter = async (server: FastifyZodProvider)})});+ server.route({+ method: "GET",+ url: "/:proxyId/ca",+ config: { rateLimit: readLimit },+ schema: {+ hide: false,+ operationId: "getAgentVaultProxyCa",+ description:+ "Get the certificate authority an Agent Vault proxy serves. Returns 409 when the proxy serves its own certificate authority, which Infisical does not hold.",+ tags: [ApiDocsTags.AgentVaultProxies],+ params: z.object({+ proxyId: z.string().uuid().describe(AGENT_VAULT.PROXY.proxyId)+ }),+ response: {+ 200: z.object({+ ca: z+ .object({+ certificate: z.string().describe(AGENT_VAULT.PROXY.rootCaCertificatePem),+ fingerprint: z.string().describe(AGENT_VAULT.PROXY.rootCaFingerprint),+ expiresAt: z.date().describe(AGENT_VAULT.PROXY.rootCaExpiresAt)+ })+ .describe(AGENT_VAULT.PROXY.ca)+ })+ }+ },+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),+ handler: async (req) =>+ server.services.agentVaultProxy.getProxyCa({+ projectId: req.internalAgentVaultProjectId,+ ctx: actorContext(req),+ proxyId: req.params.proxyId+ })+ });+server.route({method: "POST",url: "/",diff --git a/backend/src/ee/services/agent-vault-proxy/agent-vault-ca-fns.ts b/backend/src/ee/services/agent-vault-proxy/agent-vault-ca-fns.tsindex 3917c9b9a7..2d0cd93087 100644--- a/backend/src/ee/services/agent-vault-proxy/agent-vault-ca-fns.ts+++ b/backend/src/ee/services/agent-vault-proxy/agent-vault-ca-fns.ts@@ -24,6 +24,16 @@ const MAX_ROOT_CA_PEM_LENGTH = 16384;// A CA made moments before the proxy started can read as not yet valid when this server's clock is behind.const NOT_BEFORE_CLOCK_TOLERANCE_MS = 5 * 60 * 1000;const GENERATED_ROOT_CA_VALIDITY_YEARS = 10;++const fingerprintOf = (certificate: x509.X509Certificate): string => {+ const digest = crypto.nativeCrypto+ .createHash("sha256")+ .update(Buffer.from(certificate.rawData))+ .digest("hex")+ .toUpperCase();+ return `SHA256:${digest.match(/.{2}/g)!.join(":")}`;+};+export const parseRootCaCertificate = (pem: string): TParsedRootCa => {if (pem.length > MAX_ROOT_CA_PEM_LENGTH) {throw new BadRequestError({ message: "The certificate authority is too large to be a valid CA certificate" });@@ -58,16 +68,12 @@ export const parseRootCaCertificate = (pem: string): TParsedRootCa => {});}- const digest = crypto.nativeCrypto- .createHash("sha256")- .update(Buffer.from(certificate.rawData))- .digest("hex")- .toUpperCase();- const fingerprint = `SHA256:${digest.match(/.{2}/g)!.join(":")}`;-- return { fingerprint, expiresAt: certificate.notAfter };+ return { fingerprint: fingerprintOf(certificate), expiresAt: certificate.notAfter };};+// Checks nothing, so a stored CA that has since expired still compares by fingerprint.+export const getRootCaFingerprint = (pem: string): string => fingerprintOf(new x509.X509Certificate(pem));+// The same key type and subject the CLI uses for a CA it makes itself, so agents see no difference.export const generateProxyRootCa = async (): Promise<TGeneratedRootCa> => {const alg = keyAlgorithmToAlgCfg(CertKeyAlgorithm.ECDSA_P256);diff --git a/backend/src/ee/services/agent-vault-proxy/agent-vault-proxy-service.ts b/backend/src/ee/services/agent-vault-proxy/agent-vault-proxy-service.tsindex d988021942..e3975bcc16 100644--- a/backend/src/ee/services/agent-vault-proxy/agent-vault-proxy-service.ts+++ b/backend/src/ee/services/agent-vault-proxy/agent-vault-proxy-service.ts@@ -74,7 +74,7 @@ import {RESOURCE_TYPE_AGENT_VAULT_PROXY} from "../resource-auth-method/resource-auth-method-fns";import { TResourceAuthMethodServiceFactory } from "../resource-auth-method/resource-auth-method-service";-import { generateProxyRootCa, parseRootCaCertificate } from "./agent-vault-ca-fns";+import { generateProxyRootCa, getRootCaFingerprint, parseRootCaCertificate } from "./agent-vault-ca-fns";import { TAgentVaultProxyDALFactory } from "./agent-vault-proxy-dal";import {TAgentVaultProxyConfig,@@ -313,6 +313,27 @@ export const agentVaultProxyServiceFactory = ({return { proxies: proxies.map((proxy) => (isAdmin ? toAdminView(proxy) : toMemberView(proxy))), totalCount };};+ // A proxy started with its own CA reports only that CA's fingerprint, so the certificate Infisical holds is not+ // the one it serves and can't be handed out as if it were.+ const getProxyCa = async ({ projectId, ctx, proxyId }: TProxyByIdDTO) => {+ await $authorize({ projectId, ctx }, ProjectPermissionAgentVaultProxyActions.Read);+ const proxy = await $findProxyOr404({ projectId, proxyId });+ const servesOwnCa = new ConflictError({+ message: `Proxy '${proxy.name}' serves its own certificate authority. Use the certificate you passed to it with --ca-cert.`+ });+ // Rows without a certificate predate stored CAs and proxy tokens. A rotation stores a CA and issues a token.+ if (!proxy.rootCaCertificate) {+ throw new ConflictError({+ message: proxy.rootCaFingerprint+ ? `Proxy '${proxy.name}' was set up before Infisical stored its certificate authority, so it serves the ca.crt in its data directory. To manage the CA from Infisical, rotate the proxy token and restart the proxy with it.`+ : `Proxy '${proxy.name}' has no certificate authority yet. Rotate its proxy token, then start the proxy with the new token.`+ });+ }+ const held = parseRootCaCertificate(proxy.rootCaCertificate);+ if (proxy.rootCaFingerprint && proxy.rootCaFingerprint !== held.fingerprint) throw servesOwnCa;+ return { ca: { certificate: proxy.rootCaCertificate, fingerprint: held.fingerprint, expiresAt: held.expiresAt } };+ };+const $resourceActor = (ctx: TCreateProxyDTO["ctx"]) => ({type: ctx.actor,id: ctx.actorId,@@ -388,6 +409,12 @@ export const agentVaultProxyServiceFactory = ({const proxy = await $findProxyOr404({ projectId, proxyId });const { stored, reported } = await $newRootCa(proxy.projectId);+ // The fingerprint is the only record that a proxy serves its own CA, and its next start reports that CA again.+ // Overwriting it here would make the CA download hand out the new CA, which the proxy never serves. A row with no+ // certificate predates stored CAs, and its next start serves the CA stored here.+ const servesOwnCa =+ Boolean(proxy.rootCaCertificate && proxy.rootCaFingerprint) &&+ proxy.rootCaFingerprint !== getRootCaFingerprint(proxy.rootCaCertificate as string);const rotated = await agentVaultProxyDAL.transaction(async (tx) => {const updated = await agentVaultProxyDAL.updateById(@@ -397,7 +424,7 @@ export const agentVaultProxyServiceFactory = ({heartbeat: null,heartbeatTTL: null,...stored,- ...reported+ ...(servesOwnCa ? {} : reported)},tx);@@ -1149,6 +1176,7 @@ export const agentVaultProxyServiceFactory = ({return {getProxyForAuth,listProxies,+ getProxyCa,createProxy,rotateProxyToken,updateProxy,diff --git a/backend/src/ee/services/agent-vault/AGENTS.md b/backend/src/ee/services/agent-vault/AGENTS.mdindex 7494df05d2..5033c7383a 100644--- a/backend/src/ee/services/agent-vault/AGENTS.md+++ b/backend/src/ee/services/agent-vault/AGENTS.md@@ -211,10 +211,18 @@ is one `agent_vault_delegations` row per identity, with a scope of `all-members``storeRootCaIfMissing` deciding races. A proxy serving its own CA (`--ca-cert`) reports it at bootstrap and issent none; the stored CA is kept for processes that don't bring one, and the row shows whichever CA the lateststart reported. Create and rotate record the new CA's fingerprint so it can be pinned before- anything starts, and bootstrap's fingerprint write is tied to the token version it checked, so a start on a- rotated token can't overwrite it.+ anything starts, except that rotate keeps the fingerprint of a proxy serving its own CA (it is the only record+ of that, and the next start reports the same CA); a row with no certificate predates stored CAs and gets the+ new fingerprint. Bootstrap's fingerprint write is tied to the token version+ it checked, so a start on a rotated token can't overwrite it.- Agents still fetch the CA from the proxy's own unauthenticated `/_agent-vault/ca`, so the agent's trust path- has no dependency on Infisical. There is deliberately no admin download endpoint for the CA.+ has no dependency on Infisical. `GET /proxies/:proxyId/ca` (proxy Read) also returns it, for code that+ can't reach the proxy's HTTP port, such as an E2B orchestrator. It returns only the CA Infisical holds: a+ proxy serving its own CA reports just the fingerprint, so a fingerprint that doesn't match the stored+ certificate is a 409. A row with no certificate predates stored CAs and is a 409 that says to rotate the+ token. The fingerprint is only written at create, rotate and bootstrap, so a proxy that changed its own CA+ while Infisical was unreachable is recorded only at its next successful start; until then the download can+ return Infisical's CA.- Health is judged against `heartbeatTTL`, the interval the proxy was running when it last checked in, notthe row's current `pollInterval`. A proxy learns a new interval on its next poll, so comparing against thesaved one would report a live proxy as unreachable until then. Gateway v2 does the same.@@ -680,6 +688,11 @@ hostile input: nothing it sends may erase or hide its own records, so the proxyfive-poll grace window and reset the counter.- The enrollment dialog's Docker snippet mounts `/etc/infisical/agent-vault` (the root data dir). Without it are-created container has no CA and a spent token.+- `--socks5-port` opens a second door: SOCKS5, always over TLS, with the session token as the password, for+ clients such as E2B that tunnel a sandbox's traffic from outside it. After login it takes the same path as+ `CONNECT`, so it handles HTTP/1.1 only; other TCP is closed, with a rate-limited warning in the proxy's log. On that door alone, under+ the any-host policy, a host no service names may not resolve to a private address (cloud metadata, the+ proxy's own network); `--socks5-allow-private-destinations` turns that off.## The frontend@@ -698,3 +711,6 @@ hostile input: nothing it sends may erase or hide its own records, so the proxy`access-bundle-services.png` (columns are now Type and Target, and it should show an MCP row),`service-template-picker.png` (the service type sidebar, the MCP Servers section, **Custom HTTP API**), and`session-logs-view.png` (the Request column, with a tool call and a `tools/list` row).+- **Raw passthrough over SOCKS5.** Non-HTTP TCP to hosts no service names could be spliced through untouched,+ so SSH and databases work for SOCKS5 clients other than E2B. That traffic would carry no credential and+ produce no request logs.diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 21bc4ea4d0..7f736d3727 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -4930,6 +4930,7 @@ export const AGENT_VAULT = {rootCa:"The certificate authority Infisical keeps for this proxy: a PEM certificate and its PKCS#8 PEM private key.",rootCaCertificatePem: "The certificate authority's certificate, in PEM form.",+ ca: "The certificate authority the proxy serves, with its certificate in PEM form. Agents trust it to accept the proxy's certificates.",rootCaPrivateKey: "The certificate authority's private key, in PKCS#8 PEM form.",servedCaCertificate:"The certificate authority the proxy serves, in PEM form, when it uses its own instead of Infisical's. Infisical records its fingerprint and returns no `rootCa`.",diff --git a/docs/.vale/styles/config/vocabularies/Infisical/canonical/accept.txt b/docs/.vale/styles/config/vocabularies/Infisical/canonical/accept.txtindex c1f474fd5c..fe45d9d31e 100644--- a/docs/.vale/styles/config/vocabularies/Infisical/canonical/accept.txt+++ b/docs/.vale/styles/config/vocabularies/Infisical/canonical/accept.txt@@ -256,6 +256,7 @@ DevinMintlifyOnaDaytona+E2BDBTAb InitioInitio@@ -700,3 +701,6 @@ Stripe# --- Surfaced by the Agent Vault Docker guide ---gVisor++# --- Surfaced by the Agent Vault E2B guide ---+SOCKS5diff --git a/docs/api-reference/endpoints/agent-vault-proxies/get-ca.mdx b/docs/api-reference/endpoints/agent-vault-proxies/get-ca.mdxnew file mode 100644index 0000000000..1d4e921ac7--- /dev/null+++ b/docs/api-reference/endpoints/agent-vault-proxies/get-ca.mdx@@ -0,0 +1,4 @@+---+title: "Get proxy certificate authority"+openapi: "GET /api/v1/agent-vault/proxies/{proxyId}/ca"+---diff --git a/docs/cli/reference.mdx b/docs/cli/reference.mdxindex 60be20b44c..ef3c160aa3 100644--- a/docs/cli/reference.mdx+++ b/docs/cli/reference.mdx@@ -193,15 +193,22 @@ Run [Agent Vault](/documentation/platform/agent-vault/overview), which lets AI a{ name: "--ca-cert", value: "<string>", type: "string", description: "Your own certificate authority to serve instead of the one Infisical generates, as PEM text, PEM encoded as base64, or the path to a PEM file. Pass it with `--ca-key`. Can also be set with `INFISICAL_AGENT_VAULT_CA_CERT`." },{ name: "--ca-key", value: "<string>", type: "string", description: "The ECDSA P-256 private key for `--ca-cert`, in the same formats. Can also be set with `INFISICAL_AGENT_VAULT_CA_KEY`, which keeps the key off the command line." },{ name: "--data-dir", value: "<string>", type: "string", description: "The directory where the proxy keeps a cache of its settings and certificate authority, if the directory is writable. The proxy starts from the cache if it can't reach Infisical. Defaults to `~/.infisical/agent-vault`, or `/etc/infisical/agent-vault` when run as root. Can also be set with `INFISICAL_AGENT_VAULT_DATA_DIR`." },+ { name: "--listen-host", value: "<string>", type: "string", description: "The host name or IP address the HTTP proxy listens on, such as `127.0.0.1`, without a port. Defaults to all interfaces. Can also be set with `INFISICAL_AGENT_VAULT_LISTEN_HOST`." },{ name: "--log-file", value: "<string>", type: "string", description: "A file to also write logs to, as JSON lines. The file is appended to." },{ name: "--log-format", value: "<string>", type: "string", default: "console", description: "The format of the logs written to stderr: `console` or `json`." },- { name: "--port", value: "<int>", type: "int", default: "17323", description: "The port to listen on, on all interfaces. `0` picks any free port, which the startup line reports. Can also be set with `INFISICAL_AGENT_VAULT_PORT`." },+ { name: "--port", value: "<int>", type: "int", default: "17323", description: "The port for the HTTP proxy, on the address `--listen-host` sets. `0` picks any free port, which the startup line reports. Can also be set with `INFISICAL_AGENT_VAULT_PORT`." },{ name: "--proxy-token", value: "<string>", type: "string", description: "The proxy token, which Infisical shows once when you create the proxy or rotate its token. Can also be set with `INFISICAL_AGENT_VAULT_PROXY_TOKEN`, which keeps it off the command line." },+ { name: "--socks5-allow-private-destinations", type: "bool", description: "Turns off the SOCKS5 port's refusal of private and internal addresses, such as loopback, link-local, and the proxy's own network interfaces. Without this flag, the SOCKS5 port refuses those addresses for hosts that no service in the session's access bundle covers. Can also be set with `INFISICAL_AGENT_VAULT_SOCKS5_ALLOW_PRIVATE_DESTINATIONS`." },+ { name: "--socks5-port", value: "<int>", type: "int", description: "Turns on SOCKS5 over TLS on this port, on all interfaces. The port can be from `1` to `65535`, and has to differ from `--port`. Needs `--socks5-tls-name`, or `--socks5-tls-cert` and `--socks5-tls-key`. Off by default. Can also be set with `INFISICAL_AGENT_VAULT_SOCKS5_PORT`." },+ { name: "--socks5-tls-cert", value: "<string>", type: "string", description: "Your own certificate for the SOCKS5 port, as PEM text, PEM encoded as base64, or the path to a PEM file. Pass it with `--socks5-tls-key`, and not with `--socks5-tls-name`. The proxy reads it when it starts, so restart the proxy after you renew it. Can also be set with `INFISICAL_AGENT_VAULT_SOCKS5_TLS_CERT`." },+ { name: "--socks5-tls-key", value: "<string>", type: "string", description: "The private key for `--socks5-tls-cert`, in the same formats. Can also be set with `INFISICAL_AGENT_VAULT_SOCKS5_TLS_KEY`, which keeps the key off the command line." },+ { name: "--socks5-tls-name", value: "<string>", type: "string", description: "The DNS name or IP address clients reach the SOCKS5 port by. The proxy makes the port's certificate for this name from its certificate authority, and renews it. Can also be set with `INFISICAL_AGENT_VAULT_SOCKS5_TLS_NAME`." },]}examples={[{ title: "Start a proxy", code: "INFISICAL_AGENT_VAULT_PROXY_TOKEN=<proxy-token> infisical agent-vault proxy" },{ title: "Serve your own certificate authority", code: "INFISICAL_AGENT_VAULT_PROXY_TOKEN=<proxy-token> infisical agent-vault proxy --ca-cert=./ca.crt --ca-key=./ca.key" },{ title: "Log JSON to a file on a custom port", code: "INFISICAL_AGENT_VAULT_PROXY_TOKEN=<proxy-token> infisical agent-vault proxy --port=18000 --log-format=json --log-file=/var/log/infisical/agent-vault.log" },+ { title: "Accept SOCKS5 over TLS and keep the HTTP port local", code: "INFISICAL_AGENT_VAULT_PROXY_TOKEN=<proxy-token> infisical agent-vault proxy --listen-host=127.0.0.1 --socks5-port=1080 --socks5-tls-name=proxy.example.com" },]}>@@ -209,6 +216,8 @@ Run an Agent Vault [proxy](/documentation/platform/agent-vault/proxies) in the fStart the proxy with its proxy token. You can run the proxy on as many machines as you need with the same token. Each time the proxy starts, it loads its settings and certificate authority from Infisical. If it can't reach Infisical, it retries for 60 seconds, then starts from the cache in `--data-dir` if there is one, or exits.+To accept SOCKS5 connections from sandbox providers such as E2B, pass `--socks5-port` and `--socks5-tls-name`. Learn more about [the SOCKS5 port](/documentation/platform/agent-vault/proxies#accept-connections-over-socks5).+You set the proxy's traffic policy, exceptions, and poll interval in Infisical, not with flags.</CLICommand>diff --git a/docs/docs.json b/docs/docs.jsonindex 2b9dbd36a4..2e04e94d13 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -706,6 +706,7 @@"pages": ["documentation/platform/agent-vault/guides/modal","documentation/platform/agent-vault/guides/daytona",+ "documentation/platform/agent-vault/guides/e2b",{"group": "Kubernetes","icon": "/images/stack/kubernetes.png",@@ -4607,6 +4608,7 @@"group": "Proxies","pages": ["api-reference/endpoints/agent-vault-proxies/list",+ "api-reference/endpoints/agent-vault-proxies/get-ca","api-reference/endpoints/agent-vault-proxies/create","api-reference/endpoints/agent-vault-proxies/update","api-reference/endpoints/agent-vault-proxies/delete",diff --git a/docs/documentation/platform/agent-vault/guides/e2b.mdx b/docs/documentation/platform/agent-vault/guides/e2b.mdxnew file mode 100644index 0000000000..d613c6f768--- /dev/null+++ b/docs/documentation/platform/agent-vault/guides/e2b.mdx@@ -0,0 +1,559 @@+---+title: "Run agents in E2B sandboxes with Agent Vault"+sidebarTitle: "E2B"+icon: "/images/agent-vault-agents/e2b.svg"+description: "Send each E2B sandbox's traffic to an Agent Vault proxy over SOCKS5 so the agent never has access to a credential."+---++import SandboxAgentVaultSetup from "/snippets/agent-vault/SandboxAgentVaultSetup.mdx";++[E2B sandboxes](https://e2b.dev/docs/sandbox) are isolated virtual machines you create from code to run an agent. The agent in a sandbox runs commands that a prompt can influence, so any API key you give the sandbox can leak through a [prompt injection](/documentation/platform/agent-vault/why-agent-vault).++With Agent Vault, you don't give the sandbox any API keys. E2B's [bring your own proxy](https://e2b.dev/docs/network/byop) option sends the sandbox's outbound connections to a SOCKS5 proxy you run. You run an Agent Vault [proxy](/documentation/platform/agent-vault/proxies) with its SOCKS5 port turned on, and the proxy attaches the real credential to requests for the APIs you allowed. E2B connects to the proxy from its own servers, not from inside the sandbox, so nothing in the sandbox is configured to use the proxy, and code in the sandbox can't send traffic that skips it.++```mermaid+flowchart LR+ orchestrator["Your code"]+ subgraph e2b["E2B"]+ agent["Sandbox<br/>(runs the agent)"]+ host["E2B host<br/>(holds the session token)"]+ end+ proxy["Agent Vault proxy<br/>(SOCKS5 over TLS)"]+ apis["api.anthropic.com<br/>api.github.com<br/>..."]+ infisical["Infisical"]+ orchestrator -->|"creates the sandbox"| e2b+ orchestrator -->|"gets the CA and creates a session"| infisical+ agent -->|"HTTP and HTTPS connections"| host+ host -->|"SOCKS5 over TLS, with the session token"| proxy+ proxy -->|"request with the credential"| apis+ proxy -->|"fetches the credentials"| infisical+```++For each run, your code does the following:++1. [Gets the proxy's certificate authority (CA)](/api-reference/endpoints/agent-vault-proxies/get-ca) from Infisical+2. [Creates an Agent Vault session](/api-reference/endpoints/agent-vault-sessions/create) for the run ([learn more about sessions](/documentation/platform/agent-vault/sessions))+3. Creates a sandbox that sends its traffic to the proxy, with the session token as the SOCKS5 password+4. Adds the proxy's CA to the sandbox's trust store, and runs the agent+5. [Revokes the session](/api-reference/endpoints/agent-vault-sessions/revoke) and kills the sandbox when the agent finishes++One proxy serves every sandbox, so you set it up once.++<Accordion title="Why the proxy can be reachable from the internet">+ E2B only connects to proxies that are reachable from the internet, so the proxy can't be on a private network. These parts of the setup protect the session tokens and the proxy:++ - **TLS on the SOCKS5 port:** The SOCKS5 port only accepts TLS, so the session token and the traffic are encrypted on the way to the proxy+ - **No token in the sandbox:** E2B holds the session token on its servers, so the agent can't read it+ - **Short sessions:** Your code creates a session for each run and revokes it when the run ends, so a leaked token only works until then+ - **A local HTTP port:** The proxy's HTTP port stays local to the proxy's machine, and only the SOCKS5 port is public+ - **Private destinations blocked:** Through the SOCKS5 port, the proxy refuses requests to private and internal addresses, such as cloud metadata endpoints, unless a service in the session's access bundle names the host++ You can also use a firewall to limit the SOCKS5 port to the Google Cloud address ranges of the regions your sandboxes run in, as [E2B describes](https://e2b.dev/docs/faq/egress-ip-ranges). E2B publishes no ranges for its AWS region, and other Google Cloud customers share the Google Cloud ranges, so the firewall adds to these protections rather than replacing them.+</Accordion>++## Prerequisites++- The **Admin** role in [Agent Vault](/documentation/platform/agent-vault/access-control#product-membership)+- An [access bundle](/documentation/platform/agent-vault/access-bundles) with a service for each key the agent uses, including its model provider's key, such as **Anthropic** for Claude Code (see the [quickstart](/documentation/platform/agent-vault/quickstart))+- An [E2B](https://e2b.dev) account with [bring your own proxy](https://e2b.dev/docs/network/byop) turned on (E2B lists it as a private beta, so you may need to ask E2B to turn it on)+- An [E2B API key](https://e2b.dev/docs/api-key) in the `E2B_API_KEY` environment variable on the machine that runs your code+- The E2B SDK version 2.57.0 or later for your language: [Python](https://pypi.org/project/e2b/) (with [`requests`](https://pypi.org/project/requests/)) or [TypeScript](https://www.npmjs.com/package/e2b)+- A Linux machine or Kubernetes cluster to run the proxy, reachable from the internet, with a DNS name that points to it+- For the systemd setup, the [Infisical CLI](/cli/install) installed on that machine++## Step 1: Set up Agent Vault++<SandboxAgentVaultSetup />++## Step 2: Run the proxy on a public machine++Run the proxy where E2B can reach it from the internet, with its SOCKS5 port turned on. E2B runs sandboxes in Google Cloud's `us-west1` region by default, so a machine in or near that region adds the least latency to each request.++These commands start the proxy with its SOCKS5 port on port `1080`. With `--socks5-tls-name`, the proxy makes the port's TLS certificate from its CA for the DNS name you pass. Replace `<proxy-dns-name>` with the machine's DNS name, and `<your-instance-url>` with the URL of your Infisical instance:++<Tabs>+ <Tab title="systemd">+ Save the proxy token in `/etc/infisical/agent-vault-proxy.env`:++ ```bash+ INFISICAL_AGENT_VAULT_PROXY_TOKEN=<proxy-token>+ ```++ Run `sudo chmod 600 /etc/infisical/agent-vault-proxy.env` so that only root can read the file. Then save this unit as `/etc/systemd/system/agent-vault-proxy.service`:++ ```ini+ [Unit]+ Description=Infisical Agent Vault proxy+ After=network-online.target+ Wants=network-online.target++ [Service]+ EnvironmentFile=/etc/infisical/agent-vault-proxy.env+ ExecStart=infisical agent-vault proxy --domain <your-instance-url> --listen-host 127.0.0.1 --socks5-port 1080 --socks5-tls-name <proxy-dns-name>+ Restart=always++ [Install]+ WantedBy=multi-user.target+ ```++ `--listen-host 127.0.0.1` keeps the HTTP port local to the machine. Run `sudo systemctl enable --now agent-vault-proxy` to start the proxy now and every time the machine boots.+ </Tab>+ <Tab title="Docker">+ ```bash+ docker run -d --name agent-vault-proxy --restart unless-stopped \+ -p 1080:1080 \+ -v agent-vault-proxy:/etc/infisical/agent-vault \+ -e INFISICAL_AGENT_VAULT_PROXY_TOKEN=<proxy-token> \+ infisical/cli agent-vault proxy \+ --domain <your-instance-url> \+ --listen-host 127.0.0.1 \+ --socks5-port 1080 \+ --socks5-tls-name <proxy-dns-name>+ ```++ The command publishes only the SOCKS5 port, and `--listen-host 127.0.0.1` keeps the HTTP port, `17323`, from other containers on the same network.++ From inside a container, the proxy can't see the host's own addresses, so it can't refuse requests to them. If the host has its public IP address on its network interface, such as on DigitalOcean or Hetzner, and runs other services that only a cloud firewall hides, add a firewall rule on the host that blocks the proxy's container from the host's public IP address.+ </Tab>+ <Tab title="Kubernetes">+ ```yaml expandable+ apiVersion: v1+ kind: Secret+ metadata:+ name: agent-vault-proxy+ type: Opaque+ stringData:+ INFISICAL_AGENT_VAULT_PROXY_TOKEN: <proxy-token>+ ---+ apiVersion: apps/v1+ kind: Deployment+ metadata:+ name: agent-vault-proxy+ spec:+ replicas: 2+ selector:+ matchLabels:+ app: agent-vault-proxy+ template:+ metadata:+ labels:+ app: agent-vault-proxy+ spec:+ containers:+ - name: agent-vault-proxy+ image: infisical/cli+ args:+ - agent-vault+ - proxy+ - --domain+ - <your-instance-url>+ - --listen-host+ - 127.0.0.1+ - --socks5-port+ - "1080"+ - --socks5-tls-name+ - <proxy-dns-name>+ envFrom:+ - secretRef:+ name: agent-vault-proxy+ ports:+ - containerPort: 1080+ readinessProbe:+ tcpSocket:+ port: 1080+ ---+ apiVersion: v1+ kind: Service+ metadata:+ name: agent-vault-proxy+ spec:+ type: LoadBalancer+ selector:+ app: agent-vault-proxy+ ports:+ - port: 1080+ targetPort: 1080+ ```++ The Service exposes only the SOCKS5 port. Use a TCP (layer 4) load balancer, which passes the TLS connection through to the proxy. If the load balancer ends TLS itself, connections fail, because the SOCKS5 port only accepts TLS. Point `<proxy-dns-name>` at the load balancer's address.+ </Tab>+</Tabs>++To check that the proxy is up, such as in a load balancer's health check, open a TCP connection to port `1080`.++When the proxy starts, it logs `agent-vault: proxy listening`, with the proxy's ID in the `proxyId` field, then `agent-vault: SOCKS5 listening`. To read the log, run `journalctl -u agent-vault-proxy` for systemd, `docker logs agent-vault-proxy` for Docker, or `kubectl logs deploy/agent-vault-proxy` for Kubernetes.++Copy the proxy's ID for [Step 4](#step-4-run-a-command-in-a-sandbox).++<Info>+ To serve your own certificate on the SOCKS5 port instead, pass `--socks5-tls-cert` and `--socks5-tls-key` in place of `--socks5-tls-name`. Then change the `tls` setting in [Step 4](#step-4-run-a-command-in-a-sandbox) to match the certificate:++ | Certificate on the SOCKS5 port | `tls` in your code |+ | --- | --- |+ | Made by the proxy, with `--socks5-tls-name` | The proxy's CA as `ca_cert` (`caCert` in TypeScript), as the code in Step 4 does |+ | Yours, from a publicly trusted CA | `True` in Python, or `true` in TypeScript, so E2B uses its trust store |+ | Yours, from a private CA | That CA's certificate as `ca_cert` (`caCert` in TypeScript) |++ Learn more about the [SOCKS5 port's certificate](/documentation/platform/agent-vault/proxies#certificate-for-the-socks5-port).+</Info>++## Step 3: Give your code the credentials++Set `INFISICAL_UNIVERSAL_AUTH_CLIENT_ID` and `INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET` to the machine identity's client ID and client secret, in the environment of the code that creates your sandboxes. Your code never passes these credentials to a sandbox.++The proxy token stays on the proxy's machine, so your code doesn't need it.++## Step 4: Run a command in a sandbox++This function runs one shell command in a new sandbox and returns the command's output. Replace the values at the top:++- `<access-bundle-name>`: your access bundle's name+- `<proxy-id>`: the proxy's ID from [Step 2](#step-2-run-the-proxy-on-a-public-machine)+- `<proxy-dns-name>`: the proxy machine's DNS name+- `https://app.infisical.com`: if you use EU Cloud or self-host Infisical, the URL of your instance++<CodeGroup>++```python Python expandable+# run_in_sandbox.py+import os++import requests+from e2b import Sandbox++INFISICAL_URL = "https://app.infisical.com"+ACCESS_BUNDLE = "<access-bundle-name>"+PROXY_ID = "<proxy-id>"+PROXY_ADDRESS = "<proxy-dns-name>:1080"+TEMPLATE = "base"+SANDBOX_TIMEOUT = 15 * 60+SANDBOX_ENV = {}++CA_PATH = "/usr/local/share/ca-certificates/agent-vault-ca.crt"+# Points the tools that don't read the system trust store at the proxy's CA.+CA_ENV = {+ name: CA_PATH+ for name in ["SSL_CERT_FILE", "NODE_EXTRA_CA_CERTS", "REQUESTS_CA_BUNDLE", "CURL_CA_BUNDLE", "GIT_SSL_CAINFO", "DENO_CERT"]+}+++def run_in_sandbox(command: str) -> str:+ # The machine identity's credentials stay here and never enter the sandbox.+ login = requests.post(+ f"{INFISICAL_URL}/api/v1/auth/universal-auth/login",+ json={+ "clientId": os.environ["INFISICAL_UNIVERSAL_AUTH_CLIENT_ID"],+ "clientSecret": os.environ["INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET"],+ },+ timeout=30,+ )+ login.raise_for_status()+ headers = {"Authorization": f"Bearer {login.json()['accessToken']}"}++ # Fetched on every run, because the CA changes when you rotate the proxy's token.+ ca_response = requests.get(f"{INFISICAL_URL}/api/v1/agent-vault/proxies/{PROXY_ID}/ca", headers=headers, timeout=30)+ ca_response.raise_for_status()+ ca = ca_response.json()["ca"]["certificate"]++ # One session per run. The ttl outlasts the sandbox's timeout, so the agent+ # can't lose access mid-run.+ created = requests.post(+ f"{INFISICAL_URL}/api/v1/agent-vault/sessions",+ headers=headers,+ json={"accessBundles": [ACCESS_BUNDLE], "ttl": "20m"},+ timeout=30,+ )+ created.raise_for_status()+ session = created.json()["session"]++ sandbox = None+ try:+ sandbox = Sandbox.create(+ template=TEMPLATE,+ timeout=SANDBOX_TIMEOUT,+ envs={**CA_ENV, **SANDBOX_ENV},+ network={+ # E2B sends hostnames to the proxy, instead of IP addresses, only for+ # traffic that a domain entry in allow_out lets through.+ "allow_out": ["*"],+ "deny_out": ["0.0.0.0/0"],+ "egress_proxy": {+ "address": PROXY_ADDRESS,+ # The proxy ignores the username and reads the session token from the password.+ "username": "x-agent-vault",+ "password": session["token"],+ "tls": {"ca_cert": ca},+ },+ },+ )+ sandbox.files.write("/tmp/agent-vault-ca.pem", ca)+ sandbox.commands.run(+ f"install -m 644 /tmp/agent-vault-ca.pem {CA_PATH} && update-ca-certificates",+ user="root",+ )+ result = sandbox.commands.run(command, timeout=SANDBOX_TIMEOUT - 60)+ return result.stdout+ finally:+ # Revoke first, so the session ends even if killing the sandbox fails.+ try:+ requests.post(+ f"{INFISICAL_URL}/api/v1/agent-vault/sessions/{session['id']}/revoke",+ headers=headers,+ timeout=30,+ ).raise_for_status()+ finally:+ if sandbox:+ sandbox.kill()+```++```typescript TypeScript expandable+// runInSandbox.ts+import { Sandbox } from "e2b";++const INFISICAL_URL = "https://app.infisical.com";+const ACCESS_BUNDLE = "<access-bundle-name>";+const PROXY_ID = "<proxy-id>";+const PROXY_ADDRESS = "<proxy-dns-name>:1080";+const TEMPLATE = "base";+const SANDBOX_TIMEOUT_MS = 15 * 60 * 1000;+const SANDBOX_ENV: Record<string, string> = {};++const CA_PATH = "/usr/local/share/ca-certificates/agent-vault-ca.crt";+// Points the tools that don't read the system trust store at the proxy's CA.+const CA_ENV = Object.fromEntries(+ ["SSL_CERT_FILE", "NODE_EXTRA_CA_CERTS", "REQUESTS_CA_BUNDLE", "CURL_CA_BUNDLE", "GIT_SSL_CAINFO", "DENO_CERT"].map(+ (name) => [name, CA_PATH],+ ),+);++async function infisical(+ path: string,+ { method = "POST", token, body }: { method?: string; token?: string; body?: unknown } = {},+) {+ const headers: Record<string, string> = {};+ if (token) headers.Authorization = `Bearer ${token}`;+ if (body !== undefined) headers["Content-Type"] = "application/json";+ const response = await fetch(`${INFISICAL_URL}${path}`, {+ method,+ headers,+ body: body === undefined ? undefined : JSON.stringify(body),+ signal: AbortSignal.timeout(30_000),+ });+ if (!response.ok) throw new Error(`Infisical returned ${response.status}: ${await response.text()}`);+ return response.json();+}++export async function runInSandbox(command: string): Promise<string> {+ // The machine identity's credentials stay here and never enter the sandbox.+ const { accessToken } = await infisical("/api/v1/auth/universal-auth/login", {+ body: {+ clientId: process.env.INFISICAL_UNIVERSAL_AUTH_CLIENT_ID,+ clientSecret: process.env.INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET,+ },+ });++ // Fetched on every run, because the CA changes when you rotate the proxy's token.+ const { ca } = await infisical(`/api/v1/agent-vault/proxies/${PROXY_ID}/ca`, { method: "GET", token: accessToken });++ // One session per run. The ttl outlasts the sandbox's timeout, so the agent+ // can't lose access mid-run.+ const { session } = await infisical("/api/v1/agent-vault/sessions", {+ token: accessToken,+ body: { accessBundles: [ACCESS_BUNDLE], ttl: "20m" },+ });++ let sandbox: Sandbox | undefined;+ try {+ sandbox = await Sandbox.create(TEMPLATE, {+ timeoutMs: SANDBOX_TIMEOUT_MS,+ envs: { ...CA_ENV, ...SANDBOX_ENV },+ network: {+ // E2B sends hostnames to the proxy, instead of IP addresses, only for+ // traffic that a domain entry in allowOut lets through.+ allowOut: ["*"],+ denyOut: ["0.0.0.0/0"],+ egressProxy: {+ address: PROXY_ADDRESS,+ // The proxy ignores the username and reads the session token from the password.+ username: "x-agent-vault",+ password: session.token,+ tls: { caCert: ca.certificate },+ },+ },+ });+ await sandbox.files.write("/tmp/agent-vault-ca.pem", ca.certificate);+ await sandbox.commands.run(`install -m 644 /tmp/agent-vault-ca.pem ${CA_PATH} && update-ca-certificates`, {+ user: "root",+ });+ const result = await sandbox.commands.run(command, { timeoutMs: SANDBOX_TIMEOUT_MS - 60_000 });+ return result.stdout;+ } finally {+ // Revoke first, so the session ends even if killing the sandbox fails.+ try {+ await infisical(`/api/v1/agent-vault/sessions/${session.id}/revoke`, { token: accessToken });+ } finally {+ await sandbox?.kill();+ }+ }+}+```++</CodeGroup>++The function adds the proxy's CA to the sandbox's system trust store, and sets the variables that [`agent-vault run`](/documentation/platform/agent-vault/proxies#certificate-trust) sets for the tools that don't read that store.++To keep the same CA when you rotate the proxy's token, [use your own CA](/documentation/platform/agent-vault/proxies#use-your-own-certificate-authority). Infisical doesn't have your own CA, so read its certificate from a file instead of [getting it from Infisical](/api-reference/endpoints/agent-vault-proxies/get-ca).++For more about creating sessions from code, see [Create sessions with the API](/documentation/platform/agent-vault/sessions-api).++## Step 5: Verify it works++Call the function with a request to an API in the access bundle. This example calls the Anthropic API, which returns a list of models only if the request has an API key. If your access bundle doesn't have an **Anthropic** service, replace the URL with the URL of an API that the access bundle has a service for:++<CodeGroup>++```python Python+# main.py+from run_in_sandbox import run_in_sandbox++print(run_in_sandbox("curl -s https://api.anthropic.com/v1/models -H 'anthropic-version: 2023-06-01'"))+```++```typescript TypeScript+// main.ts+import { runInSandbox } from "./runInSandbox.js";++console.log(await runInSandbox("curl -s https://api.anthropic.com/v1/models -H 'anthropic-version: 2023-06-01'"));+```++</CodeGroup>++The response lists Anthropic's models, even though the sandbox has no Anthropic API key and no settings for the proxy.++<Check>+ Each run now gets its own sandbox and session. The session token never enters the sandbox, and your code revokes the session when the run ends.+</Check>++To check which requests the sandbox made, [set up session logs](/documentation/platform/agent-vault/session-logs), then [view the session's logs](/documentation/platform/agent-vault/sessions#view-session-logs) in Agent Vault. Requests that got a credential have the outcome **Brokered**.++## Step 6: Run an agent++To run an agent such as Claude Code, start the sandbox from an E2B template that has the agent installed:++<Steps>+ <Step>+ Set `TEMPLATE` at the top of the code from Step 4 to the template's name. For Claude Code, use `claude`, a [template E2B provides](https://e2b.dev/docs/agents/claude-code) with Claude Code installed. For another agent, [build a template](https://e2b.dev/docs/template/quickstart) with the agent installed.+ </Step>+ <Step>+ Add the agent's settings to `SANDBOX_ENV`. For Claude Code, add these:++ <CodeGroup>++ ```python Python+ SANDBOX_ENV = {+ # Claude Code won't start without a key; the proxy replaces this one.+ "ANTHROPIC_API_KEY": "agent-vault",+ # Skips Claude Code's update checks and telemetry. If the proxy only allows+ # access bundle hosts, it blocks them.+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",+ "DISABLE_AUTOUPDATER": "1",+ }+ ```++ ```typescript TypeScript+ const SANDBOX_ENV: Record<string, string> = {+ // Claude Code won't start without a key; the proxy replaces this one.+ ANTHROPIC_API_KEY: "agent-vault",+ // Skips Claude Code's update checks and telemetry. If the proxy only allows+ // access bundle hosts, it blocks them.+ CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1",+ DISABLE_AUTOUPDATER: "1",+ };+ ```++ </CodeGroup>+ </Step>+ <Step>+ Call the function with the agent's non-interactive command, such as `claude -p 'Reply with the word OK.' --permission-mode bypassPermissions`.+ </Step>+</Steps>++The agent calls its APIs the same way it does without Agent Vault, and E2B sends the connections to the proxy, so the agent doesn't need `HTTPS_PROXY` or `infisical agent-vault run`.++## Security considerations++### Network access from the sandbox++The sandbox can look up hostnames over DNS at `8.8.8.8`, which E2B lets through without the proxy, so an agent can still send data out in the names it looks up, though never a credential. To limit DNS, see [E2B's DNS settings](https://e2b.dev/docs/network/internet-access#dns-when-you-filter-by-domain).++Every other connection goes through the proxy:++- **Hosts through the proxy:** under the default [traffic policy](/documentation/platform/agent-vault/proxies#traffic-policy), **Any host**, the proxy forwards the sandbox's requests to any host on the internet+- **Ports:** E2B only sends connections on ports `80` and `443` to the proxy, so the sandbox can't reach a service on any other port++To allow only the hosts that services in the session's access bundle cover, set the traffic policy to **Access bundle hosts only**. Add any other hosts the agent needs, such as `registry.npmjs.org`, to the proxy's [exceptions](/documentation/platform/agent-vault/proxies#exceptions).++### Compromised sandboxes or leaked tokens++The session token is in your code and in E2B's settings for the sandbox, not in the sandbox. If you think a session token leaked, [revoke the session](/documentation/platform/agent-vault/sessions#revoke-a-session).++The proxy token is only on the proxy's machine. If you think someone took control of that machine, [rotate the proxy's token](/documentation/platform/agent-vault/proxies#rotate-a-proxys-token).++## Troubleshooting++<AccordionGroup>+ <Accordion title="The proxy's systemd service fails to start">+ If `sudo systemctl status agent-vault-proxy` shows `status=203/EXEC`, systemd couldn't find the Infisical CLI. Run `which infisical` to find your CLI's path. In `/etc/systemd/system/agent-vault-proxy.service`, replace `infisical` at the start of the `ExecStart=` line with that path, then reload and restart the proxy:++ ```bash+ sudo systemctl daemon-reload+ sudo systemctl restart agent-vault-proxy+ ```+ </Accordion>+ <Accordion title="Requests fail with a certificate error, or reach the API without a credential">+ E2B sent the proxy an IP address instead of a hostname, so HTTPS requests fail with a certificate error, and the proxy can't match the request to a service. The proxy's log shows `closed a SOCKS5 connection the proxy can't handle` with a TLS handshake error for the host's IP address.++ E2B only sends hostnames for traffic that a domain entry allows, so create the sandbox with `allow_out` set to `["*"]` and `deny_out` set to `["0.0.0.0/0"]`, as the function in [Step 4](#step-4-run-a-command-in-a-sandbox) does.+ </Accordion>+ <Accordion title="Connections from the sandbox fail right away">+ The proxy refused the connection before any request. Check the proxy's log for one of these lines:++ - `agent-vault: refused, the session is no longer valid`: the session expired or was revoked+ - `agent-vault: refused, Infisical rejected this proxy's token`: someone rotated or revoked the proxy's token, so restart the proxy with the new token+ - `agent-vault: refused, the session could not be resolved`: the proxy couldn't reach Infisical to check the session+ - `agent-vault: a client spoke plain SOCKS5 to the TLS port`: the sandbox's `egress_proxy` has no `tls` setting++ If none of these lines appears, the password might not be a session token, or E2B might not trust the SOCKS5 port's certificate. Start the proxy with `--log-level debug` to log these refusals too.+ </Accordion>+ <Accordion title="Requests fail with a 403 partway through a run">+ The session expired or was revoked while the sandbox was running. Set the session's `ttl` a few minutes longer than the sandbox's timeout, so the session lasts as long as the sandbox can run.+ </Accordion>+ <Accordion title="Requests to a host fail with a 403 from the start">+ If the proxy's traffic policy is **Access bundle hosts only**, the proxy blocks hosts that no service in the access bundle covers. Add a service for the host, or add the host to the proxy's [exceptions](/documentation/platform/agent-vault/proxies#exceptions).++ If the 403 says `the destination is a private or internal address`, the host resolves to an internal address, such as a private network or the proxy's own machine. The SOCKS5 port refuses those for every host that no service covers, including exceptions. Add a service for the host, or start the proxy with `--socks5-allow-private-destinations`.+ </Accordion>+ <Accordion title="A service on a port other than 80 or 443 doesn't work">+ E2B only sends connections on ports `80` and `443` to the proxy. Use the service's HTTPS endpoint on port `443` instead.+ </Accordion>+ <Accordion title="A tool in the sandbox rejects the proxy's certificate">+ The tool doesn't read the system trust store or the variables the function sets. Java programs use their own keystore, and some Rust programs have a built-in certificate list. Add the proxy's CA to the tool's own trust settings.+ </Accordion>+ <Accordion title="The sandbox's traffic stops going through the proxy">+ Updating a running sandbox's network settings with `update_network` (`updateNetwork` in TypeScript) replaces all of them. If the update doesn't include `egress_proxy`, E2B sends the sandbox's traffic out directly. Include the same `egress_proxy`, with its `tls` setting, in every update.+ </Accordion>+ <Accordion title="Getting the CA from Infisical fails with a 409">+ The proxy serves your own CA, which Infisical doesn't have. [With your own CA](/documentation/platform/agent-vault/proxies#use-your-own-certificate-authority), read the certificate you passed with `--ca-cert` from a file instead.+ </Accordion>+</AccordionGroup>++## Next steps++<CardGroup cols={2}>+ <Card title="Proxies" icon="server" href="/documentation/platform/agent-vault/proxies#accept-connections-over-socks5">+ Learn more about the proxy's SOCKS5 port and its settings.+ </Card>+ <Card title="Session logs" icon="list" href="/documentation/platform/agent-vault/session-logs">+ Record every request an agent makes during a session.+ </Card>+</CardGroup>diff --git a/docs/documentation/platform/agent-vault/how-it-works.mdx b/docs/documentation/platform/agent-vault/how-it-works.mdxindex 262419123e..5bbe47f738 100644--- a/docs/documentation/platform/agent-vault/how-it-works.mdx+++ b/docs/documentation/platform/agent-vault/how-it-works.mdx@@ -274,6 +274,8 @@ Agent Vault uses the `HTTPS_PROXY` environment variable, which `curl`, `git`, `gThe same applies to MCP servers. Your agent's MCP configuration keeps each server's real URL and has no token, and the proxy authenticates the agent's requests to the server.+Some sandbox providers, such as [E2B](/documentation/platform/agent-vault/guides/e2b), can send a sandbox's HTTP and HTTPS traffic to the proxy over SOCKS5 instead, so the agent doesn't need `HTTPS_PROXY`.+<Note>Node.js's built-in `fetch` (undici-backed) doesn't read `HTTPS_PROXY` by default. If your agent uses it directly, run Node with `--use-env-proxy` or set `NODE_USE_ENV_PROXY=1` (Node 24 or later). Third-party clients like `axios`, `node-fetch`, and `got` read the environment variable without extra flags.</Note>diff --git a/docs/documentation/platform/agent-vault/overview.mdx b/docs/documentation/platform/agent-vault/overview.mdxindex f36ebfeaec..34643e3cc7 100644--- a/docs/documentation/platform/agent-vault/overview.mdx+++ b/docs/documentation/platform/agent-vault/overview.mdx@@ -36,6 +36,9 @@ Set up Agent Vault for where your agents run.<Card title="Daytona" icon="/images/agent-vault-agents/daytona.svg" href="/documentation/platform/agent-vault/guides/daytona">Run an Agent Vault proxy beside each Daytona sandbox so the agent never has access to a credential.</Card>+ <Card title="E2B" icon="/images/agent-vault-agents/e2b.svg" href="/documentation/platform/agent-vault/guides/e2b">+ Send each E2B sandbox's traffic to an Agent Vault proxy over SOCKS5 so the agent never has access to a credential.+ </Card><Card title="Kubernetes" icon="/images/stack/kubernetes.png" href="/documentation/platform/agent-vault/guides/kubernetes">Learn how to run AI agents in Kubernetes pods that contain no credentials and can only connect to the Agent Vault proxy.</Card>diff --git a/docs/documentation/platform/agent-vault/plan-your-setup.mdx b/docs/documentation/platform/agent-vault/plan-your-setup.mdxindex a96e1c581e..dc79004952 100644--- a/docs/documentation/platform/agent-vault/plan-your-setup.mdx+++ b/docs/documentation/platform/agent-vault/plan-your-setup.mdx@@ -180,7 +180,7 @@ Configure the following options to get custom guidance and best practices tailor<AgentVaultSetupBranch building="platform" runs="container,kubernetes,sandbox"><Note>- The proxy runs outside the agent's environment, and the agent's network only reaches the proxy. The agent can't read the proxy token or connect to an API without going through the proxy.+ The proxy runs outside the agent's environment, and the agent's network only reaches the proxy. The agent can't read the proxy token or connect to an API without going through the proxy. If your agents run in [E2B sandboxes](/documentation/platform/agent-vault/guides/e2b), run the proxy on a public machine with its SOCKS5 port turned on, because E2B connects to the proxy from its own servers.</Note></AgentVaultSetupBranch></AgentVaultSetupStep>diff --git a/docs/documentation/platform/agent-vault/proxies.mdx b/docs/documentation/platform/agent-vault/proxies.mdxindex 332ef9cd71..31fe5664c4 100644--- a/docs/documentation/platform/agent-vault/proxies.mdx+++ b/docs/documentation/platform/agent-vault/proxies.mdx@@ -14,6 +14,8 @@ You can run the proxy in one of two ways:- **[One proxy for several agents](/documentation/platform/agent-vault/how-it-works#common-proxy):** one proxy runs on its own machine or as a [Kubernetes Deployment](/documentation/platform/agent-vault/guides/kubernetes), and every agent sends its requests to it. Agents send their session token to the proxy over plain HTTP, so this is suitable only for agents on a private network that you control- **[One proxy per agent](/documentation/platform/agent-vault/how-it-works#one-proxy-per-agent):** the orchestrator starts a proxy in a separate container with each agent, such as a [Modal sidecar](/documentation/platform/agent-vault/guides/modal) or a [linked Daytona sandbox](/documentation/platform/agent-vault/guides/daytona), and stops the proxy when the agent finishes. This is suitable for a managed sandbox platform, where a shared proxy would have to accept connections from the internet+If your agents run in [E2B sandboxes](/documentation/platform/agent-vault/guides/e2b), run one proxy for several agents on a public machine, with the [SOCKS5 port](#accept-connections-over-socks5) turned on. E2B connects to the proxy from its own servers, so the proxy can't be on a private network.+Either way, we recommend running the proxy separately from the agent, either in its own container or on its own machine. If the agent and the proxy run in the same environment, the agent can read the proxy token and the private key of the proxy's certificate authority.<Tip>@@ -22,12 +24,15 @@ If you run a shared proxy, we recommend keeping it on the same private network a## Supported connections-The proxy attaches credentials to HTTP/1.1 requests, over both HTTPS and plain HTTP. These connections fail through the proxy:+Agents connect to the proxy as an HTTP proxy. If you turn on the [SOCKS5 port](#accept-connections-over-socks5), clients such as E2B can also connect over SOCKS5 over TLS.++Over either connection, the proxy attaches credentials to HTTP/1.1 requests, over both HTTPS and plain HTTP. These connections fail through the proxy:- WebSocket connections, such as to a `wss://` URL- Clients that only speak HTTP/2, such as gRPC clients+- Other TCP traffic through the SOCKS5 port, such as SSH-If an API offers both, configure the agent to use its plain HTTPS requests. Many SDKs fall back to HTTPS when a WebSocket connection fails.+If an API offers both WebSocket connections and plain HTTPS requests, configure the agent to use the HTTPS requests. Many SDKs fall back to HTTPS when a WebSocket connection fails.## Create a proxy and start it@@ -155,6 +160,8 @@ The commands use these settings:- `INFISICAL_AGENT_VAULT_PROXY_TOKEN` or `--proxy-token`: the proxy token (prefer the environment variable, because other users on the machine can read anything on a command line)- `--domain` or `INFISICAL_DOMAIN`: your Infisical instance URL (required for EU Cloud and self-hosted instances, because the default is Infisical Cloud in the US)+The HTTP port listens on all interfaces. To make it listen on one address only, such as `127.0.0.1`, pass `--listen-host` or set `INFISICAL_AGENT_VAULT_LISTEN_HOST`. To also accept SOCKS5 connections, see [Accept connections over SOCKS5](#accept-connections-over-socks5).+Each time the proxy starts, it loads its settings and certificate authority from Infisical and, if it can, saves a copy in its data directory (`~/.infisical/agent-vault`, or `/etc/infisical/agent-vault` as root, or `--data-dir`). If it can't reach Infisical for 60 seconds, it starts from that copy, or exits if there isn't one.<Info>@@ -266,9 +273,18 @@ The proxy decrypts HTTPS traffic to attach the credential, so each agent has to<Warning>Agents send their session token to the proxy unencrypted with every request. If someone can read that traffic and reach the proxy, they can use the token to call every API in the session's access bundle with its real credentials. The token keeps working until the session expires or you [revoke it](/documentation/platform/agent-vault/sessions#revoke-a-session).-For this reason, we recommend running the proxy where only your agents can reach it, such as on the same host, a private network, or a container network.+For this reason, we recommend running the proxy where only your agents can reach it, such as on the same host, a private network, or a container network. The [SOCKS5 port](#accept-connections-over-socks5) always uses TLS, so the session token is encrypted on the way to it.</Warning>+### Download the certificate authority++To give the proxy's CA to a sandbox provider, or to get the CA without connecting to the proxy, download it from Infisical:++- **In Infisical:** on the **Proxies** page, select the download icon next to the fingerprint in the **Certificate Authority** column+- **With the API:** call [the endpoint that gets a proxy's certificate authority](/api-reference/endpoints/agent-vault-proxies/get-ca) as an Agent Vault member or admin++If the proxy serves [your own CA](#use-your-own-certificate-authority), Infisical doesn't have the certificate, so the download fails.+### Pin the proxy's certificateIf the agent runs on a network you don't fully control, pin the proxy's certificate so the agent only talks to your proxy. Copy the fingerprint from the **Certificate Authority** column on the **Proxies** page, and pass it with `--ca-fingerprint`:@@ -300,6 +316,60 @@ Your own CA stays the same when you rotate the proxy's token. To use the CA InfiThe proxy checks the certificate of each API it connects to, the way any HTTPS client does. If an API uses a private certificate authority, the machine running the proxy has to trust that authority. The agent's machine doesn't need to trust it.+## Accept connections over SOCKS5++Some sandbox providers, such as [E2B](/documentation/platform/agent-vault/guides/e2b), send a sandbox's traffic to a SOCKS5 proxy from outside the sandbox, instead of setting `HTTPS_PROXY` in the sandbox. To support them, turn on the proxy's SOCKS5 port, which only accepts SOCKS5 over TLS.++### Turn on the SOCKS5 port++Pass `--socks5-port` with the port number, and `--socks5-tls-name` with the DNS name or IP address that clients connect to:++```bash+INFISICAL_AGENT_VAULT_PROXY_TOKEN=<proxy-token> \+infisical agent-vault proxy \+ --listen-host 127.0.0.1 \+ --socks5-port 1080 \+ --socks5-tls-name proxy.example.com+```++- **Interfaces:** the SOCKS5 port listens on all interfaces, on a different port from `--port`+- **Who can reach it:** only the clients that connect to the SOCKS5 port need to reach it, so limit the port to their addresses with a firewall, a private network, or a VPN where you can+- **The HTTP port:** on a public machine, keep the HTTP port (`17323` by default) off the internet, such as with `--listen-host 127.0.0.1`, because agents send their session token to it unencrypted+- **Environment variables:** each flag has an environment variable, listed in the [CLI reference](/cli/reference#agent-vault-proxy)++When the port is ready, the proxy logs `agent-vault: SOCKS5 listening`. Log lines about SOCKS5 sign-ins and requests have the field `door` set to `socks5`.++### Certificate for the SOCKS5 port++With `--socks5-tls-name`, the proxy makes the port's certificate from its CA and renews the certificate before it expires. Clients check the certificate with the proxy's CA, which you can [download from Infisical](#download-the-certificate-authority), or with your own CA's certificate if you [use your own](#use-your-own-certificate-authority).++To serve your own certificate instead, such as one from a publicly trusted CA, pass `--socks5-tls-cert` and `--socks5-tls-key` in place of `--socks5-tls-name`:++- **Formats:** each value can be the PEM text, the PEM encoded as base64, or the path to a PEM file+- **Key types:** RSA, ECDSA, or Ed25519+- **Expired certificates:** the proxy doesn't start if the certificate has expired+- **Renewal:** the proxy reads the certificate only when it starts, so restart the proxy each time you renew the certificate (the proxy warns in its log when fewer than 14 days are left)++### Sessions on the SOCKS5 port++Clients sign in with a SOCKS5 username and password. The proxy ignores the username, so you can use any value, such as `x-agent-vault`. Set the password to the session token. After sign-in, the proxy handles requests the same way it handles them on the HTTP port, including the [traffic policy](#traffic-policy) and the limits in [Supported connections](#supported-connections).++- If the session isn't valid, the proxy refuses the sign-in and logs the reason, so the client reports a failed sign-in (if the password isn't a session token, the proxy logs the reason only with `--log-level debug`)+- If the proxy can't check the session, such as when Infisical is unreachable, it accepts the sign-in and refuses the connection with a general failure, so the client can try again later+- If you revoke a session while a connection is open, the next request on that connection gets a 403 with `the session is no longer valid` (within one [poll interval](#poll-interval))++### Requests to private addresses++The SOCKS5 port refuses requests to private, loopback, link-local, and other internal addresses, such as a cloud metadata endpoint or the proxy's own network interfaces, under either traffic policy. The client gets a 403:++```text+HTTP/1.1 403 Forbidden++the destination is a private or internal address+```++The proxy still lets the request through if a service in the session's access bundle names the host. [Exceptions](#exceptions) don't count, so an exception for an internal host is refused on the SOCKS5 port. If the proxy runs in a container, it can't see the host's own addresses, so block those with a firewall rule on the host. The HTTP port doesn't refuse these addresses. To turn the check off for the SOCKS5 port, pass `--socks5-allow-private-destinations`.+## Rotate a proxy's tokenRotate the token if it leaked, or to bring back a proxy whose access you revoked:@@ -321,6 +391,7 @@ The current token will stop working, and the proxy gets a new certificate author- Restart every agent that uses the proxy, because those agents still trust the old certificate- Update any `--ca-fingerprint` pin- Replace any `ca.pem` file you mounted for an agent+- Download the CA again for any SOCKS5 client you gave it to- On macOS, replace the certificate in your login keychainIf you [use your own certificate authority](#use-your-own-certificate-authority), only the token changes, so your agents don't need these updates.@@ -341,7 +412,7 @@ Revoke access if you think a machine running the proxy is compromised.To keep the proxy available when one machine goes down, run it on several machines with the same proxy token and put a load balancer in front of them. Every machine serves the same certificate authority, so agents trust whichever machine they reach.- **Load balancer type:** use a TCP (layer 4) load balancer, because agents send `CONNECT` requests that most HTTP load balancers don't forward. You don't need sticky sessions-- **Health checks:** send an HTTP `GET` to `/_agent-vault/ca` on each machine, which returns `200` while the proxy is serving+- **Health checks:** send an HTTP `GET` to `/_agent-vault/ca` on each machine, which returns `200` while the proxy is serving (if the HTTP port only listens locally, open a TCP connection to the SOCKS5 port instead)- **Your own certificate authority (optional):** if you want to [use your own](#use-your-own-certificate-authority), pass the same `--ca-cert` and `--ca-key` to every machinePoint agents at the load balancer's address instead of a single machine.diff --git a/docs/documentation/platform/agent-vault/quickstart.mdx b/docs/documentation/platform/agent-vault/quickstart.mdxindex 070d6e6ddc..f382451460 100644--- a/docs/documentation/platform/agent-vault/quickstart.mdx+++ b/docs/documentation/platform/agent-vault/quickstart.mdx@@ -244,4 +244,7 @@ If you're not sure which guide fits, [plan your setup](/documentation/platform/a<Card title="Docker" icon="/images/agent-vault-agents/docker.svg" href="/documentation/platform/agent-vault/guides/docker">Run an Agent Vault proxy beside each agent container so the agent never has access to a credential.</Card>+ <Card title="E2B sandboxes" icon="/images/agent-vault-agents/e2b.svg" href="/documentation/platform/agent-vault/guides/e2b">+ Run an Agent Vault proxy for your E2B sandboxes so the agent never has access to a credential.+ </Card></CardGroup>diff --git a/docs/images/agent-vault-agents/e2b.svg b/docs/images/agent-vault-agents/e2b.svgnew file mode 100644index 0000000000..7d9c9de4c7--- /dev/null+++ b/docs/images/agent-vault-agents/e2b.svg@@ -0,0 +1 @@+<svg width="64" height="64" viewBox="0 -2 64 64" fill="none" xmlns="http://www.w3.org/2000/svg"><metadata>E2B size-specific symbol artwork</metadata><path d="M48.5107 15.25V23.6553H24.6875C24.25 23.6553 23.8945 24.0107 23.8945 24.4482V25.0049C23.8945 25.4424 24.25 25.7969 24.6875 25.7969H48.5107V34.2031H24.6875C24.25 34.2031 23.8945 34.5576 23.8945 34.9951V35.5518C23.8945 35.9893 24.25 36.3447 24.6875 36.3447H48.5107V44.75H20.9404C17.93 44.7498 15.4896 42.3093 15.4893 39.2988V20.7012C15.4895 17.6907 17.9299 15.2502 20.9404 15.25H48.5107Z" fill="#FF3001"/></svg>diff --git a/frontend/src/hooks/api/agentVault/queries.tsx b/frontend/src/hooks/api/agentVault/queries.tsxindex d355d2b32d..2cda579585 100644--- a/frontend/src/hooks/api/agentVault/queries.tsx+++ b/frontend/src/hooks/api/agentVault/queries.tsx@@ -40,6 +40,7 @@ import {TAgentVaultProductMember,TAgentVaultProductMemberOf,TAgentVaultProxy,+ TAgentVaultProxyCa,TAgentVaultSession,TAgentVaultSessionLogCorsProbe,TAgentVaultSessionLogHealth,@@ -432,6 +433,13 @@ export const useListAgentVaultProxies = (});};+export const fetchAgentVaultProxyCa = async (proxyId: string) => {+ const { data } = await apiRequest.get<{ ca: TAgentVaultProxyCa }>(+ `/api/v1/agent-vault/proxies/${proxyId}/ca`+ );+ return data.ca;+};+export const useGetAgentVaultSessionLogSettings = (enabled = true) => {const { currentOrg } = useOrganization();diff --git a/frontend/src/hooks/api/agentVault/types.ts b/frontend/src/hooks/api/agentVault/types.tsindex afa8ca6398..f6a8e9a53e 100644--- a/frontend/src/hooks/api/agentVault/types.ts+++ b/frontend/src/hooks/api/agentVault/types.ts@@ -348,6 +348,12 @@ export type TAgentVaultProxy = {createdAt?: string;};+export type TAgentVaultProxyCa = {+ certificate: string;+ fingerprint: string;+ expiresAt: string;+};+export type TAgentVaultProxyToken = {proxyToken: string;};diff --git a/frontend/src/pages/agent-vault/AgentVaultProxiesPage/AgentVaultProxiesPage.tsx b/frontend/src/pages/agent-vault/AgentVaultProxiesPage/AgentVaultProxiesPage.tsxindex cce2edd627..1a1da25672 100644--- a/frontend/src/pages/agent-vault/AgentVaultProxiesPage/AgentVaultProxiesPage.tsx+++ b/frontend/src/pages/agent-vault/AgentVaultProxiesPage/AgentVaultProxiesPage.tsx@@ -1,8 +1,10 @@import { ReactNode, useState } from "react";+import axios from "axios";import { format } from "date-fns";import {BanIcon,ChevronDownIcon,+ DownloadIcon,MoreHorizontalIcon,PencilIcon,PlusIcon,@@ -58,6 +60,7 @@ import {TooltipTrigger} from "@app/components/v3";import { useProjectPermission } from "@app/context";+import { downloadTxtFile } from "@app/helpers/download";import {getUserTablePreference,PreferenceKey,@@ -66,6 +69,7 @@ import {import { useResetPageHelper } from "@app/hooks";import {AgentVaultTrafficPolicy,+ fetchAgentVaultProxyCa,useDeleteAgentVaultProxy,useListAgentVaultProxies,useRevokeAgentVaultProxyAccess,@@ -139,6 +143,22 @@ const truncateFingerprint = (fingerprint: string) =>export const AgentVaultProxiesPage = () => {const { hasProjectRole } = useProjectPermission();const isAdmin = hasProjectRole(ProjectMembershipRole.Admin);+ // Asked of the server on every click, never cached: the CA changes on rotation, and only the server can+ // refuse a proxy that serves its own CA.+ const downloadProxyCa = async (proxy: TAgentVaultProxy) => {+ try {+ const ca = await fetchAgentVaultProxyCa(proxy.id);+ downloadTxtFile(`${proxy.name}-ca.pem`, ca.certificate);+ } catch (error) {+ const message = axios.isAxiosError<{ message?: string }>(error)+ ? error.response?.data?.message+ : undefined;+ createNotification({+ type: "error",+ text: message ?? "Failed to download the certificate authority"+ });+ }+ };const [sortColumn, setSortColumn] = useState(SortColumn.Created);const [sortDirection, setSortDirection] = useState<"ascending" | "descending">("descending");@@ -354,6 +374,19 @@ export const AgentVaultProxiesPage = () => {variant="ghost"size="xs"/>+ <Tooltip>+ <TooltipTrigger asChild>+ <IconButton+ aria-label="Download certificate authority"+ variant="ghost"+ size="xs"+ onClick={() => downloadProxyCa(proxy)}+ >+ <DownloadIcon />+ </IconButton>+ </TooltipTrigger>+ <TooltipContent>Download certificate authority</TooltipContent>+ </Tooltip></div>) : (<span className="text-muted">—</span>