Skip to content

Auth & Security ​

The security model assumes a single-machine local service: bound to 127.0.0.1, every request passes host/origin guards first, then Profile tokens and roles. Keys are encrypted at rest; reports and tokens use HMAC with constant-time comparison.

Entry guards ​

  • Host header allowlist: only 127.0.0.1 / localhost accepted; anything else gets 403 forbidden_host — blocking DNS-rebinding attempts to expose the local service to web pages.
  • Origin allowlist: self origins + dev ports (5178/5179) + 8787; cross-origin requests are rejected.
  • bodyLimit: request-body caps enforced at middleware, so oversized uploads cannot take the host down.
  • Internal error detail stays in the host log (correlated by requestId); responses never leak stack traces.

PIN and Profile tokens ​

PIN: derived with scryptSync(pin, salt, 32) and compared via timingSafeEqual; resetting the PIN bumps token_version + 1, invalidating every issued token immediately.

Profile tokens (ProfileAuth):

text
token = base64url(payload) + "." + HMAC-SHA256(payload, secret)
payload = { sub, iat, exp, jti, ver }
  • The secret is randomBytes(32), stored encrypted in a system.db setting (key file in Providers & Routing); if a backup restored on another machine cannot decrypt it, a fresh secret is minted and profile_tokens cleared — old device tokens die, data is untouched, unlock again.
  • TTL = max(1, profileTokenTtlHours) × 3600 (default 12 hours).
  • profile_tokens keys on jti, recording issued/expires/revoked/user_agent/ip/last_seen; last_seen updates lazily (at most once a minute), and bookkeeping failure never fails a request.

Five verify gates: signature timingSafeEqual → exp not expired → Profile exists → ver matches current token_version → jti not revoked. Any failure returns null.

Device management: listTokens lists devices; revokeDevice(jti) revokes one; rotate / revoke bump the version and revoke all; POST /api/v1/auth/tokens/:jti/revoke serves the UI.

Identity binding and roles ​

  • profileOf trusts only the Profile bound to the verified token; a client x-ifg-profile header mismatching the binding → 403. A header alone never grants identity.
  • Dev mode IFG_REQUIRE_PROFILE_TOKEN=0 lets scripts pick a member Profile by header; naming an admin requires a verified token, else 403.
  • Admin-only: provider/route edits, probes, provider deletion, retention, background jobs, audit export; members may only rotate private-provider keys. The shared library's use/edit/admin levels are in Shared Library & ACL.

Keys, signatures and egress ​

SurfaceMechanism
Provider keysAES-256-GCM at rest, master.key 0600; APIs return only hasKey
Reportssha256 hash + HMAC-SHA256 signature, verified with timingSafeEqual (Scoring & Reports)
WebSSRF guard + per-hop redirect re-checks (Capabilities)
Code executionseatbelt / resource-limited sandbox (Code Sandbox)
Egressegress / capability_routes ledgers: who, when, to where, at what cost

Audit ​

Three audit lines, none substituting for another: system-level audit (admin actions, key rotation, Profile add/remove), shared-library shared_audit (per action), and tool-level tool_calls + tool_approvals (MCP approval and calls). CSV exports resolve actor names server-side, so clients cannot forge identity.

Structure at a glance ​

Figure 1 · Three gates before a request reaches a route

Local-first · inference egresses on demand · fully traceable