# Security model

How AgenticMind protects secrets, isolates code, enforces node permissions, guards its API, and what to change before exposing a server.

Source: https://glamorous-boar.cloudvent.net/security/

---

AgenticMind is designed to run on your own machine with real API keys and real data. Its security model rests on a few rules applied everywhere.

## Secrets are references

- Configs store `{"$secret": "NAME"}`, never values. A literal value in a secret field is a validation error (`SECRET_LITERAL_VALUE`).
- Values resolve at run time from the environment (`.env`, which wins) or the workspace store (Settings → Secrets).
- The workspace store encrypts with **AES-256-GCM**, with the secret name as associated data. The key comes from `AGENTICMIND_SECRET_KEY` or `<data>/secret.key` (generated with mode 600). **Back up the key with the database**, or stored secrets cannot be read. No endpoint ever returns a value; forms show only whether a name is set.
- A node may resolve only secrets referenced in **its own config** (or delegated through handles wired into it), and only with the `credentials` permission (`SECRET_NOT_PERMITTED`, `SECRET_ACCESS_DENIED`).
- Resolved values are **scrubbed** from traces, errors and stored outputs; sensitive keys (`api_key`, `password`, `access_token`…) are redacted in summaries.
- Exports, GitHub commits and deployment files contain secret **names** only; tests assert no value appears in any exported file.

## Node permissions and trust

Every node declares permissions up front: `network`, `filesystem`, `database`, `subprocess`, `credentials`, `artifacts`, `memory`. Nodes get capabilities only through these: project files (`artifacts`), memory (`memory`), a storage folder (`filesystem`), secrets (`credentials`). Agent tools must need a subset of the Agent's permissions.

Trust is assigned from the providing distribution, never self-declared:

| Trust | Who | Runs |
|---|---|---|
| `core` | Built-in `agenticmind-nodes-*` packages | In-process |
| `community` / `private` | Installed node packages | Isolated worker processes, after an admin approves exactly the requested permissions |
| `verified` | Reserved until package signing exists | — |

Third-party code is **never imported into the platform process**. See [Node packages](/node-packages/).

## Sandboxed code

Code nodes and the Code Interpreter run in a fresh Docker container by default: no network, read-only filesystem, memory/CPU/process limits, all capabilities dropped, unprivileged user. The operator, not the graph, chooses the backend. `process` mode is for trusted code only and is not a security boundary. See [Code execution](/code-execution/).

## Network protections (SSRF)

- **Web Fetch** requires an explicit domain allow-list, blocks private and cloud-metadata addresses, and re-checks every redirect. (It does not defend against DNS rebinding between check and connect.)
- **S3 Loader** refuses endpoints resolving to link-local or metadata addresses.
- **MCP HTTP** targets may be localhost but not link-local/metadata; `/api/mcp` checks Host headers against an allow-list.

## Databases

Read-only twice: a `sqlglot` policy (one SELECT, known allowed tables, no denied functions, row cap) and read-only connections where the engine supports them. Use a read-only database role anyway. See [Databases](/databases/#the-read-only-policy).

## The API guard

- **Sign-in is off by default** (single local user), and every dev server and `compose.yaml` listens on **localhost only**. The API logs a warning at start-up while sign-in is off.
- One ASGI middleware covers every `/api` route, so new routes are protected by default.
- **Cross-site write guard** (always on, even with sign-in off): `POST/PUT/PATCH/DELETE` requests carrying an `Origin` or `Referer` must come from the page's own host or `AGENTICMIND_CORS_ORIGINS`. A web page in your browser cannot drive your local API.
- Uploads: type allow-list (no SVG), size limit, served as attachments with `nosniff`. Archives have zip-bomb limits.

## Accounts (when sign-in is required)

Set `AGENTICMIND_AUTH=required`:

- local accounts; the first account (created on the setup screen) is an admin; admins add people; roles `admin` and `member`;
- passwords hashed with scrypt and a per-password salt; unknown usernames take the same time as wrong passwords;
- 5 failed sign-ins per username or address in 15 minutes → `429` with `Retry-After`;
- sessions: random 256-bit token in an `HttpOnly`, `SameSite=Lax` cookie (named per port, `am_session_<port>`), only its SHA-256 stored, 14-day sliding expiry; password change or *Sign out other browsers* revokes other sessions;
- `AGENTICMIND_COOKIE_SECURE=1` behind HTTPS.

See [Settings and accounts](/settings/).

## Exposing a server: checklist

1. `AGENTICMIND_AUTH=required` and create the admin account.
2. Serve over HTTPS and set `AGENTICMIND_COOKIE_SECURE=1`.
3. `AGENTICMIND_BIND=0.0.0.0` only after the steps above.
4. Set `AGENTICMIND_MCP_TOKEN` and `AGENTICMIND_METRICS_TOKEN` if those endpoints are reachable.
5. Keep `AGENTICMIND_SANDBOX=docker`; keep `AGENTICMIND_LOCAL_DEPLOY` off unless every member may run containers.
6. Use PostgreSQL and back up the database together with the secrets key.

## Known gaps

No SSO/OIDC, MFA, password-reset email, personal API tokens, per-project permissions or audit log yet. The login rate limiter is per process. Declared node permissions other than `credentials` are not OS-enforced for core nodes; isolation for plugins on Windows relies on the separate process, scrubbed environment and secret scoping.
