# Vault, sign-in and secrets (/es/docs/browser/vault)

Credentials an agent can use without seeing them, and where the other secrets an identity names are kept.

An identity can keep a username, a password and a TOTP secret per site, only in the OS secret store (the macOS Keychain, the Linux Secret Service, or DPAPI-encrypted files on Windows):

```sh
turno-browser vault add school mail --url https://mail.example.com/login --username alice --totp
turno-browser vault list school
```

The password and the TOTP secret are asked with hidden prompts (or read from stdin). An agent then calls `browser_login` with the site name on that sign-in page: the tool fills the username, the password and the current one-time code without the agent seeing them, only on the origins given with `--url`, and hides the values from every later result. It then submits the form by default, and the result says so without the values. `turno-browser vault submit school confirm` makes it stop after filling, so the agent clicks sign in itself; an identity policy with `"autoSubmit": false` does the same and wins. A vault created before submitting became the default reads as `auto` too, even though its index says `confirm`: that was the old default, not a choice, so run `vault submit <id> confirm` again to keep it. See the threat model in [SECURITY.md](https://github.com/wimo-dev/turno/blob/main/SECURITY.md#the-credential-vault).

## Password fields and credentials [#password-fields-and-credentials]

A password or a one-time code never comes back to the agent, whoever typed it. A sensitive field is an input of type `password`, one whose `autocomplete` is `current-password`, `new-password` or `one-time-code`, or one named like a password or a code (`password`, `passcode`, `otp`, `totp`, `2fa`, `mfa`). Every page snapshot shows its value as `[sensitive field]`, the snapshot files an action writes to the workspace too, and the value is hidden from every later result, such as a script that reads it or the request that sends it. The agent cannot type into one: `browser_type`, `browser_fill_form` and key presses into a sensitive field are refused, and the error tells it to ask the person (with `browser_request_human`) or to sign in with `browser_login`. A [flow replay](/docs/browser/flows) types one only when its parameter is read from the secret store (`keychain:<item>`).

`browser_network_requests` and `browser_network_request` keep the names of credentials and show `[redacted]` for their values: the `Authorization`, `Proxy-Authorization`, `Cookie` and `Set-Cookie` headers (the scheme and the cookie names stay), and query parameters, form fields and JSON fields named like a token, a code, a session, a key, a secret or a password (`access_token`, `code`, `sid`, `api_key`, `client_secret`). A request saved to a file with `filename` is redacted the same way.

Values are matched as typed and in the usual encodings; one shorter than four characters is masked in snapshots only. A value the page hashes or encodes some other way, and what a screenshot shows, are not covered.

## Cookies and stored tokens [#cookies-and-stored-tokens]

The `storage` capability is on by default: the agent can list, read, set and delete cookies, localStorage and sessionStorage items, and save or restore the storage state. The values that keep an identity signed in read `[masked]`. A value is masked when any of these holds:

- the cookie is `HttpOnly`: the page's own scripts cannot read it, and sites put their sessions there;
- its name reads like a credential: `session`, `sess`, `sid` (`SID`, `__Secure-3PSID`), `token`, `auth` (`ESTSAUTH`, `auth_token`), `jwt`, `csrf`, `xsrf`, `login`, `logged_in`, `remember`, `sso`, `saml`, `oidc`, `secret`, `key`, `identity`;
- it holds a run that looks random, of 64 bits or more: session identifiers are random by design, so one under any name is caught.

The rule was measured on the cookies of 60 popular sites, signed out: it masks about three in four of them (HttpOnly 24%, a random value 41%, the name 9%), and what stays readable is consent flags, themes, locales, currencies and timestamps. The name rule alone catches 74 of 96 well-known session cookie names; the rest (`xs`, `li_at`, `ct0`, `d`) are HttpOnly or random, and the other two rules catch them. Analytics and advertising identifiers are masked too: the rule leans that way.

A cookie keeps its name, domain, path, expiry and flags. A JSON item keeps its layout, with only its tokens masked: `{"access_token":"[masked]","expires_at":1767225600}`. The storage state file `browser_storage_state` writes is masked the same way.

After every browser call the server reads the browser's cookies and the current page's web storage, and every masked value that looks random is hidden from every result, not only the storage tools': `document.cookie` through `browser_evaluate`, a response body, a console message, a page snapshot, a file a tool writes, the prompt of a [natural language action](/docs/browser/natural-language-and-captchas). A short or plain value (`none`, a date) is masked in the storage tools only, so the page text stays readable.

Writes keep working. A value of your own is written as given. A mask written back stands for the value it hides, in the same cookie (name, domain and path) or the same item and field only: `browser_cookie_set` with `[masked]`, an edited JSON item with its masked fields left as they were, and `browser_set_storage_state` with a masked file all keep the session. A mask anywhere else is refused, so a write cannot carry a value to another cookie or site.

What is not covered: a script (`browser_evaluate`, `browser_run_code_unsafe`) can transform a value before returning it (base64, reversed, split), which no redaction of the result catches; a screenshot or PDF shows what the page shows; a trace the agent starts with `browser_start_tracing` (the `devtools` capability) saves the network traffic, cookie headers included, to the workspace; and a response body saved to a file with `filename` that is not text is written as it is. Where that matters, an [identity policy](/docs/browser/policy) can turn `storage`, `evaluate` or `run_code` off (any policy turns `run_code` off), and `--caps` without `devtools` leaves tracing out. In [attach mode](/docs/browser/engines#attach-to-your-chrome) the storage tools are off by default: those are your own Chrome's cookies.

## Secrets [#secrets]

An `identity.json` never holds a secret. It names one as `keychain:<item>` (`proxy.password`, `act.key`, `captcha.key`), and so does a replay parameter (`--param password=keychain:<item>`). The value lives in the login Keychain on macOS, the Secret Service on Linux, or a DPAPI-encrypted file on Windows:

```sh
# asks with a hidden prompt, or reads stdin
turno-browser secret set proxy-password
# exits 0 when the item exists
turno-browser secret has proxy-password
# every keychain: reference in identity.json, and whether it is stored
turno-browser secret list
turno-browser secret remove proxy-password
```

Values are never printed and never passed as an argument. They are the same items `turno secret` uses, so with turno installed either command works. Sign-in credentials do not go here: they live in the vault above.

### On Windows [#on-windows]

Windows has no command line keychain like `security` or `secret-tool`, so each item (a vault credential or a `keychain:` secret) is a file in `%LOCALAPPDATA%\turno\secrets`, encrypted with DPAPI for your Windows user (the `CurrentUser` scope). Windows PowerShell 5.1, which every Windows 10 and 11 has, does the encryption: the value goes to it on stdin and comes back on stdout, never in a command line, and only the encrypted blob is written to disk. `turno-browser doctor` shows the folder in its `secret store` row.

- Only your Windows user can decrypt an item, and only on this machine unless your account has a roaming domain profile. A copy of the folder under another user or on another machine (a backup, a synced folder) does not open; set the items again there.
- Any program running as you can decrypt them, as on macOS and Linux. Admin rights are not needed, and neither are native modules.
- Each file carries its item name, and DPAPI binds the value to that name, so a file copied over another item's file does not decrypt.
- The items are not in Credential Manager. Credential Manager caps an item at 2560 bytes, which an OAuth record can pass, and has no credentials in an SSH session; these files have no size limit.
- Reading or storing a value starts Windows PowerShell: about 0.3 s on a GitHub Actions Windows runner, and a few seconds for the first start after the machine boots. Checking whether an item exists (`secret has`, `secret list`, `vault list`, `doctor`) only looks at the file.