Threat model
Last updated: 2026-11-27T14:16:11-03:00 (UTC-3)
Security and trust · Architecture · Cryptography · Data inventory
The product’s risk management: what m7gtw protects, from whom, where the trust boundaries are and which defense answers each threat. The threats follow STRIDE. Each defense points to the test that proves it, which runs in the release gate. The review happens when a trust boundary changes, which, per AGENTS.md, also calls for an ADR.
Assets
Section titled “Assets”- Provider and third-party credentials: API keys, cloud credentials, MCP OAuth tokens. A leak creates cost and access in the operator’s name.
- Client keys and console sessions: whoever holds them acts as the owning team.
- Content: prompts and responses in transit, plus what is stored (captures, files, vector stores, datasets; see the inventory).
- Spend: budgets, quotas and the balance with the providers.
- Configuration and audit: who can change routes, models and policies, and the record of who changed them.
- Availability of the inference path.
Actors
Section titled “Actors”- Client with a valid key: may try to go beyond its scope, its team or its budget.
- Attacker without credentials, on the gateway’s network.
- Console user of one team, trying to see or change another team.
- Faulty or compromised provider, MCP server, IdP or vault, returning malicious responses.
- Operator: trusted, but can make configuration mistakes.
Trust boundaries
Section titled “Trust boundaries”client ───(1)──▶ gateway ──(4)──▶ provider · MCP · guardrail · catalogoperator ─(2)──▶ console/admin API gateway ──(5)──▶ PostgreSQL · Redis · vaultIdP ─────(3)──▶ OIDC login · JWT · SCIM gateway ──(6)──▶ webhooks · email · log destinationsThreats and defenses
Section titled “Threats and defenses”| # | STRIDE | Threat | Defense | Test |
|---|---|---|---|---|
| 1 | Spoofing | Stolen, expired or revoked key | SHA-256 hash, database lookup on every request and fail closed if the database goes down | TestAuthorizedRequestPreservesScopeAcrossConcurrentRevocationWithPostgres |
| 2 | Elevation | Key uses a route or model outside its scope | Route scopes, model allowlist, team policy and default deny | TestManagedKeyRouteScopeIsEnforced |
| 3 | Disclosure | A user of one team reads another team’s data | Scope applied in SQL before pagination | TestTeamViewerIsolatedReadsWithPostgres |
| 4 | Spoofing | Forged browser request against the console | HttpOnly and SameSite=Strict cookie, CSRF and same origin on every write |
TestAdminSessionAndCSRF |
| 5 | Spoofing | Tampered or replayed OIDC login | Encrypted PKCE, state and nonce; discovery only from trusted endpoints |
TestOIDCLoginAndRevocationWithPostgres, TestOIDCDiscoveryRejectsUntrustedEndpointsRedirectAndOversize |
| 6 | Repudiation | Federated logout replayed to bring down sessions | Atomic anti-replay and tombstones across replicas | TestOIDCLogoutCallbackRaceReplayAtomicityAndStorageFailure |
| 7 | Spoofing | JWT with the wrong algorithm, issuer or key | Pinned algorithms, JWKS without redirects and without private keys | TestJWTInferenceClaimAndSignatureRejectionsWithPostgres, TestJWTJWKSRejectsRedirectOversizeDuplicateAndPrivateKeys |
| 8 | Elevation | SSRF: the gateway made to call the internal network or the cloud metadata service | URLs defined by the operator; special or mixed DNS denied before connecting; pinned IP; no redirects | TestNetworkDeniesSpecialAndMixedDNSBeforeDial, TestNetworkPinsResolvedIPWithoutSecondLookup |
| 9 | Disclosure | Secret leaking in a response, log or listing | Listings with metadata only; encrypted secrets; rejection of a credential echoed back by the upstream | TestAdminConfigExposesFeatureStatesWithoutSecrets, TestClientRefusesRedirectWithoutCredentialOrPayloadLeak, TestMCPReviewRejectsEscapedCredentialsAndSessionInPublishedData |
| 10 | Disclosure | Stored secret read from the database | AES-256-GCM with the resource’s identity as associated data | TestProviderCredentialEncryptionBindsIdentity |
| 11 | Disclosure | Cache serving one team’s response to another | Cache key isolated by identity, team and credential; encrypted, tamper-proof cache | TestExactCacheIsolationExactBytesExpiryCredentialAndConfiguration, TestEncryptedSlotsGenerationPurgeCollisionAndTamper |
| 12 | Elevation | Cache hit bypassing revocation or RPM | Authorization and RPM before the cache | TestReviewRemoteCachePostgresAuthorityAndRPMPrecedeSharedHit |
| 13 | Tampering | Malicious prompt or one with sensitive data | Input and output guardrails, with masking or blocking before the provider | TestGuardrailsOnChatAndManagementPostgres, TestGuardrailsCoverResponsesAndAnthropicMessages |
| 14 | Denial of service | Large body, slow read or ambiguous JSON | Size ceiling, read deadline and strict JSON | TestLoginReviewDeadlineStrictJSONAndTotalBodyLimit |
| 15 | Denial of service | Burst that exhausts the provider or the budget | RPM, TPM and budgets per key, team and end user; bounded queue per destination | TestEndUserRateLimitsPostgres, TestDestinationAdmissionFIFOOverflowCancellationAndNoSlotLeak |
| 16 | Denial of service | Malicious upstream or cache with malformed frames | Bounded parsers; an invalid WebSocket frame or a message above 16 MiB stops parsing: the realtime session closes (1011) when a limit applies, otherwise it is relayed unmetered | TestRealtimeFrameReaderRejectsWhatItCannotFollow, TestRealtimeFrameReaderBoundsMessageSize, TestRealtimeUnreadableStreamFailsClosedUnderQuotaPostgres, TestBoundedRESPAggregateDepthFramesAndWireBudget |
| 17 | Tampering | Reading a file outside the documentation site | Folder opened as os.Root; inline scripts only by hash |
TestDocsSiteServedBesideTheConsole |
| 18 | Repudiation | Configuration change with no author | Audit with actor and request_id |
TestAdministrativeAuditExplorerWithPostgres |
| 19 | Elevation | Incident in progress (leaked key used at scale) | Emergency stop that cuts traffic on every replica | TestPanicStopsTheDataPlaneAndPropagatesPostgres |
| 20 | Disclosure | Dependency with a known vulnerability | Scan in the release gate | scripts/security-scan.sh (secure development) |
| 21 | Disclosure | Response interpreted as another type, or embedded by another site | nosniff, Cross-Origin-Resource-Policy and Cross-Origin-Opener-Policy on every response |
TestBaselineSecurityHeadersOnEveryAnswer |
| 22 | Elevation | Whoever takes over the console (or the admin API) runs code on the server | No configurable feature starts a program or loads a native plugin; only the aws and az CLIs, with fixed name and subcommand, and the AWS profile validated as a simple name. Extensions (T058) are WebAssembly modules, or JavaScript sources run by the pinned QuickJS WebAssembly engine (T058.001), run in process with no ambient capability, and only a signature by a boot-trusted key makes one loadable, so console access alone cannot add an extension. The one exception is a code evaluator (T186.009, code_evaluators, off by default): a team member with evals:manage writes a JavaScript evaluate(data) that runs in the same QuickJS sandbox with no host function at all (row 27) |
TestNoAdministratorCanExecuteCodeOnTheHost, TestCloudCLIsAreTheOnlyCommands, TestAWSCLISource, TestExtensionSandboxGrantsNoAmbientCapability, TestCodeEvaluatorSandboxBoundsAndIsolation |
| 23 | Elevation | An extension escapes its sandbox: reads files, environment or sockets, or calls a capability it was not approved for | WASI preview 1 without file system, environment, arguments, real clock or sockets; only the aigw host functions; a module importing an ungranted host function does not load; a JavaScript plugin gets only the frozen host object, and the host bridge refuses an ungranted http_call |
TestSandboxDeniesHostAccessAndBoundsResources, TestUngrantedHostFunctionUnsignedAndTamperedModulesAreRefused, TestJavaScriptSandboxBoundsAndIsolation, TestJavaScriptUngrantedHostCallIsRefused, TestJavaScriptModulesReachNothing |
| 24 | Disclosure | One team’s extension call sees another team’s request, egress or secret | A fresh instance per call; host functions answer from the calling team’s invocation only; secrets resolved by reference inside the host and never handed to the plugin, an echoed secret refused; a team-owned plugin never runs for another team | TestFreshInstancePerCallIsolatesTenants, TestExtensionLifecycleGuardrailAndTenantIsolationPostgres, TestJavaScriptPluginSandboxBoundsAndIsolation |
| 25 | Tampering | A stored module or manifest is altered, or approval widens what was reviewed | Ed25519 signature over the canonical manifest and module digest checked on every load against boot-trusted keys; approval signs exactly the submitted bytes; the runtime is part of the signed manifest | TestUngrantedHostFunctionUnsignedAndTamperedModulesAreRefused, TestExtensionLifecycleGuardrailAndTenantIsolationPostgres, TestJavaScriptTamperedSourceOrManifestIsRefused, TestJavaScriptGuardrailPluginLifecyclePostgres |
| 26 | Denial of service | An extension loops, allocates without bound, floods output or saturates the replica | Per-call deadline with interruption, page ceiling, output limit, per-replica and per-team concurrency refused at once and counted; a trap or panic becomes an outcome | TestSandboxDeniesHostAccessAndBoundsResources, TestTeamConcurrencyIsBoundedAndRefusalsCounted, TestJavaScriptPluginSandboxBoundsAndIsolation, TestJavaScriptTeamConcurrencyIsBounded |
| 27 | Elevation, disclosure, denial of service | A team’s code evaluator (T186.009) escapes the sandbox, reads another team’s or organization’s traffic, reaches the network, keeps state between runs, or exhausts the replica | QuickJS-ng on wazero with WASI preview 1 and nothing behind it; the bridge function is deleted before the source runs, so no host operation exists (no network, files, environment, process, real clock or randomness); a fresh instance per run; the data is the evaluator’s own team’s target, read in that team’s span store and captures only (a target of another team or organization is left out of a run and ends target_gone live); captured content is read only when the source names it and the capture allows it; the source is compiled at save and bounded by evaluation.code (deadline, memory pages, heap, program, input and result sizes, per-team concurrency); results, reasoning and console output follow the content rules (console output and metadata never stored); every save, publish, run and cancel is audited |
TestCodeEvaluatorSandboxBoundsAndIsolation, TestCodeEvaluatorRunsEvaluateOnData, TestCodeEvaluatorRunsAndLimits, TestCodeEvaluatorsPostgres, TestCodeEvaluatorsPostgresClickHouse |
Local inference (T203)
Section titled “Local inference (T203)”With local_inference.supervise on, the gateway starts model servers. That is the second place, after the cloud credential helper, where the gateway runs a program, so its boundary is stated here (an internal ADR records the decision).
- What may run is decided at boot, in the YAML alone.
local_inference.supervise, the absolute path of each executable (local_inference.runtimes), the directories weights may come from (local_inference.model_dirs) and the container images (local_inference.container_images) are read when the gateway starts. No API route and no console form sets them; the admin API shows which executables are admitted, never their paths. - What the API can do is combine. A pool written through the API (
local_inference:manage, global admin only) picks a backend whose executable is admitted, weights inside an admitted directory (checked again after symbolic links are resolved, when the replica starts) and an admitted image.extra_argsreach a command line, andapi_key_envsends a variable of the gateway’s environment to the pool’s endpoints, so both are YAML only: the API accepts them only unchanged, for a pool the YAML declares with the same backend, mode, weights, image and endpoints, and a stored list that stops meeting that is set aside.extra_argsmay never set the model, the address, the credential or a download source. - How it runs. An argument vector built from validated, typed fields; no shell; a minimal environment with none of the gateway’s own variables, so none of its secrets; every supervised replica bound to
127.0.0.1; its own process group, ended on stop and on gateway shutdown. A port already taken is reported, never taken over. - Nothing is fetched. The gateway never downloads weights or installs a model server; MLX and vLLM are started offline and Ollama with its cloud models off.
- What comes back. A replica’s output is kept only as its last line, in memory, shown to readers of the Local inference screen to explain a failure, and never logged. Health probes go to the replica’s own origin, follow no redirect and read no body.
- Tenant isolation. Pools are operator infrastructure with no key, team or organization in them, and global by design. Which organizations may call a pool’s alias follows the usual model grants; a replica’s state and metrics carry no tenant data.
- What it does not cover. A model server is trusted code the operator chose: the gateway does not sandbox it, verify the weights’ content or limit what the server itself reads. The vLLM backend needs access to the container runtime’s socket, which is equivalent to root on that host: use a host dedicated to inference. Local processes of the host can reach a replica’s loopback port without passing through the gateway.
| Threat | Defense | Proof |
|---|---|---|
| An API caller makes the gateway run a program or read a file of its choice | Executables, model directories and images are boot settings; pools only combine them; extra_args are YAML only |
TestLocalInferenceManagementPostgres, TestLocalInferenceConfigValidation |
| An API caller makes the gateway send one of its environment variables to a host of the caller’s choice | api_key_env is YAML only and bound to the YAML pool’s endpoints |
TestLocalInferenceManagementPostgres, TestLocalInferenceConfigValidation |
| Weights that link outside the admitted directories | Resolved and checked again at start; the replica stays blocked | TestWeightsLinkOutsideModelDirsIsRefused |
| The gateway’s secrets reach a model server | Minimal environment built per start | TestOllamaStyleServerGetsItsEnvironmentAndNoGatewaySecrets |
| Traffic reaches a model server that is loading, dead or stopped | A replica is routable only while its own health check passes | TestLocalInferenceRoutesOnlyToReadyReplicas, TestReplicaStillLoadingIsNotRoutableAndTimesOut |
| A crash loop exhausts the host | Doubling backoff and a restart limit per hour, then failed until an operator starts it | TestCrashingReplicaFailsAfterTheRestartLimitAndExplainsItself |
| A viewer or team role starts or stops servers | local_inference:operate and local_inference:manage are permissions inside the roles; reads are separate |
TestLocalInferenceManagementPostgres |
Agent interactions (T199)
Section titled “Agent interactions (T199)”The Gemini Interactions API can run an agent (agent, agent_config) or a remote environment (environment, environment_id) at the provider: a loop that searches, browses, executes code and calls tools on Google’s side, for minutes, and reports back. gemini_interactions_agents (off by default, an operator control) is what admits such a request; without it the gateway answers 422 agents_disabled.
| Threat | What the gateway does | What it cannot do |
|---|---|---|
| The agent reaches the internet or runs code with data from the prompt | Input guardrails check the request’s text before it is sent | It does not see the agent’s tool calls, the pages it reads or the code it runs: no tool policy, MCP allow-list or egress control applies |
| Unbounded cost | The request log records the call; the cost is unknown, never zero |
An agent run cannot be reserved: an alias under a budget refuses it |
| The answer carries content no guardrail checked | An enforcing output guardrail refuses background interactions, which agents need, so a guarded alias does not serve them | Output of an unguarded alias is relayed as the provider returns it |
| Cross-tenant state | Interaction IDs are signed to the key; with organizations environment_id is refused |
Within one tenant, a remote environment is shared provider state |
Turn the flag on only for aliases whose callers you would let run code on a third party’s machines with the data they send, and keep those aliases apart from guarded ones.
Accepted risks
Section titled “Accepted risks”- An operator with database access reads the stored content in cleartext: files, batches, vector stores, datasets and prompts (inventory).
- The provider receives the prompt: that is the gateway’s job. Guardrails reduce what goes out, but do not eliminate it.
- Stream output does not go through the guardrails.
- Audit is not immutable: a database administrator can change it.
- Ingress and inbound TLS belong to the operator, and the hardening guide explains how to configure them.
Extension runtime (T058)
Section titled “Extension runtime (T058)”The extension runtime is the one place where code the operator did not write runs inside the gateway process, so its boundary is stated here in full (internal ADR 0221 records the decision).
- Boundary. A plugin is a WebAssembly module run by wazero (pure Go). It gets WASI preview 1 with nothing behind it - no file system, environment, arguments, real clock, real randomness or sockets - and the
aigwhost functions its signed manifest grants. A JavaScript plugin (T058.001) is source text run by QuickJS-ng compiled to WebAssembly, pinned by digest, on the same engine and rules: a fresh QuickJS instance per call, the same memory ceiling and deadline, and a frozenhostobject whosehttp_callgoes through the same host checks. Network access exists only as thehttp_callhost function: the origin must be in the signed manifest and in the calling team’s binding, the request goes through the same pinned, redirect-free SSRF-safe client as every other integration, and secrets are referenced by name and resolved inside the host. - Why hybrid. Small logic (redaction, policy checks) runs in process for microsecond-to-millisecond cost. Heavy logic - ML libraries in Python, a team’s own database - stays out of process behind the existing HTTP guardrail and authorization contracts. Native plugins (
.so) are not supported: they need CGO, fail on Windows, demand exact toolchain matching and cannot be unloaded. - Tenant isolation. A fresh instance per call, so no memory is reused across calls or teams; per-team concurrency; host functions see only the calling team’s input, egress and secrets; a plugin a team submitted runs only for that team; only the global administrator’s trusted signature approves a version, and approval cannot widen it.
- Code evaluators (T186.009). A second caller of the same JavaScript engine, internal ADR 0227: team code that judges the team’s own traffic, written in the console by
evals:manage, run with no bridge (the program gets notoolsorhostobject; the injected bridge function is deleted by the prelude and answers nothing), onevaluation.codelimits, a fresh instance per run. Unlike a plugin it is not signed: it can reach nothing outside its instance, and what it returns is checked by the gateway against the evaluator’s output before anything is written. It reads only the captured content of its own team, and only the sent view, as every judge does. - What it does not cover. Timing side channels between calls sharing the process and CPU caches; a bug in the WebAssembly engine; the resources a plugin may legitimately spend within its limits; the intent of a plugin the operator signed. Tenants that need physical isolation need separate replicas or deployments.