---
title: "Security architecture"
---

# Security architecture

How Neural Inverse Govern isolates tenants, encrypts and signs data, keeps a tamper-evident audit trail and runs without internet access, and how to report a vulnerability.

This page is for security teams evaluating Neural Inverse Govern (Keystone). It describes how the system is built to protect your data; each section links to the page with the operating detail.

## Design principles

- **Self-hosted, air-gap first.** Govern runs on your infrastructure and is designed to make no calls to external services at runtime. See [Air-gapped installation](https://neuralinverse.com/docs/deploy/air-gapped/).
- **Server-side enforcement.** Model calls, MCP tool calls and agent-to-agent calls are decided in Govern's gateways. Checks inside client apps are a second line, because a modified client can remove them.
- **Fail closed.** An unreadable policy, a missing signing key, an expired manifest, an unavailable DLP scan or a failed audit write is a refusal, not a pass.
- **Audit everything.** A change whose audit entry cannot be written does not happen.

## Tenant isolation

Every organisation's rows share one PostgreSQL database, and the database itself keeps them apart, independently of the application's own query filters.

- **A runtime role without privileges to bypass isolation.** The server's tenant traffic runs as `keystone_app`: no superuser, no `BYPASSRLS`, no DDL, no `TRUNCATE`, and it owns nothing, so it cannot turn row-level security off. The server refuses to start on any other kind of role.
- **Row-level security on every tenant table**, enabled and forced, with a policy that compares the row's organisation with the organisation the statement runs as.
- **No escape when the context is missing.** If the organisation is not set, the policy function raises an error. Code without a tenant context fails on tenant tables instead of seeing every row.
- **Named exceptions.** Statements that must span organisations run on a separate `keystone_platform` connection, from a short list of named, justified call sites.
- **Checked at start and in CI.** Every table has a recorded tenancy decision. The server refuses to start, and the build fails, while any table's state does not match its decision.
- **Request scoping.** Organisation ids in the path, query, headers and top-level JSON body are confined to the caller's own organisation.

## Identity and sessions

- Passwords are hashed with bcrypt. TOTP secrets, LDAP bind passwords, social sign-in client secrets and webhook signing secrets are encrypted at rest with AES-256-GCM under deployment keys. API keys, OAuth authorisation codes and refresh tokens are stored only as HMAC-SHA256 digests with a deployment pepper.
- Access tokens last 15 minutes by default. Console sessions end after 1 hour idle and 12 hours at most.
- Forwarding headers are believed only from proxies the operator lists, so clients cannot choose the address used for rate limits, lockouts and audit.
- Least privilege, just-in-time access, break-glass and access reviews are described in [Identity and access](https://neuralinverse.com/docs/govern/identity/).

## Encryption and key management

- **Key hierarchy.** A deployment master key (`KMS_MASTER_KEY`, kept outside the database) seals each organisation's versioned encryption keys. Those keys wrap per-object 256-bit data keys, and data is encrypted with AES-256-GCM.
- **Secrets are write-only.** AI provider keys and other credentials are held in Govern's vault and are never returned by the API; responses show only a hint, a version and the rotation time.
- **Sealed records.** Gateway request logs and cached model answers are sealed under the organisation's encryption key.
- **Signing.** Policy and configuration delivered to machines (agent policy, model access, MCP and skill manifests) is signed with Ed25519, and clients verify it against public key sets published under `/.well-known/`. Audit checkpoints, exports and cold segments are signed with the audit signing key, published at `/.well-known/keystone-audit-keys.json`.
- **In transit.** The data-plane TLS policy requires TLS 1.2 at minimum and prefers TLS 1.3, with mutual TLS between data planes and the control plane. In the Docker Compose stack, TLS is terminated by your reverse proxy.
- **FIPS 140-3 mode.** The server can use Go's FIPS 140-3 cryptographic module when it is built and run with the module enabled. With `KEYSTONE_FIPS140=required`, the server refuses to start unless the module is on, and it runs known-answer tests of its algorithms at start. Whether this meets a validation requirement is for you and your assessor to decide.

## Outbound requests

Govern refuses to send requests to tenant-supplied URLs that resolve to loopback, private, link-local, carrier-grade NAT or cloud metadata addresses, checked when the connection is made, so DNS answers that change later and redirects cannot reach them either. Only the operator can open specific internal networks.

## Data loss prevention

DLP runs on every model gateway prompt (and on answers when an organisation turns on output DLP), on agent-to-agent traffic in both directions, on MCP tool calls, context sources and audit client events, with built-in and custom patterns. The action follows the data's classification: redaction at lower classifications, refusal at confidential, restricted or regulated. See [AI gateway and model access](https://neuralinverse.com/docs/govern/ai-gateway/).

## Audit chain

The audit log is append-only and chained with HMAC-SHA256 per organisation. Chain heads are sealed every minute into Merkle epochs signed with Ed25519, and signed checkpoints are made every five minutes, so even someone with the HMAC key cannot rewrite one organisation's history unnoticed. Exports are signed and verify offline with `keystone-audit-verify`. Archived entries can sit under S3 Object Lock in compliance mode, and Govern has no operation that deletes them. See [Audit log](https://neuralinverse.com/docs/govern/audit/).

## Agents on developer machines

Agent policy reaches machines as an Ed25519-signed manifest. The endpoint agent rejects a manifest that does not verify or is older than the one it holds, denies every action once the offline grace period has passed, and denies on any internal error. How much this controls inside each third-party tool is stated per tool in [Third-party AI coding tools](https://neuralinverse.com/docs/govern/third-party-tools/).

## Report a vulnerability

Email **security@neuralinverse.com**. Do not open a public issue.

Please include a description of the vulnerability, steps to reproduce or a proof of concept, the affected versions, and what an attacker could achieve. Our process, response times and safe harbour are on the [vulnerability disclosure page](https://neuralinverse.com/trust/vulnerability-disclosure/).

In scope are, among others: authentication bypass or privilege escalation, token or session leakage or forgery, injection and SSRF, cross-tenant data access or sandbox escape, AI agent authorisation or policy bypass, governance bypass (DLP, secrets scanning, code review gates), and audit log tampering or HMAC chain bypass.
