Skip to main content
An AI agent can be manipulated by what it reads, such as a web page, an issue comment, or an email. A dependency’s install script can also run code of its own. To leak a secret, the agent must be able to read it and to reach somewhere to send it. A Bunker limits both. Its Perimeter holds your credentials outside the Bunker and decides which services the agent can reach. This page sets up a Bunker so the agent gets only placeholders for the keys you keep in the Perimeter, never the real values.

What this protects against

  • An agent, steered by injected instructions, that tries to send a key to another host.
  • A malicious dependency that reads environment variables and files in search of secrets.
  • An agent that tries to widen its own access.

1. Keep each credential in the Perimeter

Open your Perimeter. Under Permissions, add the service from the Catalog and enter its credential there. Choose a named service over a generic connection: the Perimeter can judge individual requests only when it knows the service’s operations. Inside the Bunker, the agent gets a placeholder instead of the real value:
The Perimeter swaps in the real credential only for that connection’s exact HTTPS origin and position in the request. It refuses the placeholder anywhere else. See Credential substitution. Then remove any real keys from the workspace: .env files, shell profiles, and tool configuration. The agent can act as root inside the Bunker, because the sandbox user has passwordless sudo, and can read anything on the workspace.

2. Give each connection the narrowest access

On the Perimeter’s Bunkers page, set the Bunker’s access level for each connection:
  • Read only when the agent only needs to read.
  • Ask for changes you want to see first.
  • Allow only for operations you accept the agent running unattended.
Store narrowly scoped credentials too. A token limited to the repositories or resources the agent needs, such as a GitHub fine-grained personal access token, limits what an allowed connection can do. Prefer tokens that expire. The Perimeter refreshes OAuth tokens for you.

3. Connect only the services the agent needs

Your Bunker reaches the outside world only through its Perimeter. All TCP traffic and DNS lookups go through an encrypted tunnel to the Perimeter, which refuses any traffic that matches no allowed connection. UDP, ICMP, and IPv6 are dropped, and while Allow everything is off, the Perimeter refuses private and internal addresses. Perimeter setup also adds two connections: network, which reaches any host and is set to Ask by default, and package-registries, which reaches npm, PyPI, crates.io, and other package registries and is allowed by default. Package registries accept uploads, so turn package-registries off if the workspace holds sensitive files. Under Permissions, check that Allow everything is off, and allow a connection that reaches any host only if you need it. From inside the Bunker, list what the agent can reach:

4. Approve sensitive actions

With Ask, a request waits under Activity until you choose Allow once, Allow always, or Deny. A request that gets no answer within two minutes fails. The agent can read its own policy with perimeter policy show and request more access with perimeter policy propose. A proposal changes nothing until you approve it. Agents cannot propose changes to credentials, MCP tool pins, other Bunkers, or global settings.

Example: let an agent use a work email account

An agent that reads a work email account needs more care than most. Anyone who can email the account can send the agent instructions, and the inbox often holds password reset links and sign-in codes. Keep the email credential out of the agent’s reach, give the agent the narrowest access that does the job, and approve what it sends.

Connect Gmail

The Gmail connection signs in with Google, so the Perimeter stores a Google sign-in token instead of a password. You need the Tinfoil CLI on your own computer.
  1. On your own computer, run:
    Open the local address it prints. To sign in through Tinfoil’s Google app, open the Perimeter with the CLI.
  2. Under Permissions, open the Catalog and choose Gmail.
  3. Leave Google OAuth client ID and Google OAuth client secret empty to sign in through Tinfoil’s app, or enter your own Google OAuth client. Then choose Sign in with Gmail.

Connect another mail provider

For a provider that accepts an app password, add two connections from the Catalog: Email reads and manages the mailbox over IMAP, and Email sending sends over SMTP. Each asks for your address, an app password, and the server’s IMAP or SMTP URL. The Perimeter logs in to the mail server with the stored password and passes the session through. The password stays in the Perimeter, but an app password is not limited to the agent’s task.

Choose what the agent may do

On the Perimeter’s Bunkers page, set the Bunker’s access level for each email connection:
  • Read only if the agent only reads or summarizes. Sorting, labelling, and moving mail are changes, so they need Ask or Allow. Over IMAP, an ordinary fetch marks a message as read, which counts as changing mail, so with Read only the agent must fetch without marking messages read (IMAP BODY.PEEK).
  • Ask to allow reads and ask you before changes, such as sending. To let the agent sort mail without asking each time, choose Allow always the first time it sorts, which saves a rule; sends keep asking.
Each request that needs approval waits under Activity. A request that gets no answer within two minutes fails, so an agent that must send while you are away needs that access granted ahead of time. Grant only what you accept unattended.

Keep the agent’s model inside secure enclaves

The agent’s model reads the emails the agent passes to it. A vendor-hosted model receives them. To keep them inside secure enclaves, have the agent use Tinfoil Inference.

What the email setup does not protect against

  • Messages written to manipulate the agent. With read access, the agent reads every message it can reach, including those.
  • Sends you allowed. With Allow, the agent sends without asking.
  • What your mail provider sees. The provider handles your mail as it always does.

What this does not protect against

  • Use of an allowed connection. Allowing a connection lets the agent use it within your policy. An agent allowed to write to a repository can paste text into an issue there.
  • Secrets on the workspace. Anything you copy into the Bunker is readable by the agent.
  • What a connected service does with what it receives. The Perimeter controls what reaches a service, not what the service does with it.
  • Code sent to a vendor-hosted model. A coding agent that uses its vendor’s models sends your code to that vendor. To keep prompts inside secure enclaves, use Tinfoil Inference.
The full list is in the threat model.