Threat model
Status: accepted by the maintainer on 2026-11-23 with the conditions of
section 10, for the v1.0.0-rc security
gate (readiness criterion 7, v1.0 readiness).
The reporting channel (G4, O7) was enabled and verified on 2026-11-23. DNS
rebinding (O1) is an explicit residual risk, not resolved.
Written 2026-11-22 against main at 580af3f (v0.9.0 plus documentation);
refreshed 2026-11-23 against main at e13b3cc for the frozen 1.0 contract
(v1.0 backlog item N16): input byte limits and
body-read classification (T1.3), feeder admission lanes, busy,
too_many_connections and per-lane metrics (T1.5, T1.6, T1.10), the drain gate
(T1.16), non-UTF-8 inspection paths (T1.17) and the console variable namespace
(T3.10). It describes the supported
exposure only and promises nothing beyond the evidence cited; every cited test
exists at the refresh commit.
This document states what Knotrel protects, from whom, where the trust boundaries are, which threats apply at each boundary, and, for every mitigation, the test or CI check that validates it. Gaps are listed with their status and a proposed fix; none is closed by this document alone.
1. Scope and supported exposure
Knotrel has no authentication, authorization or TLS of its own (trust model). The supported exposures for 1.0 are:
| Exposure | Supported | Who is trusted |
|---|---|---|
E1 Loopback: server on 127.0.0.1/[::1] (the default), clients on the same host |
Yes | Every process and user on the host that can open a loopback connection |
E2 Trusted network: non-loopback bind with KNOTREL_ALLOW_NON_LOOPBACK=true, reachable only from a network whose every host is trusted (for example a private container network) |
Yes | Every host on that network, with full read/write access |
E3 Behind a gateway: server on loopback (or on a network only the gateway reaches); a gateway terminates TLS and authenticates and authorizes every request (deployment guide, examples/gateway/) |
Yes | The gateway and the identities it admits, per route class |
| E4 Untrusted exposure: any client that is not trusted can reach the Knotrel listener directly (public internet, shared network) | No | — |
Native authentication is not part of 1.0; E4 stays unsupported. Opting in to a non-loopback bind is an operator acknowledgement, not a hardening step.
Since v1.3.0 (experimental): gateway-verified identity
(KNOTREL_AUTH=gateway-identity, ADR 0017).
It refines E3: Knotrel authorizes each request by role from an identity the
gateway verified and forwards in X-Knotrel-Auth-* headers (boundary B7).
Its two trust conditions are requirements, and E4 stays unsupported with
it: there are still no rate limits, abuse bounds or audit output for
untrusted clients (#185, M8.4–M8.5). Off by default, so E1–E3 behave as in
1.0.
Out of scope: the security of the authoritative source itself, of the operator’s identity provider, of the container runtime and host, and of third-party feeders other than the reference PostgreSQL feeder. Side channels and physical access are not considered.
2. Assets
| ID | Asset | Why it matters |
|---|---|---|
| A1 | Graph integrity: nodes, edges, lifecycle flags, generation and revision | Wrong connectivity answers propagate to every consumer |
| A2 | Synchronization integrity: feeder session, epoch, lease, delivery sequence, source frontier, deduplication window | A takeover or a desynchronization makes the graph diverge silently from the source |
| A3 | Availability: the graph lock, admission lanes, connections, memory and CPU | Knotrel is an accelerator on a query path; stalls and crashes are the main operational risk |
| A4 | Graph confidentiality: topology and node IDs, readable through queries, inspection, stats and metrics | Topology can be sensitive (for example network or grid layout) |
| A5 | Credentials around Knotrel: gateway credentials, TLS keys, the PostgreSQL feeder role’s password | Knotrel holds none itself; the deployment around it does |
| A6 | Release artifacts: binaries, crates, console archive and image | A tampered artifact compromises every deployment |
Knotrel stores nothing on disk (state and lifetime): a restart loses A1/A2 by design and is recovered by a rebuild from the source.
3. Actors
| Actor | Trust | Normal capabilities |
|---|---|---|
| Operator (human or automation) | Trusted inside the boundary | Configures and starts the server; in standalone mode mutates the graph; reads everything |
| Query client (application) | Trusted inside the boundary | Queries; in standalone mode also mutates |
| Feeder (the reference PostgreSQL feeder or another) | Trusted inside the boundary | Owns the feeder session; imports and streams events in source-managed mode |
| Console user | Trusted, authenticated by the gateway (E3) or the single local user (E1) | Reads; in standalone mode mutates through the console’s allowlisted routes |
| Gateway | Trusted component | Terminates TLS, authenticates, authorizes per route class, forwards |
| PostgreSQL (reference source) | Trusted authority for the graph content | Supplies snapshots and the logical replication stream |
| Misbehaving insider: a buggy or compromised client inside the boundary | Inside the boundary, not malicious by assumption, but considered for availability and for blast radius | Anything the boundary grants |
| Web attacker: a page the operator’s browser visits | Untrusted | Can make the browser send requests to loopback and private addresses |
| Network attacker outside the boundary | Untrusted | Can reach the gateway’s listener (E3) but not Knotrel directly |
| Supply-chain attacker | Untrusted | Targets dependencies, CI or release artifacts |
4. Trust boundaries and data flows
untrusted | trusted boundary
|
browser (console user) --TLS--> [ gateway ] ------+--> console (127.0.0.1) --> Knotrel (127.0.0.1)
query client --------------TLS--> [ gateway ] ----+--------------------------> Knotrel
feeder -------------------TLS--> [ gateway ] -----+--------------------------> Knotrel /v1/feeder/*
|
PostgreSQL <--replication-- reference feeder (same trusted network, no TLS)
| ID | Boundary | Crossing | Controls |
|---|---|---|---|
| B1 | Network → Knotrel listener | Every HTTP request | Loopback default and explicit opt-in for other binds; request bounds; no authentication |
| B2 | Gateway (E3) | Client → gateway → Knotrel or console | TLS 1.2/1.3, HTTP Basic (example) or the organization’s identity provider, route classes per credential |
| B3 | Console container | Browser → console → Knotrel | Fixed upstream, route allowlist (graph resources read-only), Host/Origin/Sec-Fetch-Site checks, CSP, no credential forwarding; no identity header reaches Knotrel unless KNOTREL_CONSOLE_FORWARD_GATEWAY_IDENTITY=on, which relays exactly the three identity headers (B7) |
| B4 | Feeder routes | Feeder → /v1/feeder/* |
Mode check, instance ID, session/epoch fencing, lease; separate gateway credential (E3) |
| B5 | PostgreSQL → reference feeder | Snapshot and logical replication | Least-privilege role, password from a file, slot retention bounds |
| B6 | Build and release | Source → CI → artifacts | Locked dependencies, advisory checks, pinned actions, checksums, signed tags |
| B7 | Identity headers (opt-in, new in 1.3) | Gateway → Knotrel (directly or through the console), X-Knotrel-Auth-* |
Gateway overwrites the headers on every request, the console location included; only trusted peers reach the listener, and only the gateway reaches the console listener; strict header parsing (duplicates, unknown reserved names and malformed values refused); optional peer allowlist; roles per action |
5. Threats and mitigations per boundary
Each mitigation names its validation. “Doc only” means the mitigation is a
documented operator duty with no automated check. Gaps are cross-referenced
to section 6 (G#) and section 7 (N#).
B1 — Network to the Knotrel listener
| ID | Threat (STRIDE) | Mitigation | Validation |
|---|---|---|---|
| T1.1 | Accidental exposure on a non-loopback address (S, T, I) | Default bind 127.0.0.1:8080; a non-loopback KNOTREL_ADDR fails startup unless KNOTREL_ALLOW_NON_LOOPBACK=true; a warning is logged when set |
security.rs::non_loopback_listener_requires_a_separate_constructor; startup.rs::invalid_environment_exits_promptly_with_the_setting_name (includes KNOTREL_ADDR=0.0.0.0:0 without the opt-in) |
| T1.2 | Any reachable client reads and mutates the graph (S, T, I, E) | None in Knotrel by design by default: restricted to E1–E3; E3 adds authentication at the gateway; with the opt-in gateway-verified identity, Knotrel also authorizes each route by role (B7) | Gateway smoke test (B2); E1/E2 are a deployment duty (doc only, trust model) |
| T1.3 | Oversized bodies or fields exhaust memory before parsing, or grow per-event state (D) | 1 MiB body limit on every route except import, enforced before parsing; import bounded by KNOTREL_MAX_IMPORT_BODY_BYTES (default 64 MiB, at most 512 MiB) and admitted (one permit) before its body is consumed: a declared Content-Length above the limit gets 413 before any body byte is read, and a body (chunked included) that grows past it while received gets 413 too. Only the limit answers 413: a body that cannot be read to its end for another reason (client abort, malformed chunked encoding, receive error) gets 400 invalid_request with a fixed message on every route, and an import that fails so releases its permit. Strings kept per event or per generation are bounded in bytes: every source position (event source_position and prev_source_position, import source_position, barrier_source_position) 1 to 256 bytes, event_id at most 64 bytes; other values get 422 invalid_request with nothing applied |
security.rs::request_size_bounds_are_enforced_before_parsing_on_every_engine; http.rs::oversized_bodies_are_rejected_before_mutation; import.rs::test_1_admission_before_body_consumption_and_ceiling_at_one, test_17_import_over_limit_is_413_declared_or_streamed, test_18_malformed_chunked_import_is_400_not_413, test_19_client_abort_mid_body_is_not_413_and_releases_the_permit, test_20_json_routes_classify_body_read_failures_the_same_way, test_21_chunked_import_with_trailers_is_read_to_its_end; input_limits.rs::import_source_position_is_one_to_256_bytes, event_source_positions_are_one_to_256_bytes, event_id_is_at_most_64_bytes, barrier_source_position_is_one_to_256_bytes |
| T1.4 | Graph growth without bound (D) | Default KNOTREL_MAX_NODES=100000, KNOTREL_MAX_EDGES=500000 on every engine; unlimited is an explicit opt-out; rejections do not mutate |
security.rs::configured_servers_default_to_finite_graph_limits_on_every_engine, node_limit_boundary_is_exact_and_rejections_do_not_mutate, edge_limit_boundary_is_exact_and_unlimited_is_an_explicit_opt_out, batches_cannot_exceed_limits_and_report_per_operation_rejections; http.rs::graph_limits_apply_to_batches_and_concurrent_requests |
| T1.5 | Slow or idle connections hold resources (slowloris) (D) | Header read / keep-alive timeout (5 s), request timeout (30 s) covering body receipt, connection limit (KNOTREL_MAX_CONNECTIONS, default 1024): the accept loop writes a static 503 too_many_connections to an extra connection, before reading any request, and closes it |
lifecycle.rs::silent_and_partial_header_connections_time_out, idle_keep_alive_connection_times_out, request_timeout_bounds_a_stalled_body, connection_limit_rejects_extra_connections_and_recovers (asserts the exact too_many_connections body) |
| T1.6 | Work flooding the graph worker, or queries starving the feeder (D) | Admission lanes, each with its own permits: shared KNOTREL_MAX_PENDING_JOBS (32) for queries and direct operations; in source-managed mode a feeder data lane (KNOTREL_FEEDER_RESERVED_JOBS, default 4: events, barrier, gap) and a feeder control lane (2 permits: session, heartbeat) that queries never use; one import permit. An exhausted lane answers 503 busy on every route of that lane before any graph work; 503 import_in_progress only from /v1/feeder/import while another import holds the permit, and a running import refuses no lane |
http.rs::invalid_admission_limits_are_rejected_before_router_construction; feeder_admission.rs::exhausted_data_lane_answers_busy_on_events_barrier_and_gap, exhausted_control_lane_answers_busy_on_session_and_heartbeat, concurrent_import_is_import_in_progress_and_refuses_no_lane; events.rs::test_26_queries_cannot_refuse_feeder_events_and_feeder_capacity_is_checked_first (feeder admission); not a CPU or lock-time bound → G2 |
| T1.7 | Lock-holding requests delay every mutation, feeder event and import (D) | Read-write lock (queries share it); batch ceiling 1024; inspection pages bounded by a scan budget | Inspection: inspection.rs::invalid_parameters_are_rejected_before_admission and inspection costs; per-request worst-case lock time not measured → G2 |
| T1.8 | Import memory amplification (D) | Streaming import parse; one import at a time; deployment sizing for old graph + import body + new graph |
Measured in the v0.6.0 qualification (topology lifecycle, resource model); import.rs::test_16_replaced_graph_released_after_lock_inside_worker → G1 |
| T1.9 | Information disclosure through errors and logs (I) | Error messages never quote a string taken from the current request (identifiers, positions, epochs, If-Match values, operation, field or parameter names), parser positions or internal paths. They are not free of client data: they may contain numbers from the request (node IDs, sequences, generations, byte lengths) and server state, including values a feeder supplied earlier (applied position, source_id, source_epoch, retained event_id); logs never contain bodies, node IDs or parser messages |
security.rs::client_errors_are_stable_and_do_not_leak_internals_or_payloads, schema_violations_never_echo_client_supplied_names_or_values, feeder_errors_never_echo_client_supplied_strings, inspection_errors_never_echo_client_supplied_names; logs.rs::logs_correlate_requests_and_never_expose_payloads |
| T1.10 | Metric label cardinality explosion (D), or admission pressure on one lane hidden in an aggregate (D, detection) | Only bounded labels; route templates, not raw paths; metrics off by default. Admission metrics are labelled by lane from 1.0.0: knotrel_requests_rejected_total{reason,lane} (lane one of the four lanes or none), knotrel_graph_jobs_outstanding{lane} and knotrel_graph_job_capacity{lane}, a fixed series set, so an operator sees feeder-lane exhaustion separately from query load |
metrics.rs::exposition_is_valid_and_uses_only_bounded_labels (every lane value enumerated), capacity_help_describes_the_admission_permit_limit, feeder_admission_rejection_answers_busy_and_counts_busy, import_permit_rejection_is_counted_as_import_capacity, every_registered_route_is_labelled_with_its_template, series_count_is_constant_under_sustained_churn, metrics_route_is_absent_when_disabled |
| T1.11 | Cross-site request forgery from a web page against a loopback server (T) | Mutating routes require a JSON media type (a cross-site form cannot send one without a CORS preflight, which Knotrel never grants); feeder routes also require the X-Knotrel-Instance-Id header |
http.rs::content_type_requires_a_json_media_type_before_mutation; the absence of CORS headers is not asserted by a test → N1 |
| T1.12 | DNS rebinding: a web page rebinds its name to 127.0.0.1 and becomes same-origin with the server (S, T, I) |
None in the server: Knotrel does not check Host. The console container and the gateway check Host only for requests that pass through them, so they protect nothing while the browser can reach the listener directly. The protection is deployment: the listener must not be reachable from any context where untrusted web content runs (trust model) |
Gateway example: “Knotrel not reachable from the host” and “from another container” (T2.1); otherwise doc only → N1 |
| T1.13 | Memory-unsafe code (T, E) | unsafe_code = "forbid" in the workspace lints |
Workspace lints (Clippy in CI) |
| T1.14 | Uncertain outcome after a timeout is mistaken for “not applied” (T) | Documented: a timed-out mutation’s outcome is unknown; mutations are idempotent; the console never retries mutations | lifecycle.rs::http_request_timeout_leaves_worker_active_and_shutdown_waits_for_it; console test/ui/workbench.test.tsx (“marks a timed-out mutating batch as uncertain and never retries”) |
| T1.15 | Any reachable worker panic becomes permanent unavailability (D). The graph worker sets graph.failed before running a job and clears it only when the job returns; after a panic every later request gets 503 unavailable and /ready reports unavailable until the process is restarted and rebuilt from the source (probes). This fail-stop is deliberate (integrity over availability: a graph left half-mutated by a panic is never served), but it turns any panic reachable from request input into a denial of service that outlasts the request, for queries, mutations and feeder events alike |
Fail-stop is tested; the absence of input-reachable panics is not: no audit of unwrap/expect/unreachable! sites on request paths and no fuzz or property test of arbitrary feeder envelopes against each synchronization state. Defect D1 (T4.6) is a concrete instance |
Fail-stop: lifecycle.rs::worker_panic_after_caller_cancellation_marks_ready_unavailable, bootstrap.rs::test_17_caller_cancellation_and_worker_panic_preserve_lifecycle, service.rs unit test panicked_writer_rejects_queued_and_future_work; absence of reachable panics: open → N7 |
| T1.16 | New work admitted while draining, or a drain answered inconsistently (D) | While draining, only GET and HEAD on /health, /ready and /metrics (when metrics are enabled) are answered; every other method on those paths, every other route and unknown routes get 503 shutting_down with Connection: close. The gate checks the method and the path (B8, knotrel/knotrel#123): before the fix a wrong method on a probe path got 405 |
lifecycle.rs::draining_rejects_non_read_methods_on_probe_and_metrics_paths; metrics.rs::scrape_is_served_while_draining, disabled_metrics_path_is_not_a_probe_while_draining, shutdown_rejection_is_counted_once_and_probes_are_not |
| T1.17 | A malformed path reaches a framework error path and bypasses the documented error envelope and gating (I) | An inspection path segment that is not valid UTF-8 (/v1/nodes/%FF, /v1/nodes/{node}/edges) gets the JSON envelope: 409 inspection_disabled when inspection is off, otherwise 422 invalid_request, instead of the framework’s plain-text 400 that quoted the parameter name (B11, knotrel/knotrel#123) |
inspection.rs::non_utf8_node_paths_get_the_json_error_envelope; security.rs::inspection_errors_never_echo_client_supplied_names |
B2 — Gateway (E3)
Validated by examples/gateway/smoke-test.sh,
run by the gateway CI workflow (.github/workflows/gateway.yml) on every
change to the server, the container images or the example.
| ID | Threat | Mitigation | Validation (smoke-test check) |
|---|---|---|---|
| T2.1 | Bypassing the gateway to reach Knotrel directly (S, E) | Knotrel binds 127.0.0.1:9080 (KNOTREL_ALLOW_NON_LOOPBACK=false) in a namespace shared only with the console and the gateway; only 8443 is published |
“Knotrel not reachable from the host”; “Knotrel not reachable from another container on the network”; “console not reachable from another container on the network” |
| T2.2 | Eavesdropping or tampering on the wire (I, T) | TLS 1.2/1.3 only; plain HTTP refused; HSTS | “TLS 1.2 accepted”, “TLS 1.3 accepted”, “gateway allows only TLS 1.2 and 1.3”, “plain HTTP on the TLS port refused” |
| T2.3 | Unauthenticated access (S) | HTTP Basic on every location, probes included | “no credentials refused”, “wrong password refused”, “console UI refused without credentials” |
| T2.4 | A query client or console user takes over the feeder session, or a feeder mutates through the operator API (E) | Separate credential files: operators for /v1/* except feeder routes, /metrics and the console; feeders for /v1/feeder/*; probes for either |
“operator cannot use feeder routes”, “feeder cannot use the operator API”, “feeder credentials reach the feeder routes”, “feeder can read readiness” |
| T2.5 | Key compromise via the gateway container (I) | The local CA key is deleted after signing and never mounted; files mounted read-only; containers read-only, all capabilities dropped, no-new-privileges |
“CA key not present in the gateway”; Compose settings reviewed, not tested |
| T2.6 | Credential leakage in process listings or logs (I) | Smoke test passes credentials to curl in files; Knotrel never logs headers | Smoke-test design; logs.rs (no payloads) |
| T2.7 | Request flooding through an authenticated or unauthenticated client (D) | Gateway body limits (1 MiB, 64 MiB for feeder routes) and read timeout; no rate or connection limiting in the example | Not tested → N3 |
| T2.8 | Weak authentication in production (S) | The example states that HTTP Basic with static files is an example, not a recommendation | Doc only (deployment guide) |
B7 — Identity headers (opt-in, new in 1.3)
Applies only with KNOTREL_AUTH=gateway-identity
(authentication,
deployment requirements). Knotrel
trusts X-Knotrel-Auth-Subject, X-Knotrel-Auth-Tenant and
X-Knotrel-Auth-Roles as set by the gateway. Two trust conditions are
deployment requirements: (1) the gateway overwrites or strips every identity
header on every forwarded request; (2) only trusted peers (the gateway) reach
the listener. With KNOTREL_CONSOLE_FORWARD_GATEWAY_IDENTITY=on (off by
default) the console container relays exactly the three headers to
Knotrel (since v1.3.0, #226),
so both conditions extend to it: (1) the gateway overwrites the headers on
the console location too; (2) only the gateway reaches the console listener.
| ID | Threat | Mitigation | Validation |
|---|---|---|---|
| T7.1 | Forged identity header: a client sends its own X-Knotrel-Auth-* values through the gateway to gain a role, a subject or a tenant (S, E) |
Condition 1 (the gateway overwrites the three headers on every location; example: identity-headers.conf). In Knotrel: a header sent twice (a gateway that appends instead of overwriting), any other header with the reserved prefix, a malformed value or an unknown role answers 401 (fail closed); each role grants one action only |
Gateway smoke test: “client identity headers overwritten (read / mutate / probe / metrics)”, “other reserved identity header fails closed in Knotrel”; tests/auth.rs::missing_or_forged_identity_is_unauthenticated_on_every_route, each_role_grants_exactly_its_action; auth.rs unit test rejects_malformed_identities |
| T7.2 | Gateway bypass: a process connects to the listener directly and sends any identity (S, E) | Condition 2 (loopback in a namespace shared only with the gateway, or a network policy). Optional defense in depth: KNOTREL_AUTH_TRUSTED_PEERS, checked against the TCP peer address (never a forwarding header); a router without a peer address fails closed |
Gateway smoke test (T2.1 checks: Knotrel unreachable from the host and from other containers); tests/auth.rs::peer_allowlist_uses_the_connection_peer; auth.rs unit tests peer_allowlist_fails_closed, peer_ranges_parse_strictly. The allowlist adds nothing on loopback in a shared namespace (every peer is 127.0.0.1): doc only there |
| T7.3 | Identity headers trusted while the operator did not enable the extension (S) | Off by default: no middleware is installed, the headers are never read, responses are unchanged | tests/auth.rs::identity_headers_are_ignored_while_the_extension_is_off; gateway smoke test, second phase: “identity headers ignored without the extension” |
| T7.4 | Wrong role or tenant performs an action: a reader mutates, a query client takes over the feeder session, a tenant reaches another tenant’s graph (E) | Role per action (read, mutate, feeder-control, feeder-data, import, …); the mutate check covers the whole batch before admission, so a mixed batch is refused with nothing applied; authorization precedes mode and validation errors; tenant match for tenant-owned graphs |
tests/auth.rs::each_role_grants_exactly_its_action, mixed_batch_from_a_read_only_identity_applies_nothing, authorization_comes_before_mode_and_validation_errors, tenant_scoping_through_a_custom_authorizer; gateway smoke test “feeder identity has no read role in Knotrel”. HTTP-level tenant scoping of graph resources: T7.8–T7.10 |
| T7.5 | Credential or identity leakage through errors or logs (I) | 401/403 bodies carry fixed messages; logs record a reason category, never a subject, tenant, role, header value or peer address; Principal’s Debug output is redacted; successful requests do not log the subject |
tests/auth_logs.rs::refusals_never_echo_credentials_in_responses_or_logs; auth.rs unit test debug_output_redacts_identity |
| T7.6 | Request body or admission spent on an unauthenticated request (D) | Authentication and the route’s role are checked from the headers before the body is read and before admission | tests/auth.rs::import_is_refused_before_its_body_is_read |
| T7.7 | Misconfigured gateway trusted silently (S) | The startup log (warning) states both trust conditions when the extension is enabled | tests/auth_logs.rs (startup warning asserted) |
| T7.8 | Forged tenant scope on graph resources (/v1/graphs, #155): a client claims another tenant through a body field, metadata, the tenant parameter or a client tenant header (S, E) |
The owning tenant comes only from the authenticated principal; unknown body members are refused (422), metadata is descriptive, the tenant parameter is honored only for tenant-admin (403 otherwise; 422 without authentication), and identity headers are ignored while the extension is off; a principal without a tenant is refused (403) |
tests/graphs.rs::tenants_are_isolated_and_enumeration_reveals_nothing, identity_headers_are_ignored_without_authentication, roles_are_checked_before_lookup; tests/graphs_logs.rs (refusals and changes logged without subject or tenant) |
| T7.9 | Graph enumeration across tenants: probing identifiers or listing to learn which graphs exist (I) | Lookups happen only in the resolved tenant’s scope; another tenant’s, a deleting, an unknown and a malformed ID answer the same 404 graph_not_found with the same body; the role is checked before the lookup, so a 403 does not depend on existence; lists show the resolved tenant only; IDs are random UUID v4 |
tests/graphs.rs::tenants_are_isolated_and_enumeration_reveals_nothing, roles_are_checked_before_lookup; knotrel-runtime tests/graph_records.rs::pages_are_scoped_ordered_and_complete |
| T7.10 | Graph exhaustion by one tenant (or by an unauthenticated local client) creating graphs until memory runs out (D) | Per-tenant graph quota KNOTREL_TENANT_MAX_GRAPHS (default 16), which also counts the local tenant’s graphs (only the default graph is exempt) and graphs still draining; idempotency keys bounded per tenant and in time; bodies at most 1 MiB. Records and metadata are bounded (16 entries, 4 KiB). Untrusted exposure stays unsupported |
tests/graphs.rs::the_graph_quota_applies_to_the_local_tenant; knotrel-runtime tests/tenant_quotas.rs::only_the_default_graph_is_exempt; graphs.rs unit test idempotency_is_bounded_per_tenant_and_in_time |
| T7.11 | Identity forged through the console: a client sends X-Knotrel-Auth-* values to the console, which relays them to Knotrel (S, E) |
Relay off by default (KNOTREL_CONSOLE_FORWARD_GATEWAY_IDENTITY): a default console sends no identity header. With the relay on: condition 1 on the console location (the example’s console location includes identity-headers.conf); condition 2 for the console listener (example: KNOTREL_CONSOLE_LISTEN=127.0.0.1:8080 in the namespace shared only with the gateway). The console relays only Subject, Tenant and Roles and drops every other reserved header; it forwards only its allowlisted routes, so even a forged identity cannot reach feeder routes or graph changes through it. Residual: nginx joins a repeated header into one comma-separated value, so behind a gateway that appends instead of overwriting, Knotrel’s duplicate refusal does not apply on the console path (condition 1 excludes it) |
smoke-container: “identity: exactly Subject, Tenant and Roles forwarded; other X-Knotrel-Auth-* headers dropped”; smoke-container: “default console relays no identity”; gateway smoke test: “upstream gets the gateway’s identity (forged client values)”, “(duplicated client values)”, “console: client identity headers overwritten”, “console drops other reserved identity headers”, “console not reachable from another container on the network” |
B3 — Console container
Validated by console/scripts/smoke-container.sh,
run in the console workflow and before each console release
(.github/workflows/console.yml, console-release.yml), and by the console
unit and browser tests (npm run check, npm run test:e2e). The container’s
forwarding rules are a security surface; changing them follows
AGENTS.md (update docs/console.md, console/deploy/nginx-gateway.conf
and the smoke script together).
| ID | Threat | Mitigation | Validation |
|---|---|---|---|
| T3.1 | Console used as an open proxy to arbitrary upstreams (S, E) | Upstream fixed by KNOTREL_CONSOLE_UPSTREAM; credentials in it are refused; startup fails without it |
smoke-container: “credentials in KNOTREL_CONSOLE_UPSTREAM accepted” / “missing KNOTREL_CONSOLE_UPSTREAM accepted” must fail |
| T3.2 | Feeder takeover through the console (E) | Route allowlist; feeder routes never forwarded | smoke-container: “feeder route hidden” (404), “unknown node subpath rejected”, “non-numeric node path rejected”, “method check” |
| T3.3 | DNS rebinding (S) | Only accepted Host names are served (421 otherwise) |
smoke-container: “Host check” |
| T3.4 | Cross-site request forgery (T) | Origin must match; Sec-Fetch-Site must be same-origin or absent |
smoke-container: “Origin check”, “Sec-Fetch-Site check” |
| T3.5 | Script injection through server-provided text (T, E) | Server text is rendered as text; ESLint forbids dangerouslySetInnerHTML and innerHTML; strict CSP (script-src 'self', frame-ancestors 'none') |
npm run lint (console/eslint.config.js); CSP headers in console/container/knotrel/security-headers.conf are not asserted by a test → N4 |
| T3.6 | Precision loss on IDs, revisions or counts leads to wrong mutations (T) | Lossless JSON parsing; IDs never converted to number |
Console unit tests and smoke-container “API forwarding with exact IDs” (a full batch with ID 18446744073709551615) |
| T3.7 | Credential forwarding to Knotrel (I) | No client header is forwarded except Content-Type and the three identity headers (proxy_pass_request_headers off), so Cookie, Authorization and forwarding headers never reach Knotrel; Set-Cookie hidden |
Console container configuration; the identity allowlist is asserted (T3.11), the rest is not (low risk: Knotrel ignores and never logs headers) |
| T3.8 | Oversized requests through the console (D) | 64 KiB body limit (1 MiB for batches) | smoke-container: “body limit”, “full batch accepted” |
| T3.9 | Static archive deployed with an unsafe hand-written gateway (S, E) | console/deploy/nginx-gateway.conf mirrors the container’s allowlist (graph resources GET only), CSP and stripping (proxy_pass_request_headers off), sets the identity headers from its own authentication only, and states that TLS and access control are required |
Packaged and checksummed by package-static.mjs --verify; not syntax- or behavior-tested → N4 |
| T3.10 | A console setting changes the server’s behavior through a shared environment file, or a console deployment stops the server (T, D) | Console variables are named KNOTREL_CONSOLE_* (legacy KNOTREL_UPSTREAM and KNOTREL_UPSTREAM_TIMEOUT remain deprecated aliases for 1.x; an alias that disagrees with the new name refuses to start the console). The server reserves that namespace and the two legacy names as console-owned and ignores them silently: it reads no value from them, so a console variable cannot change server behavior, whatever its value (non-Unicode values included). Every other unknown KNOTREL_* name still fails server startup. Trust implication: the console namespace carries no server configuration; a setting meant for the server but spelled with the console prefix is ignored rather than refused |
configuration.rs unit tests console_variables_are_ignored, console_legacy_aliases_are_ignored (near-miss names such as KNOTREL_CONSOLE and KNOTREL_CONSOLEUPSTREAM still fail), non_unicode_console_values_are_ignored; console side: console/scripts/test-entrypoint.sh (alias resolution) and the deprecated-alias cases in smoke-container.sh |
| T3.11 | Identity headers through the console (S, E; with KNOTREL_AUTH=gateway-identity) |
Off by default: no X-Knotrel-Auth-* header reaches Knotrel (identity headers set empty, others dropped). With KNOTREL_CONSOLE_FORWARD_GATEWAY_IDENTITY=on, exactly X-Knotrel-Auth-Subject, -Tenant and -Roles are relayed; every other reserved header is dropped; the console never sets an identity. It relies on B7’s conditions for the gateway in front of it (T7.11) |
smoke-container, against a server with KNOTREL_AUTH=gateway-identity: 401 without identity, 200 with subject and roles, 403 when the roles lack read, graph list 403 without and 200 with a tenant, 200 with extra X-Knotrel-Auth-Groups/-Debug headers (Knotrel would answer 401 had they arrived); default console: 401 even with a complete identity, and a header-echo upstream receives no X-Knotrel-Auth-* header (forged and duplicated values included); relay on: the echo receives exactly Subject, Tenant and Roles |
| T3.12 | Graph resources changed or deleted through the console (T, E) | Only GET /v1/graphs and GET /v1/graphs/{graph_id} are forwarded; POST, PATCH, DELETE and paths below a graph are refused by the gateway |
smoke-container: “graph resources: GET list and GET one forwarded; POST, PATCH, DELETE and subpaths refused” (the graph is read back unchanged) |
B4 — Feeder routes
| ID | Threat | Mitigation | Validation |
|---|---|---|---|
| T4.1 | Stale feeder overwrites newer state after a takeover or lease expiry (T) | Session/epoch fencing, lease on the monotonic clock, instance ID on every request, If-Match replacement preconditions |
import.rs::test_3_exact_ownership_fencing_both_directions, test_9_session_takeover_and_lease_expiry_before_publication, test_14_strict_replacement_preconditions_negative_cases; events.rs::test_13_session_takeover_and_lease_expiry_before_execution, test_24_whole_request_fencing_rejections_apply_nothing; bootstrap.rs::test_14_session_retries_and_takeovers_cannot_bypass_synchronization_recovery, test_20_delayed_barrier_fenced_across_lease_expiry; e2e_rebuild.rs::test_15_lost_ack_combined_with_competing_ownership_takeover; PostgreSQL integration tests (postgres-feeder workflow, PostgreSQL 15–19) |
| T4.2 | Hostile client inside the boundary takes over the feeder session (S, E) | None in Knotrel by design: fencing protects against stale feeders, not against a hostile client. Any client that can reach /v1/feeder/session (the instance ID is public through GET /v1/info) can take over. Mitigated only by the boundary: in E3 by a separate feeder credential at the gateway |
Gateway smoke test T2.4; console smoke test T3.2 → G3 |
| T4.3 | Direct mutations bypass the source in source-managed mode (T) | Mutations refused with 409 direct_mutation_disabled; reads and inspection allowed |
batch.rs::test_05_source_managed_mode_rejects_mutating_batches_allows_query_only; inspection.rs::source_managed_reads_are_available_without_mutation |
| T4.4 | Replayed or reordered events corrupt state (T) | Delivery sequence with predecessor check and bounded exact deduplication | events.rs and bootstrap.rs sequence tests; integration contract §5–§7 |
| T4.5 | Feeder routes used in standalone mode (E) | 409 mode conflict | Gateway smoke test (“feeder credentials reach the feeder routes”, 409 from Knotrel) |
| T4.6 | Defect D1, found by the R3 soak: a feeder event with delivery_sequence: 0 right after an import panics the graph worker (D). After an import and before the first event of the generation is applied (applied_delivery_sequence == 0), check_sequence returns DedupLookup::Future for sequence 0 and the duplicate branch reaches DedupLookup::Future => unreachable!() in crates/knotrel-server/src/service.rs. By T1.15 the server then answers 503 unavailable to every request until it is restarted and rebuilt. Any client able to register a feeder session (in E3: any holder of the feeder credential) can make the server permanently unavailable with one request |
Fixed in knotrel/knotrel#104 (merged on main as 0fe35f6): sequence 0 is classified as evicted in every state and rejected with 409 unverifiable_duplicate without state mutation; no feeder input reaches an unreachable!() arm in apply_events |
events.rs::test_29 (sequence 0 after create_only and replace imports, server stays ready, later events accepted) and soak.rs::regression_d1_sequence_zero_at_generation_start; the soak sends sequence 0 in every state → N6 (closed) |
B5 — PostgreSQL and the reference feeder
| ID | Threat | Mitigation | Validation |
|---|---|---|---|
| T5.1 | Over-privileged feeder role used to modify the source (E) | Role with LOGIN REPLICATION and SELECT on the two tables only (sql/roles.sql) |
PostgreSQL integration tests run as an equivalent role created inline (integrations/postgres-feeder/tests/common/mod.rs; postgres-feeder workflow); roles.sql itself is not executed by a test |
| T5.2 | Password exposure on the command line or in images (I) | KNOTREL_PG_PASSWORD_FILE preferred; never a command-line argument; Compose secrets; generated secrets ignored by git |
Code review of integrations/postgres-feeder/src/config.rs; no automated test; doc (reference feeder) |
| T5.3 | WAL retention exhausts the source’s disk (D) | max_slot_wal_keep_size required (unbounded retention refused unless explicitly allowed); slot checks and cleanup |
integrations/postgres-feeder/tests/history.rs::unbounded_retention_is_refused and the other feeder integration tests |
| T5.4 | Eavesdropping on PostgreSQL traffic or the feeder’s HTTP traffic (I, T) | No TLS: the feeder connects to PostgreSQL with TLS disabled and its HTTP client is built without TLS support; supported only on a trusted network | Open → N2 |
| T5.5 | A compromised container on the reference Compose network controls Knotrel (E) | The reference example is E2: every service on its private network is trusted, and only the console is published, on loopback | Doc only (examples/postgres-feeder/compose.yaml header) |
B6 — Build and release
| ID | Threat | Mitigation | Validation |
|---|---|---|---|
| T6.1 | Vulnerable or malicious dependency (T, E) | Committed Cargo.lock and package-lock.json; exact npm versions; cargo deny (advisories; the feeder also licenses, bans, sources); npm audit --audit-level=high |
vulnerabilities workflow (every push, PR and weekly); postgres-feeder workflow; console workflow |
| T6.2 | Compromised CI action (T) | Actions pinned by commit SHA; permissions: contents: read by default |
Workflow files; reviewed, not tested |
| T6.3 | Tampered release artifacts (T) | SHA256SUMS over the whole bundle, build provenance receipts, signed tags, console archive reproducible on three platforms, SBOM workflow |
release workflow (inventory and checksum validation), console workflow (reproducibility job), sbom workflow; the release binary’s reproducibility is a separate rc gate (criterion 6) |
| T6.4 | Base image drift (T) | Container base images pinned by digest | Compose and Dockerfiles; reviewed, not tested |
6. Concrete security gaps from the readiness assessment
The four gaps listed in v1.0 readiness:
G1 — Import memory amplification
Status: mitigated and documented; sizing guide completed 2026-11-23 (O4).
- Evidence: v0.6.0 replaced the import parse with a streaming parse; a
100,000-node import peaked at 31–33 MiB (create) and 50 MiB (replace, old
graph still live) against 111–130 MiB in v0.5.0
(deployment guide, resource bullets;
resource model). Only one import runs at a time and
it is admitted before its body is read (
import.rs::test_1_…). The deployment guide says to size memory forold graph + import body + new graph, as the gate requires. - Remaining: a body that fails the streaming parse is parsed again by the former
parser with the v0.5.0 working set (documented in the resource model), so a
malformed 64 MiB import can still reach the old amplification once. Request
bodies on the other routes are buffered before admission, bounded by
KNOTREL_MAX_CONNECTIONS × 1 MiB(up to 1 GiB by default; admission); the deployment guide’s memory sizing does not mention this term. - Done (documentation): the memory sizing in
docs/deployment.mdnow lists every term — steady graph, compaction, replace import, the import body reserved in full when declared (backlog DV4), the malformed-import second parse, andKNOTREL_MAX_CONNECTIONS × 1 MiBof buffered bodies (1 GiB by default) — with a worked example for a 512 MiB container that lowersKNOTREL_MAX_CONNECTIONSto 128. Optional code proposal, 1.x: drop the second parse for bodies above a size threshold.
G2 — Lock-holding work per request
Status: open (documented qualitatively, not measured).
- Evidence: the costs are documented — a
connectedis anO(V + E)BFS, a batch has at most 1024 operations, query-only requests share the lock but delay mutations, feeder events and imports (concurrency and order); compaction is anO(V log V + E)rebuild and catalog growth anO(V)rebuild under the lock (topology lifecycle); a timed-out request does not stop its worker (timeouts). - Missing: the per-request worst-case lock time for the supported envelope
(for example a 1024-
connectedbatch and a compaction at the default limits of 100,000 nodes and 500,000 edges) and a decision on a configurable batch ceiling. - Proposed fix: measure both as part of the declared supported envelope
(criterion 4, rc) with declared criteria, publish them in
docs/http-api.mdand the deployment guide; propose an additive setting (for exampleKNOTREL_MAX_BATCH_OPERATIONS, default 1024, lower values allowed) as a maintainer decision. Both are server work outside this document.
G3 — Feeder takeover is unauthenticated by design
Status: met for documentation by this document (T4.2); mitigated in E3 and validated.
- Session fencing protects against stale feeders, not against a hostile client inside the boundary. Any client that can reach the feeder routes can take over (the instance ID is public). The deployment guide states that a second feeder takes over the session; this document states explicitly that this is not an authentication mechanism.
- Validation of the mitigation: in E3, feeder routes require a separate credential (gateway smoke test, T2.4); the console never forwards them (console smoke test, T3.2).
- Proposed follow-up (documentation): one sentence in integration contract §4 and the trust model linking here.
- Since v1.3.0: with
KNOTREL_AUTH=gateway-identitythe feeder routes need thefeeder-control,feeder-dataorimportrole in Knotrel itself (T7.4), in addition to the gateway’s routing; without the extension the mitigation is unchanged.
G4 — SECURITY.md is stale
Status: closed. Document fixed (knotrel/knotrel#106); reporting channel enabled by the maintainer and verified on 2026-11-23.
SECURITY.mdnow lists the supported versions by policy (latest minor release line; 0.9.x today, 1.0.x after 1.0.0), names GitHub Private Vulnerability Reporting as the only channel (the unaddressed email option is removed), and links this document.- Maintainer decision (2026-11-22): GitHub Private Vulnerability Reporting is the security channel, to be enabled and verified before the rc.
- rc gate closed (2026-11-23): it was disabled on
knotrel/knotrel(GitHub API"enabled": falseon 2026-11-22 and 2026-11-23). The maintainer enabled it on 2026-11-23. Verified the same day:GET /repos/knotrel/knotrel/private-vulnerability-reportingreturns{"enabled":true}, and the public Security page (fetched without signing in) shows Report a vulnerability. The channel published inSECURITY.mdworks.
7. Further findings of this review
Found while mapping mitigations to validations. None changes server behavior here; each is a proposal.
| ID | Finding | Severity within the trust model | Proposed fix |
|---|---|---|---|
| N1 | DNS rebinding against a directly reachable listener (E1, E2). Knotrel accepts any Host, so a web page in a browser that can reach the listener (on the same host as a loopback listener, or on the trusted network) can rebind its name to the listener’s address and read and mutate the graph, including taking over the feeder session after reading the instance ID from /v1/info. The console container (T3.3) and the gateway check Host only for requests that pass through them; they do not protect a listener the browser can still reach directly. CSRF without rebinding is blocked by the JSON content-type check (T1.11) |
Medium: E1 is the default exposure and trusts processes, not web pages | Explicit residual risk for 1.0, not resolved (section 8). Documented in the trust model, wording approved 2026-11-23: the protection requires that the listener is not reachable from any context where untrusted web content runs; using the console or a gateway is not by itself a mitigation. 1.x code proposal: an optional Host allowlist in the server (for example KNOTREL_ALLOWED_HOSTS, default loopback names and the bind address; 421 otherwise), additive, with a security test |
| N2 | Reference feeder has no TLS to PostgreSQL (NoTls, TlsConfig::disabled()) or to Knotrel (reqwest without a TLS feature), so it cannot be used through the gateway example and sends the PostgreSQL password and graph data in clear text |
Low for the documented local reference setup; blocks E3 for the reference feeder | Code proposal for the feeder: sslmode (require/verify-full) with a CA file for PostgreSQL; a rustls feature and a credential file for the Knotrel URL; extend the gateway smoke test with the reference feeder |
| N3 | Gateway example has no rate or connection limiting, although the trust model lists rate limiting among the gateway’s duties | Low (authenticated clients only) | Add limit_req/limit_conn per credential to examples/gateway/nginx.conf with a smoke-test check, or state the omission in the deployment guide |
| N4 | Unvalidated security configuration: console/deploy/nginx-gateway.conf (static archive) is packaged but never run or syntax-checked; the console container’s CSP and nosniff headers are not asserted by smoke-container.sh; the absence of CORS headers on Knotrel is not asserted |
Low | Add nginx -t and an allowlist check for the archive config in the console workflow; header assertions in smoke-container.sh; a CORS-preflight assertion in security.rs |
| N5 | Trust-model wording is narrower than the 1.0 exposure: docs/http-api.md said “a single trusted local client” while E2 and E3 are supported |
Documentation | Done: the trust model lists E1–E3, states that every client that can reach the listener is trusted and that web pages are not, and gives the DNS-rebinding condition (N1) |
| N6 | Defect D1 (T4.6), found by the R3 soak: a feeder event with delivery_sequence: 0 before the first event of a generation panics the graph worker and leaves the server permanently unavailable |
High for availability: one request from a registered feeder; in E3 limited to feeder-credential holders | Closed: fixed in knotrel/knotrel#104 with regression tests that pass in CI. To list in the rc release notes |
| N7 | Fail-stop amplifies every reachable panic (T1.15). Fail-stop itself is intended, but nothing shows that request input cannot reach a panic; D1 shows it can | Medium: depends on finding such inputs; D1 is one | Audit of panic sites on request and worker paths (replace input-reachable ones with request errors); a property or fuzz test sending arbitrary feeder envelopes and operations in every synchronization state and asserting no unavailable; keep the soak’s reference-model check. Optional maintainer decision: let a successful replace import clear the failed state instead of requiring a restart (behavior change, needs its own review) |
8. Residual risks accepted by the trust model
- Any client inside the boundary has full read access and, per mode, write and feeder access (no per-client authorization in Knotrel), unless the opt-in gateway-verified identity is enabled (B7, new in 1.3); that mode in turn relies on its two trust conditions.
- CPU per request is not bounded beyond the batch ceiling, graph limits and admission; a timed-out request keeps its worker; there are no write timeouts or slow-reader protection (non-guarantees).
- A worker panic is fail-stop: the server stays unavailable until restarted and rebuilt (T1.15); this is accepted, input-reachable panics are not (N7).
- Process RSS has no hard bound (allocator retention); a container memory limit is the operator’s control.
- The graph and its synchronization state are lost on restart; integrity after a restart depends on a rebuild from the authoritative source.
- Feeder session takeover is not authenticated (G3, T4.2); it is mitigated only by the boundary (a separate feeder credential at the gateway in E3).
- DNS rebinding (O1, N1) is an explicit residual risk, not resolved.
Knotrel does not validate
Host, so untrusted web content in a browser that can reach the listener can read and mutate the graph and take over the feeder session. The console container and the gateway do not protect a listener the browser can reach directly. The only protection in 1.0 is deployment: the listener is not reachable from any context where untrusted web content runs.
9. Maintenance
Update this document with any change to: routes, modes or the trust model; the console’s forwarding rules; the gateway example; resource bounds; the reference feeder’s connections; the release pipeline. Each new mitigation names its validation; a mitigation without one is listed as “doc only” or as a gap.
10. Maintainer acceptance (2026-11-23)
Recorded from the maintainer’s decision; it changes no code.
R1–R6 accepted as the architectural limits of 1.0, within the declared deployment perimeter (E1–E3, section 1). R1–R5 are the five limits of section 8; R6 is the unauthenticated feeder takeover (G3). This acceptance does not cover concrete vulnerabilities reachable from input: a panic, a bypass of a documented bound or any other input-reachable defect is a defect to fix, not an accepted risk (as D1 was, T4.6).
| ID | Item | Disposition | Explicit limitation | Tracked activity |
|---|---|---|---|---|
| O1 | DNS rebinding (N1, T1.12) | Explicit residual risk, not resolved. The earlier wording was not accepted; the revised wording in the trust model and in N1 was approved on 2026-11-23: the protection requires that the listener is not reachable from any context where untrusted web content runs, or that the backend validates Host itself, which Knotrel 1.0 does not. The console and the gateway do not protect a listener directly reachable from the browser |
A browser that can reach the listener is an open exposure in 1.0 | Backlog TM-O1: 1.x optional Host allowlist in the server |
| O2 | No audit of input-reachable panics (N7, T1.15) | Deferred to 1.x with a tracked activity | The soak does not replace an audit: it shows the absence of panics only for the inputs it generates | Backlog TM-O2: panic-site audit of request and worker paths, property or fuzz test of feeder envelopes in every synchronization state |
| O3 | Lock-holding work per request not measured (G2) | Deferred to 1.x with a tracked activity | The request timeout does not bound the work that continues in the worker: a timed-out request keeps its worker and the graph lock until the job ends | Backlog TM-O3: measure the worst-case lock time in the supported envelope; decide on a configurable batch ceiling |
| O4 | Memory sizing term missing (G1) | Done (section 6, G1): sizing guide completed in docs/deployment.md |
Figures are one graph shape and an upper-bound sum, not a guarantee | — |
| O5 | Reference feeder without TLS (N2) | Deferred to 1.x with a tracked activity | The reference feeder is supported only on a trusted network and cannot be used through the gateway (E3) | Backlog TM-O5: sslmode and CA file for PostgreSQL, rustls and a credential file for Knotrel, gateway smoke test with the feeder |
| O6 | Gateway example without rate or connection limits; unvalidated security configuration (N3, N4) | Deferred to 1.x with a tracked activity | The example is not a production gateway; the static-archive nginx configuration, the console’s CSP and nosniff headers and the absence of CORS headers on Knotrel are not asserted by tests |
Backlog TM-O6: limit_req/limit_conn in the example with a smoke check; nginx -t of the archive configuration; header and CORS-preflight assertions |
| O7 | Private Vulnerability Reporting disabled (G4) | rc gate closed: enabled by the maintainer and verified on 2026-11-23 (API "enabled": true; Report a vulnerability on the public Security page) |
— | Backlog TM-O7: verify after activation ("enabled": true from the API and Report a vulnerability on the Security tab) |