# Security model

> Ring 0–3 capabilities, four physical redlines, the blind-injection vault, human approval and mutation audit.

Security in Kernuq is not a sentence in a prompt; it is a physical boundary in kernel space.

## Four Ring 0 redlines

1. **`ui://rom/*` and `kernel_mutation_logs` are physically read-only.** No agent can tamper with the factory views or the audit trail.
2. **Zero plaintext vault reads.** `vault://` uses AES-256-GCM envelope encryption and is blind-injected into execution only in Ring 0.
3. **Sandboxed widgets are offline by default.** Agent-built ESM widgets run in isolated iframes with `connect_allowlist: []`; the RPC allowlist never includes `vault.*` or `system.*`.
4. **Humans approve the dangerous.** Destructive deletes, production writes and privilege escalation require a HITL `approval` event.

## Capabilities only narrow

Ring 0–3 capabilities can only shrink along a delegation chain — a child agent never gets more than its parent. `governance.limits` also caps spawn depth and fan-out to stop fork bombs:

```yaml
governance:
  limits:
    default_ttl: 16
    max_spawn_depth: 5
    max_fan_out_concurrency: 32
  hitl_approval:
    require_approval_for:
      - "tool://builtin/bash:write_or_network"
      - "budget_exceed_usd:10.0"
```

## Master key

The vault KEK lives in the OS keychain by default, with an environment-variable fallback:

```yaml
governance:
  vault_kek:
    provider: "os_keychain_with_env_fallback"
    env_var: "KERNUQ_MASTER_KEK_B64"
```

## Audit and rollback

Every write from the UI, API or MCP lands in `kernel_mutation_logs` with its `batch_session_id` and redacted before/after diffs, and broadcasts `kernel.entity.mutated`. Any batch can be rolled back atomically with `audit.rollback_batch`.

## Network exposure

The daemon listens only on loopback and OS-protected local pipes by default. LAN (mDNS) and internet (outbound-tunnel Magic Links) access must be enabled explicitly — see [Deployment](/en/docs/deployment/).
