AIFeed

How we secure Figma's multiplayer agent platform

Original text(via Hacker News)

Figma has long used sandboxing

A millipede gets into a castle by going up through the drain into a pit with spikes. The pit stops it from getting out.
A millipede gets into a castle by going up through the drain into a pit with spikes. The pit stops it from getting out.

Server-side sandboxing: An introduction

In this three-part series, our security engineering team shares practical tips for deploying and operating application sandboxing techniques. First up: evaluating the many sandboxing options, and how to think about the trade-offs between them.

The Figma design agent is here

Starting today, work with an agent that is built for Figma—directly on the canvas.

While we need to give an agent’s sandbox real authority to be useful, we also need to make sure it’s limited in what it can read, change, or disclose. Here’s how we secured Figma’s multiplayer agent sandbox platform by keeping every agent’s authority narrow, isolated, and enforced outside its sandbox. We’ll cover the credentials agents hold, what those credentials allow, where data can go, and how we keep collaborators’ authority separate.

Building agents for multiplayer files

In a multiplayer file, multiple editors and their agents collaborate on the same canvas and code. In Figma Make

Abstract digital art with colorful rays, code-like text, maroon spiked circles, and orange dots, modern style.
Abstract digital art with colorful rays, code-like text, maroon spiked circles, and orange dots, modern style.

Prompt, prototype, perfect: Figma Make is now available to all users

Today, all Figma AI features and products are moving out of beta, including Figma Make—which is now available for everyone to try. Here’s how teams are using the prompt-to-app tool to dream bigger, move faster, and work better together.

Illustrated sandbox factory with workers inside glass spheres moving along conveyor belts as an operator manages the system.
Illustrated sandbox factory with workers inside glass spheres moving along conveyor belts as an operator manages the system.

How Figma manages sandboxes at scale

Figma’s AI products require tens of thousands of sandboxes to run untrusted code safely. That’s why we built Nimbus: a platform that makes sandboxes fast, reliable, and easy for Figma product teams and operators to manage.

That leaves two threats for us to control:

  • A misaligned agent that acts against its own user’s intent through mistakes, bugs, or prompt injection—for example, uploading a file to a public file-sharing service while trying to help.
  • A malicious collaborator trying to use shared file content to reach another editor’s credentials or connected tools.

Controlling what an agent can do

The first threat we focused on is agent misalignment. Since a misaligned agent can run arbitrary code inside its sandbox, we limit its capabilities and enforce authorization in trusted infrastructure outside the sandbox.

Least privilege is the principle of granting a user, process, or service only the minimum permissions needed to perform its intended task.

Multi-tenancy is an architecture where shared infrastructure serves multiple users while keeping their data and workloads isolated.

How agents use those capabilities changes how we think about least privilege. When trying to finish a task, agents will systematically probe every credential they can read and every API they can reach. Least privilege used to serve as a guardrail around deterministic application code in multi-tenant systems, but now it’s a hard requirement for agent systems, which tend to exhaust whatever capabilities they’re given.

Scoping agent credentials with FigJWTs

To do useful work, an agent needs to act on a user’s behalf by calling a model provider through our AI gateway or invoking a connected tool through its Model Context Protocol (MCP)

Abstract illustration of interlocking organic shapes in purple and orange on a dark green background.
Abstract illustration of interlocking organic shapes in purple and orange on a dark green background.

The TL;DR on MCP: Why context matters and how to put it to work

Figma’s MCP server brings your design decisions into the tools where code gets written—so what gets built actually matches what was designed. Here’s what that unlocks for everyone who builds products.

We achieved this with a credential we called the FigJWT, a signed JSON Web Token issued by our trusted backend services. A FigJWT works with standard authentication headers while expressing who the agent acts for, which workload it runs, and which file it can access. Figma’s AI gateway and other receiving services validate the FigJWT on every request and decide whether to authorize the action.

As we built more agent experiences, FigJWTs became the canonical way for sandbox workloads to reach our services. After a few months of organic growth, though, sandboxes with very different needs were sharing the same broadly capable token. An agent that needs LLM inference doesn’t necessarily need external tools, and two workloads calling our backend rarely need the same routes.

To tighten permissions without breaking live workflows, we instrumented consuming services to log which capabilities each FigJWT actually exercised. That telemetry showed where we could narrow access—for instance, the sandbox that builds cached Make previews only needed backend requests and never needed LLM inference, so its token could be restricted to those operations alone.

From there, we introduced token profiles and a set of granular capabilities to grant each profile. AgentControl, the service that coordinates agents, mints a FigJWT for each prompt with a profile identifying the workload’s permission set.

