Skip to content

Security model

To report a vulnerability, follow the security policy. Do not open a public issue.

Anchor uses server-side encryption. The Worker holds the root key and decrypts values to serve them. That is a deliberate choice: it is what makes references, imports, rollback and online key rotation work, and it lets CI read secrets with a plain bearer token.

Attacker Outcome
Gets a copy of the D1 database (export, backup, leaked dump) Sees metadata (users, project and secret names, audit events) and the PBKDF2 password hashes, which allow offline password guessing, but no secret values: those are AES-256-GCM ciphertexts under keys wrapped by a root key that is not in the database
Can write to D1 but not run the Worker Can grant themselves access (insert a session or token hash, change a role or a scope) and then read everything through the API, or point a secret back at an older version. The AAD only stops a ciphertext being moved to another secret, version, environment or project. Protect D1 write access like access to the Worker
Steals a service token Reads (or writes, for read-write) only the environments and folders in its scopes, until it expires or is revoked; every value read and every write is audited with the token’s id (listing names is not)
Steals a session Acts as that user until the session expires (7 days for the dashboard, 30 days for the CLI) or is revoked from the Account page
Steals an agent’s OAuth tokens Calls the MCP tools as that user within the app’s permissions until the refresh token expires (30 days) or the app is revoked on Account → Connected apps or the user’s password changes; if the agent and the thief both refresh, the grant is revoked
A malicious project member Limited to the member’s role and allowed environments; cannot read the audit log unless a project admin
Reaches a freshly deployed instance’s URL before its owner exists Becomes the owner: the first account created at /setup owns the instance. Nothing is stored yet at that point, but create the owner right after the deploy, and start over with an empty database if /setup says an owner exists that you did not create (see Troubleshooting)
Controls your Cloudflare account, or the Worker and its secrets Reads everything. Anchor cannot protect against the platform it runs on
  • Values are encrypted with AES-256-GCM through WebCrypto, with a fresh random 96-bit IV each time.
  • Each project has its own key (KEK), versioned; the root key wraps every KEK. See the key hierarchy.
  • Every ciphertext stores its algorithm and key version, and is bound by AAD to project, environment, secret and version. Since 0.4.0 the AAD (format 2) also binds the version’s value type and sensitive flag, so changing either column in D1 makes the value fail to decrypt instead of exposing a secret as plain config. Versions written before 0.4.0 keep format 1 and are always read as a sensitive string.
  • The value type and the sensitive flag are stored in plaintext next to the ciphertext, so a copy of the database shows which secrets are JSON, PEM, numbers and so on, and which are marked as non-sensitive. It does not show any value.
  • The root key is a Worker secret. It is never in source, wrangler.jsonc, logs, the database or test fixtures. Losing it loses every value: there is no recovery path by design.
  • Passwords: PBKDF2-SHA-256, 100,000 iterations (the workerd maximum), per-user salt.
  • Login is limited per address and email, not per account (0.5.3): 5 failed logins for one email from one address (an IPv6 /64 counts as one) lock that pair for 15 minutes, and 50 failed logins from one address lock the address for 15 minutes. Someone guessing elsewhere cannot lock the owner out, and the answer (including the 429) is the same whether the email exists or not. A successful login clears its pair; a password reset clears every lock on that email.
  • Sessions, service tokens, invite links and password-reset links are high-entropy random tokens with a type prefix (anc_s_, anc_st_, anc_inv_, anc_rst_). Only their SHA-256 hash is stored. Invite links last 72 hours, reset links 1 hour.
  • The dashboard session is an HttpOnly, Secure __Host- cookie. State-changing requests authenticated by cookie must carry the instance’s own Origin, or they are rejected (CSRF).
  • Service tokens are accepted only as Authorization: Bearer, never from a cookie.
  • A service token created with no expiry (0.4.0) is a standing credential: it works until someone revokes it, so a leak is not retired by time. Scope it narrowly, prefer read, and revoke it when it is no longer used. Revocation takes effect on the next request.
  • anchor login (0.4.0) uses a browser flow modeled on the OAuth device authorization grant. The CLI keeps a 256-bit device code (prefix anc_dc_, only its SHA-256 hash is stored) and polls; the person types the short code shown in the terminal on the dashboard’s /cli/login page and approves it. Since 0.5.3 the link carries no code (?code= is ignored), so a link someone sends cannot fill in their code for you. Only a dashboard (web) session sent as the cookie can approve or deny: a CLI session, even pasted into the cookie, and a service token are refused, so a stolen CLI token cannot mint more sessions. Requests expire after 10 minutes, a device code yields at most one session, and approvals, denials and the resulting login are audited. Residual risk, as with gh auth login: someone who starts a login and talks you into approving their code gets a session as you. The approval page shows the code, the client name, the IP and the request’s age; approve only a code you just saw in your own terminal.
  • AI agents connect over MCP (0.4.0) with OAuth 2.1: authorization code with PKCE S256, public clients registered dynamically, and approval on the dashboard by a web session sent as the cookie, like CLI logins. Access tokens (anc_oat_) last 1 hour and refresh tokens (anc_ort_) 30 days; authorization codes (anc_oac_) last 5 minutes and work once. Only their SHA-256 hash is stored. A refresh token rotates on every use, and presenting a used one (or a used code) revokes the whole grant, since someone else may hold a copy. Redirect URIs must be https: or a loopback address, and the approval page shows the app’s name and where it returns. OAuth access tokens work only on /mcp, and /mcp accepts nothing else, so a session or service token cannot be replayed there and an agent token cannot call the REST API. An agent acts as the approving user with that user’s roles, narrowed by its permissions: reading sensitive values needs secrets:reveal, granted only when the person ticks it, and each such read is audited. Residual risk: a value an agent reads enters the AI model’s context and may be kept by the AI provider. Revoking an app on Account → Connected apps, disabling the user, or changing or resetting their password stops it on the next request.

