Yabanin Security Posture
This page is the entry point to Yabanin's security model: who can authenticate through which surface, how secrets are stored, where the policy pipeline fits as a control layer, and how the supply chain is guarded. Detailed findings and the threat-model history live in security-audit.md; the OWASP Top-10 for LLM Applications mapping lives in security-owasp-llm.md.
Authentication surfaces
| Surface | Credential | Mechanism | Code |
|---|---|---|---|
| Admin console (local) | email + password | bcrypt (cost 12) hashes; a login attempt always burns bcrypt work (timing-equalized); HMAC-signed session cookie with expiry + issued-at | pkg/adminauth/auth.go, pkg/adminauth/hash.go |
| Admin SSO — OIDC | upstream IdP | Authorization Code + PKCE (S256), state CSRF token, nonce, fail-closed user mapping | pkg/adminauth/oidc.go, sso-oidc.md |
| Admin SSO — SAML 2.0 | upstream IdP | ACS endpoint, signed AuthnRequests, process-local assertion replay cache (see SAML limitations) | pkg/adminauth/saml.go, sso-saml.md |
| SCIM 2.0 provisioning | org-scoped bearer token | mounted on the public router under its own bearer guard (never the admin session); token lookup by SHA-256 (unique index, no secret comparison in SQL) + constant-time compare | services/admin/handlers/scim.go, pkg/adminstore/scim.go |
| Gateway JWT auth | external JWT | keys selected by kid from the deployment-configured JWKS only; iss/aud/exp/nbf enforced; the org claim becomes the request's org context and the key-label claim becomes locked key labels; symmetric keys planted in the JWKS are rejected; with an unreachable JWKS the gateway fails closed (503, bounded staleness) | pkg/gateway/auth_jwt.go |
Gateway API keys (yb_…, ybs_…) | bearer key | stored SHA-256-hashed; resolved through a Redis cache keyed by sha256(plaintext) with HMAC-signed entries (CacheSigner) — a Redis attacker cannot forge a resolve result | pkg/auth/resolver.go, pkg/auth/sessionkeys.go |
Agent keys (yag_*) | bearer key | same hashing; agent-principal semantics (tool calls, budgets, task tags) | pkg/auth/agentkey.go, agent-governance.md |
| EE session validation (internal) | shared internal token (X-EE-Internal) | POST /auth/ee/session: the enterprise backend relays the browser's raw Cookie header and receives a fail-closed verdict (valid/subject/expires_at) computed by the SAME validation path as the admin middleware; route not mounted (404) unless EE_INTERNAL_TOKEN is set | services/admin/handlers/auth_ee.go, pkg/adminauth/auth.go |
Revocation propagation is bounded and pinned by tests: every revocation path
purges the shared resolve cache, so a revoked key is denied immediately with
Redis, or within YABANIN_ORG_RESOLVER_TTL (default 300 s) without it —
security-audit.md, "Key Revocation Propagation".
Internal EE session validation: the enterprise backend never holds
admin session secrets. It relays the browser's raw Cookie header to
POST /auth/ee/session behind the X-EE-Internal shared token
(EE_INTERNAL_TOKEN; the route is not mounted — the path answers 404 —
until that token is configured). The verdict is always HTTP 200 with
{"valid", "subject", "expires_at"}; any doubt (revoked, expired,
malformed, store error, deactivated user) collapses into the identical
valid:false payload — no oracle — and the validation itself is the exact
sequence of the admin session middleware (pkg/adminauth.validateSession),
including the durable revocation store, the invalidation watermark and live
user revalidation. The response never sets cookies: EE answers to a server,
not a browser.
Status ladder, exactly as implemented: with EE_INTERNAL_TOKEN unset or
empty the route is not mounted at all — any method on the path answers the
router's ordinary 404 (feature-dark; the unconfigured SSO routes behave the
same way). When the token is configured: a non-POST method answers 405 (the
router's method guard fires before the token guard, so an unauthenticated
non-POST probe learns only 405, never token state); a POST with a missing or
wrong X-EE-Internal token answers a bare 401 unauthorized that is
byte-identical for missing and wrong tokens (constant-time compare, no
oracle); a POST with a valid token but an undecodable JSON body answers 400
{"error":"invalid request body"} (64 KiB envelope cap). Every decodable
body — with or without a usable cookie — answers HTTP 200 with the verdict
shape above, never 401/403. Known cosmetic: the 401 body is text/plain
(http.Error) while the 400 body is application/json (writeJSON); no
consumer reads either error body (the EE client branches on status only).
Exposure posture: the endpoint is network-internal by design. It sits on
the admin listener behind the X-EE-Internal shared-secret guard and
network isolation — it has no rate limiter of its own (unlike
/auth/login's 5 attempts / 15 min budget; only the global
admin-listener budget of 1000 req/min per IP applies, which is not a
guessing-resistant bound). Residual risk, named: an attacker already in a
network position to reach the admin listener can use the endpoint as a
shared-secret guessing oracle throttled only by that global budget; the
accepted mitigation is network isolation of the admin listener, the
constant-time compare and the tiny request envelope. Timeout envelope: the
admin server reads headers/body at 10 s and writes at 15 s; the EE client's
whole-request deadline is 10 s — strictly under the server's write budget,
so a slow core becomes a client-side unavailability (fail-closed deny),
never a half-truncated verdict read.
Contract pinning and versioning: there is no cross-repo golden contract
today — both sides pin independently (core: the byte-exact 200 verdict pin
in services/admin/handlers/auth_ee_test.go; EE: client parsing tested
against a stub, tolerating extra response fields), and neither seam is
versioned (no vN path segment, no version field in payloads). Accepted
for the preview; revisit — bump the path or add a version field, and
consider one shared golden fixture — at the first breaking change.
The core contract is covered by services/admin/handlers/auth_ee_test.go.
These tests do not establish end-to-end compatibility with an external EE deployment.
Brute force and abuse: admin login is limited to 5 attempts / 15 min, the
admin API to 1000 req/min, with a Redis-backed limiter
(pkg/adminauth/ratelimit_redis.go); the gateway applies per-IP token-bucket
limits. Admin mutations land in the hash-chained audit journal
(pkg/auditlog: row_hash = sha256(prev_hash || payload)), and privileged
routes require root-only middleware.
Secrets at rest
enc:envelopes. Provider keys (BYOK) and MCP upstream credentials are stored as AES-256-GCM ciphertext with anenc:version prefix. Writes are fail-closed: without a configured encryptor the write is refused — a missing key can never silently downgrade to plaintext. Weak keys (short, low-entropy hex) are rejected at construction (pkg/encryption/encryption.go).- KMS master key.
localaccepts its configured master key or versioned keyset.FileKMSexists as a library implementation, butfileis not a selectable provider in the gateway factory in this version. Theawsprovider is an unimplemented, fail-closed placeholder; supplying configuration cannot enable it (pkg/kms/factory.go). - Hashed, never recoverable. API/agent keys are SHA-256 hashes; SCIM bearer tokens resolve by hash lookup with a constant-time confirm; admin passwords are bcrypt. These stored hashes cannot be used to recover the original credentials; newly issued keys are returned once to their creator.
- Masked credential reads. Stored upstream credential APIs return masked
metadata (
secret_last4,has_secret), not the stored plaintext. Upstream authentication resolves the secret in memory. Newly issued gateway and agent keys are a separate case: their plaintext is returned once at issuance (mcp-gateway.md §6). - Org isolation. Secret-bearing tables sit under the org-isolation RLS
contract (
ENABLE+FORCE,app.current_orgGUC pinned per transaction); a foreign org's rows are invisible and unwritable. - Deployment secrets (
session_key,cache_hmac,pg_uri, KMS keys) depend on the deployment profile. Development profiles use environment variables; hardened installations can mount secret files under/run/secrets/and use supported file-based settings. See the rotation runbook (ops/secrets-rotation.md).
The policy pipeline as a control layer
Policy Pipeline (YPP) is the enforcement point for content-level controls: PII/secret/injection detectors, redaction and pseudonymization mutators, external scanners, LLM judges, output-schema and streaming checks. Properties that make it a control rather than a feature:
- Off by default, admin-owned. With
YABANIN_POLICY_MODEunset the runtime is never built; there are no per-request (SDK-supplied) policy configs, so a client cannot bypass an admin's policy. - Fail-closed default. A step error denies by default (
on_error: fail_closed);fail_openis an explicit per-step choice. Unknown actions rank as deny. - Shadow → enforce. Policies roll out in shadow mode (record-only, never mutates), with the decision log (90-day retention, content hashed) and per-policy metrics as the review surface. A process-wide kill switch downgrades everything to shadow in one move.
- Bounded egress. Callout steps require an operator allow-list
(
YABANIN_POLICY_CALLOUT_ALLOW_HOSTS); every dial is SSRF-guarded with pinned DNS (no rebinding window), no redirects, no retries, per-URL circuit breaker.
The OWASP LLM Top-10 mapping (security-owasp-llm.md) spells out per-risk what this layer covers and what it does not.
Supply chain
- Dependency CVE scanning in the gates.
make analyze-securityrunsgo mod verify+ symbol-levelgovulncheck; the same check is a quality gate (scripts/quality/dep_audit.py), so a reachable CVE fails the build, not just a report. Analyzer versions are pinned (make install-analysis-tools); findings triage usesscripts/security/govulncheck-classify.sh. Current scan results: security-audit.md. - Dependency policy. New Go dependencies ride the same review + quality gates as code changes; the scanner classifies findings by reachability, and "not called" findings are recorded with that justification rather than silenced.
- Runtime supply chain. Container restrictions and listener exposure depend on the chosen Compose or Helm profile. Review the rendered configuration for read-only filesystems, privilege restrictions, network isolation and published ports. The shared SSRF package guards configured upstream and callout paths; it is not a replacement for deployment-level egress controls.
- Policy/prompt/model provenance. Policies reconcile from git and record the git SHA of the declaring revision; judge prompts and prompt-studio resources are versioned; model eligibility can be constrained per org with the model-whitelist step. The npm tree of the dashboard/site and Docker base images are outside Go scanning — a known, documented boundary (security-owasp-llm.md, LLM03).
Incident response
Runbooks: incident response, severity classification, secret rotation, budget-reservation alerts, and the production runbook.