AgentControl mints a FigJWT for the untrusted sandbox, which runs the agent harness and agent- and user-written code. The sandbox sends requests to the trusted AI gateway, which checks the user named in the token and the profile's capabilities (such as llm, mcp, and backend) before routing to LLMs, connected tools through the MCP proxy, and the Figma backend.
AgentControl mints a FigJWT for the untrusted sandbox, which runs the agent harness and agent- and user-written code. The sandbox sends requests to the trusted AI gateway, which checks the user named in the token and the profile's capabilities (such as llm, mcp, and backend) before routing to LLMs, connected tools through the MCP proxy, and the Figma backend.

Example FigJWT claims (abbreviated):


        {
  "sub": "user_123",
  "fileKey": "file_abc",
  "tokenProfile": "make-generic",
  "exp": 1767225600
}
      

Because the token is signed by the trusted issuer, code inside the sandbox can present it but can’t alter its claims or edit a local config to grant itself extra permissions. Consuming services enforce those profiles outside the sandbox using YAML policies. In its simplified form, the AI gateway maps each profile to its allowed capabilities:


        profiles:
  make-generic:
    ai_gateway: [llm, mcp, backend]
  make-cached-preview:
    ai_gateway: [backend]
      

With this policy, cached-preview tokens cannot authorize inference or MCP requests. Access to Figma’s backend, Sinatra, is further narrowed by route policies—allowing the cached-preview profile on the thumbnail route, for example:


        POST /api/internal/make/:file_id/thumbnail:
  - make-cached-preview
      

Tightening permissions on live workflows required a careful rollout. We ran new policies in shadow mode first, checked which real requests would’ve been blocked against each agent’s intended capabilities, and gradually enabled enforcement behind feature flags.

Limiting file access in the permissions system

To support Figma’s editing workflows, agents need to read and modify Figma files through our internal APIs. Because an agent acts on a user’s behalf, those permissions can span every file in the user’s plan—far broader than the single file an agent needs to access while working with a user. If a misaligned agent is steered off course by untrusted file content or makes a mistake, file scope limits its Figma API access to the active file.

Highlighting the path from the untrusted sandbox through the trusted AI gateway to the Figma backend API routes, this flow illustrates how file scope restricts access. Under the permissions check, a token scoped to file A cannot read or change file B, even if the user owns both, and the user's own permissions still apply.
Highlighting the path from the untrusted sandbox through the trusted AI gateway to the Figma backend API routes, this flow illustrates how file scope restricts access. Under the permissions check, a token scoped to file A cannot read or change file B, even if the user owns both, and the user's own permissions still apply.

We originally enforced file scope inside individual endpoints, but those checks left a gap. An endpoint could confirm that an agent’s token was scoped to file A, then call a helper that checked the user’s permission on file B. Because the user could access file B, the helper check succeeded even though file B was outside the token’s scope. We considered requiring every endpoint to declare whether it needs a file-scoped token, but that wouldn’t have closed the gap in shared helpers.

Two flows compare where a token scoped to file A is checked. In "Check in each endpoint," the endpoint passes file A, but a helper sees the user can open file B and returns file B outside the token's scope. In "Check in the permissions system," the file scope travels with the user's identity, so when the helper asks about file B, it is correctly denied.
Two flows compare where a token scoped to file A is checked. In "Check in each endpoint," the endpoint passes file A, but a helper sees the user can open file B and returns file B outside the token's scope. In "Check in the permissions system," the file scope travels with the user's identity, so when the helper asks about file B, it is correctly denied.

Instead, we moved file-scope enforcement to our pre-existing centralized permissions system, which uses the permissions DSL we’ve written about before

On the left (Fig. A) showing a purple line scribbled in a roundabout way, and on the left (Fig. B), a much cleaner, circular spiral.
On the left (Fig. A) showing a purple line scribbled in a roundabout way, and on the left (Fig. B), a much cleaner, circular spiral.

How we built a custom permissions DSL at Figma

When our permissions system came apart at the seams, everything came to a halt. This is the story of how we fixed it while improving performance, accuracy, and developer ergonomics.

For example, this policy denies all file permissions when a FigJWT is scoped to a different file:


        class DenyAccessToOtherFiles extends DenyPolicy(PolicyResourceType.FILE) {
  applyFilter: ExpressionDef = and([
    [FigJwtClaims.fileKey, '<>', null],
    [File.key, '<>', { type: 'field', ref: FigJwtClaims.fileKey }],
  ])

  permissions = getAllPermissionsForResource(FilePermission)
}
      

