Threat Model
Security threats, mitigations, and residual risks for Ontos.
Threat Summary
All SPARQL is validated at the ARQ parser level AND checked for read-only (no UPDATE/INSERT/DELETE). One self-repair retry on parse failure, then a structured 'cannot answer' — never execution of malformed or mutating queries.
Column names with injected instructions (e.g., 'ignore instructions; INSERT...') are tested in ai-svc test suite. The model is instructed to produce only schema-valid read-only SPARQL. Parser-level validation is the last line of defense.
Every service validates the JWT signature against the Keycloak OIDC discovery endpoint. The gateway rejects requests without a valid token at the perimeter. Internal services (graph-engine, ai-svc) also validate — defense in depth.
No service accounts for user-triggered work. The caller's token is forwarded on every internal call. If a service is compromised, it can only act with the privileges of the current user's token.
The PolicyFilter injects constraints at the ARQ query rewriting level — not in a middleware layer that can be bypassed. Unit-tested with 6+ cases including subquery and UNION shapes. The filter is applied on every SPARQL request from graph-engine.
Credentials go through the SecretStore port. The local adapter encrypts with a local key in Postgres. Credentials never appear in sync-run records, logs, or API responses. CI architecture check bans cloud SDK imports in services/.
Triples in urn:ontos:staging are never visible to analysts (role check) and require explicit steward approval before promotion to urn:ontos:data. The approval endpoint requires the steward role JWT.
Ontos never returns fabricated results. NL→SPARQL output is validated against the real ontology — nonexistent properties are dropped. On parse failure: one self-repair retry, then a structured 'cannot answer'. Never guessed data.
Per-user bucket4j rate limit (20 rps) at the gateway. Exceeds return HTTP 429 with Retry-After. SPARQL queries have a 5s timeout; MCP run_sparql has a 1000-row cap. These prevent long-running query attacks.
Fuseki backup endpoint provides consistent TDB2 snapshots. Backup + restore rehearsal test runs in CI (seed → backup → wipe → restore → count queries equal). Postgres pg_dump for the platform database.
CI architecture check (tools/ci/check-ports.sh) fails if any file under services/ imports com.amazonaws, software.amazon, or boto3. All cloud dependencies go through interfaces in libs/platform-ports/.
Gateway enforces CORS for the web origin only. React renders data as text (no dangerouslySetInnerHTML). SPARQL results are not executed as code anywhere in the web app.
Out of Scope (Phase 1)
- Production Keycloak hardening (Keycloak runs
start-devin Phase 1) - mTLS between internal services
- Network policy enforcement in Kubernetes
- Secrets management via Vault or AWS Secrets Manager (local adapter only)
- SOC2 audit logging (Phase 2)