# Security model

How Valakes keeps secrets in the main process, what it trusts, what it does not, and where its protections end.

Source: https://docs.valakes.com/security/

Last updated: 2026-11-25

This page describes how Valakes is built to protect your servers and your secrets, and where each protection stops. It is the short version of the app's security design. Each section says what is guaranteed by design and which limit remains. The [security FAQ](https://docs.valakes.com/security-faq/) answers the common questions one by one.

## Two zones

Valakes runs in two parts that do not trust each other equally.

- **The host zone** is the Electron main process. It holds the vault, opens the SSH connections, decides what an agent may do, checks commands, masks output and writes the audit log.
- **The view zone** is the window you see. It is sandboxed and is treated as something that could be attacked. It draws the terminal, the composer and the panels, and it receives names and metadata but never a secret.

No secret value flows from the host zone to the view. Values you type travel the other way: when you create or edit a credential, import a key or type a passphrase, or answer an SSH login prompt, the value goes from the window to the host once and is never sent back. The view is never trusted to decide risk, policy, which credential to use or which host you are on. The host works those out again from its own records.

## The window itself

The window is configured strictly from the first line of code, not added later:

- The renderer is sandboxed with context isolation on and Node.js integration off.
- The page loads from the app's own scheme, not from a `file:` address, and no remote content is allowed. Scripts may come only from the app's own files, and JavaScript `eval` is blocked.
- Navigation, new windows and embedded web views are refused. A link to the outside goes through the host, which shows you the address and asks before opening it.
- Every permission request is denied, and the window's session is in memory, so no cookies or storage reach the disk.
- Release builds flip the Electron fuses that make the app inert to `ELECTRON_RUN_AS_NODE` and similar switches.

The content policy of the window has two allowances, and both are written down. Styles may be inline, because xterm.js and React style attributes need it, while scripts may not. WebAssembly may be compiled (`'wasm-unsafe-eval'`), because the parser that reads your commands needs it; JavaScript `eval` stays blocked. The worst case of inline styles is a restyled interface, which is why the production markers are also checked in the status bar text.

Every request from the window to the host has a typed contract and a runtime schema check in the host, and the host verifies which frame sent it. There is no generic "run this" channel. A few paths sit outside that registry because they carry bytes, not requests: terminal data, the one-time secret submission and dropped file paths. Each has its own check.

## The vault

Saved credentials are encrypted at rest, decrypted only in the host zone at the moment of use, and shown everywhere else as `{{cred:name}}`. The key that opens them is wrapped by your operating system's store. [Credentials and auto-fill](https://docs.valakes.com/credentials/) describes how a value reaches a server without passing through the window, the history or any log.

## SSH host keys

Valakes always verifies the host key.

- **First connection:** the connection pauses and shows the fingerprint in the form `SHA256:` plus the key's hash. You compare it and choose Trust or Cancel.
- **Changed key:** the connection stops and shows the trusted fingerprint next to the new one. There is no "continue anyway" button in v1. To go on, you remove the entry in Settings, **Known hosts**, type the host pattern to confirm and accept a native dialog. The next connection is a first connection again.
- **Agents** cannot answer a host key prompt. On a key that is not trusted yet, their call fails and Valakes closes the session. You open the host yourself, compare the fingerprint and trust it, and then the agent can connect.
- Valakes never writes your `~/.ssh/known_hosts`. It can read that file, if you allow it, but its own list is separate.

The limit is the first connection. Valakes cannot know whether the first key it sees is the right one, so that comparison is yours.

## The agent API

The API for AI agents is built to be reachable only by the program you meant.

- It listens on `127.0.0.1` only, on a random port chosen at every start. The port is written to a file in the data folder.
- Every agent has its own token and handle. The token sits in a file only you can read, and it is never shown, copied or put in a snippet.
- The bridge program proves the server first. It sends a random value and checks the server's answer, an HMAC that only a program that knows the token's hash can produce, before it sends the token. A program that grabs the port after Valakes stops therefore does not receive the token.
- A request that carries an `Origin` header or a `Sec-Fetch-` header is refused, which every browser adds, so a web page cannot call the API. The `Host` header must be exactly `127.0.0.1:<port>`, which stops DNS rebinding, and there is no CORS.
- An agent uses ten tools. None returns a credential, changes a policy, approves a request, reads the audit log or reads known host keys. Those calls do not exist.

Each call then passes the same checks, in the host: which hosts the agent may see, which sessions are its own, the host's policy, a risk check on the command, approval where needed, and an audit entry before the command is sent. Output is masked before it leaves.

- **Policies** start at Off for every host. Read-only is an allow-list of read commands, not a sandbox, and the page on [how agents work](https://docs.valakes.com/agents/) says why.
- **Approvals** are bound to what you saw: the card carries a hash of the exact command, session and directory, and the host runs the stored command, never a resubmitted one. An approval is used once, and it lapses if the directory, the session or the policy changes while it waits.
- **The audit log** is hash-chained: it shows that entries have not been edited, reordered or cut from the end. It is tamper-evident, not tamper-proof.
- **The kill switch** turns the API off, cancels every approval, ends every share and closes the sessions the agents opened. It does not undo what a command already did.

## Masking

Before an agent reads output, Valakes replaces the stored values it knows (6 bytes or more) with `***`, also when they appear as base64, percent-encoded, hex, JSON-escaped or shell-quoted. For the built-in assistant a second pass removes common key formats. Masking is a best-effort filter. It cannot know a secret that is not in the vault, and it does not catch a value that the command's author transformed, for example reversed, compressed or split over several lines. The real protection against that is a server account with no access to anything that matters.

## Commands, production and files

- The [command check](https://docs.valakes.com/command-check/) reads what you typed. A host marked production is read from the host's stored record and never from what the server prints, so a server cannot make a production tab look like staging. A record that was tampered with is treated as production until you confirm it again.
- Valakes builds some queries itself: tab completion, the blast-radius count. Those are assembled from quoted arguments only, and text you typed is never evaluated by a shell on that channel.
- Files move only between the server and a few local places you add. Valakes refuses a drive root, your home folder, credential folders such as `~/.ssh` and its own data folder, so a slip or a compromised window cannot send your keys to a server. The check is on paths: a hard link that points out of a place is not detected. See [Files](https://docs.valakes.com/files/).

## What this does not protect against

| Control              | What it does not cover                                                                                |
| -------------------- | ----------------------------------------------------------------------------------------------------- |
| Vault encryption     | Code running as you inside Valakes. On Windows, a program running as your user can ask for the key.   |
| The agent token file | A process running as your user can read it, and so can use the token. Revoke an agent you stop using. |
| Masking              | A secret that is not in the vault, or a value that the command reshaped.                              |
| Read-only policy     | Reading what your server account can read: `cat ~/.ssh/id_ed25519` is a read command.                 |
| Command check        | Scripts, aliases, SQL read from a file, Raw mode, full-screen programs and nested shells.             |
| Host key check       | The first connection.                                                                                 |
| Kill switch          | A command already started under `nohup` or in `tmux` keeps running on the server.                     |

An external agent also sends what it reads, including command output, to its own model provider under that provider's terms, and Valakes cannot control that. Mistake prevention, the typed host name and the **Run anyway** button guard an honest user. A user who ignores the markers is a risk that remains.