Every route calls one policy function before it touches data. It reads memberships and tokens from D1 on every request, so removal and revocation take effect immediately.

Principal Can
Instance owner / admin Everything: projects, users, invites, the instance audit log, every project’s secrets. Only owners can manage owners, and the last active owner cannot be demoted, disabled or deleted
Instance member Only the projects they are a member of
Project admin Environments, members, service tokens, key rotation and the project audit log, plus read and write secrets
Project developer Read and write secrets in the environments the membership allows
Project viewer Read secrets in the environments the membership allows
Service token Read (or read and write) secrets in its scopes, { environment, folder } pairs; a folder scope covers its subfolders

References and imports are authorized hop by hop: expanding ${prod:/db/PASSWORD} requires read access to prod:/db, and a forbidden target is a 403 whether it exists or not.

  • Append-only: a database trigger rejects every UPDATE and any DELETE of a row younger than 365 days.
  • Logged: logins (successful and failed), every value read (listing names without values is not logged), writes, deletes, rollbacks, permission and membership changes, token creation and revocation, key rotations, and approving, denying and revoking AI agents. Events from an agent carry via: "mcp" and its client id.
  • Every event has the actor (user or service token), IP address, user agent, time and target. Events never contain secret values or tokens.
  • A secret read that cannot be audited fails.
  • No end-to-end encryption. See the trust model above.
  • Only login is rate limited, and not per account. Limits are per address and email, so an attacker with many addresses (a botnet, or an IPv6 /48 with 65,536 /64s) can keep guessing one account’s password: the price of nobody being able to lock the owner out. Use a long, unique password, and add a Cloudflare rate-limiting rule on /api/v1/auth/login and the other anonymous endpoints; see Rate limiting.
  • Break-glass recovery leaves no audit event. It is a direct D1 update; see Break-glass recovery.
  • First-run setup is open until the owner exists. /setup asks for no token; the first account created there owns the instance. Create it right after deploying.
  • No SSO or MFA yet. Accounts are email and password.
  • Approving a code someone else sent you signs them in. CLI logins and agent approvals are phishable the way gh auth login is: the page shows the device, IP and age; type and approve only a code from your own terminal.
  • Any MCP client can register itself. Dynamic client registration is open (capped per IP and instance); the consent page names the app and where it returns, and nothing is granted until a signed-in person approves it.
  • Folder writers control what reaches a child process. The server stores any key name. The CLI (anchor run, dotenv export) and loadAnchorEnv skip reserved names (PATH, NODE_OPTIONS, LD_PRELOAD, proxies, ANCHOR_*, …) unless told otherwise (0.5.3); any other variable your program trusts is still theirs to set.
  • Plain http is opt-in. The CLI and the SDK refuse http:// except to localhost, 127.0.0.1 and [::1]; the SDK’s allowInsecureHttp: true lifts that, and with it the token travels in clear text. Neither client follows redirects.
  • Pre-1.0. Only the latest release gets security fixes.