If the token is scoped to file A, this policy denies access to file B, even when the user owns both. File scope only narrows a user’s existing Figma file permissions; separate controls govern what an agent can do through connected tools.

Controlling where data can go

A misaligned agent can also send data somewhere the user never intended. After ordinary requests to export assets, we saw agents try to upload files to public file-sharing services to give the user a link. Nobody was attacking the system—the agents were trying to be helpful—but this underscored why we couldn’t rely on intent alone to control egress.

We saw the same pattern with coding agents on our own engineers’ laptops. While working on routine tasks, agents searched home directories for private keys, suggested piping remote install scripts straight into a shell, and in one case, printed service credentials into a transcript while debugging. Prompt instructions telling agents to inspect scripts before running them didn’t hold. Just as our security teams needed external controls on laptops to restrict file access and flag risky commands, we needed to enforce outbound network controls outside the agent’s sandbox.

A trusted egress proxy outside the sandbox enforces network policy between the untrusted sandbox, the AI gateway, and other internet hosts. Its default policy sends request bodies only to allowlisted hosts like package registries, limits other hosts to GET, HEAD, or OPTIONS with no body and URLs up to 10 KB, and lets admins turn internet access off.
A trusted egress proxy outside the sandbox enforces network policy between the untrusted sandbox, the AI gateway, and other internet hosts. Its default policy sends request bodies only to allowlisted hosts like package registries, limits other hosts to GET, HEAD, or OPTIONS with no body and URLs up to 10 KB, and lets admins turn internet access off.

By default, Make and Figma agent sandboxes can send a request body only to hosts on their allowlist, such as package registries for pulling code dependencies. Requests to all other hosts are limited to GET, HEAD, or OPTIONS with no body and URLs capped at 10 KB—enough for read-only actions like web search and reading documentation, while blocking agents from uploading files to arbitrary servers.

In practice, these restrictions keep agents “on the rails,” but read requests can still leak small amounts of data per request through their URLs and headers. For Make and the Figma agent, organization admins who want stricter isolation can disable general internet access in the admin panel and only allow the hosts they choose and the small set of hosts agents need to operate.

Finally, we bound how long an agent can act. AI gateway FigJWTs expire after two hours, and sandbox lifetimes cap how long the environment itself stays alive.

Isolating credentials between collaborators

Coding agents face a similar isolation problem: Collaborators work on a shared code repository, but each agent runs in its user’s own environment with access to their filesystem and credentials. In Figma, the shared state lives in a multiplayer file, and we give each user their own sandbox for that file.

The second threat we focused on is a collaborator using shared state in multiplayer files to reach another user’s authority: stealing their tokens, acting as them through connected tools, or accessing and exfiltrating their data.

It’s tempting to think a shared file should have a shared sandbox. Much of Figma’s infrastructure is multi-tenant: For example, our multiplayer service handles many users’ files in a shared, memory-safe service, and other services execute untrusted code in sandboxes such as nsjail. Agent sandboxes are different because they execute arbitrary code that collaborators can share and change, while also needing credentials and broader authority to act on the user’s behalf. If collaborators shared a sandbox, that code could read credentials from the shared environment and act as another user.

A shared Figma file feeds separate untrusted sandboxes for Editor A and Editor B, each with its own agent harness, FigJWT, and trusted egress proxy. Both proxies connect to the AI gateway, which checks each request's FigJWT to use that editor's OAuth MCP connections and file access, so every request carries its own editor's authority.
A shared Figma file feeds separate untrusted sandboxes for Editor A and Editor B, each with its own agent harness, FigJWT, and trusted egress proxy. Both proxies connect to the AI gateway, which checks each request's FigJWT to use that editor's OAuth MCP connections and file access, so every request carries its own editor's authority.

With separate sandboxes, agents can still collaborate on and commit changes to the same file using user-specific credentials. Every request draws from the driving user’s file permissions and credit budget, attributes file changes to that user, and stays bound by the permission and network controls above. The same separation applies to connected tools: For MCP servers that use OAuth, our AI gateway looks up the connection belonging to the user in the FigJWT, so an editor’s agent can only ever use that editor’s own OAuth connections.

Even with isolated sandboxes, editors can modify shared file contents that another editor’s sandbox will later load and run. Therefore, we need to carefully consider when a sandbox receives credentials and provide them just in time, as the user prompts the agent to act on their behalf.

In Figma Make, when a collaborator with edit access opens a file, we provision a sandbox so they can build and preview the application right away, but opening a file shouldn’t let collaborator-written code trigger LLM inference or MCP calls on their behalf. Instead of injecting those credentials when the sandbox starts, we supply them just in time with each user prompt.

Binding FigJWTs to their sandbox

Isolating sandboxes keeps collaborators’ credentials separate, but a plaintext token inside a sandbox is still portable. Whether a FigJWT leaks through shared state or an agent mistake—or is copied out deliberately by a user—anyone holding it could authenticate to our AI gateway as that user and invoke their connected tools while the token remains valid.

Inference access has become a hot target for abuse across the industry, with copied credentials used to access models and resell access through proxy services—a pattern often called “LLMjacking.” In our initial design, we exposed FigJWTs to sandboxes in an environment variable because we built on vendor infrastructure to move fast, and our sandbox providers didn’t yet support routing outbound HTTPS traffic through our own egress proxy. Over time, we noticed a pattern of new Figma accounts creating a Make file, copying FigJWTs from their own sandboxes, and reusing them outside the product against our AI gateway. Short token lifetimes and plan spend limits enforced by the AI gateway bounded each token, but rotating through new accounts and tokens still let that reuse continue.

We needed FigJWTs that only worked from the sandbox they were issued to. Since code inside the sandbox only needs to attach the token to outbound requests, it didn’t need access to the plaintext token at all.

To make that happen, we worked with our sandbox providers to route all outbound HTTPS traffic from sandboxes through our own egress proxy. Before delivering a FigJWT to a sandbox for model and tool calls, we encrypt it. The agent sends that encrypted token in its normal authentication header, and as the request leaves the sandbox, our external egress proxy decrypts it and swaps in the plaintext FigJWT before forwarding the request to the AI gateway for validation. Because the proxy runs outside the sandbox container, code inside the sandbox can’t inspect the plaintext token, tamper with the proxy, or alter its policy.

To stop copied tokens from working elsewhere, we bind each encrypted FigJWT to a single sandbox using authenticated encryption (AEAD), passing a sandbox-binding value from trusted infrastructure as associated data. Code inside the sandbox can’t change the binding value its proxy uses. If someone copies the encrypted token into another sandbox, that sandbox’s proxy has a different binding value and decryption fails, and sending it straight to the AI gateway fails too, because the ciphertext isn’t a valid FigJWT.

Before, a FigJWT in a sandbox environment variable could be copied out and accepted by the AI gateway until it expired. After, the token is encrypted and bound to its sandbox: its proxy decrypts and swaps it for the AI gateway, while a token copied to another sandbox fails decryption and one sent straight to the gateway fails as not a valid FigJWT.
Before, a FigJWT in a sandbox environment variable could be copied out and accepted by the AI gateway until it expired. After, the token is encrypted and bound to its sandbox: its proxy decrypts and swaps it for the AI gateway, while a token copied to another sandbox fails decryption and one sent straight to the gateway fails as not a valid FigJWT.

Once we rolled out encrypted, sandbox-bound tokens, the copied-token abuse stopped—and it hasn’t come back. Code running inside the original sandbox can still make authenticated requests, bounded by the workload, file-scope, and egress limits described earlier.

What we learned, and what’s next

Building a collaborative agent platform turned out to be as much an infrastructure security effort as a product one. Enabling agents to work safely in multiplayer files required solving problems across sandboxing, credentials, permissions, and networking—and bringing infrastructure, product, and security teams together to adapt patterns we already knew worked. Network filtering we had built for Figma’s training environment shaped our agent egress controls, our capability policies mirror IAM-style workload permissions, and our authorization telemetry resembles CloudTrail-style logging for understanding how agents exercise their authority.

Everything we’ve described was built within the constraints of a monolithic agent architecture. Today, the agent harness still runs inside the sandbox alongside generated code, which means the sandbox has to hold authority that the generated code itself doesn’t need.

Learn more about life at Figma, and browse our open roles.

Our next step is to give untrusted code less authority to begin with by moving the harness out of the sandbox, following what Anthropic calls “decoupling the brain from the hands.” Separating the harness from the sandbox where generated code runs builds on the same principle that guided the rest of our design: keeping credentials and permission enforcement outside untrusted environments.

Thank you to the Sandbox and Agent Platform teams and the infrastructure and security engineers across Figma who collaborated on this work. It was made possible by Adil Ahmed, Ava Dordi, Bashar Al-Rawi, Carl He, Catherine Han, Chen Luo, Dylan Visher, Emre Unal, Frannie Zlotnick, Ian VonSeggern, Jim Myers, Jordan Rodgers, Pratik Agarwal, and Reid Draper.

The text above was extracted automatically from the source page and may miss images, tables or code blocks. The original is authoritative.

Published by Hacker News
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