Repository navigation
Description
Follow-up to #7522 (storage over the bus) and #7433 (process-state inventory).
Summary
In SaaS mode, one core process serves many user profiles. The audit question is whether data can cross from one profile to another, especially over the TinyBus module bus.
Current answer: no confirmed cross-profile leak exists today. That holds because SaaS exposes only a narrow surface:
- Domains: operator, threads, channels, memory.
- RPC: the
USER_METHODSallowlist. - Tools: browser, computer, desktop and MCP-registry tools are hard-denied.
The bus itself is not profile-aware. Isolation is incidental, not structural:
- Every cdylib module is loaded once per process and shared by all profiles.
- Requests carry no profile, and no host interface authenticates the caller.
- Several modules hold process-wide configuration that is reconfigured per call without holding a lock across the call.
Enabling one more domain for profiles (e.g. Integrations) would turn latent issues into real leaks. This issue makes profile confinement on the bus a structural guarantee, enforced and tested.
How isolation works today
-
Carrier: the gateway (
crates/openhuman-rpc/src/server/saas_gateway.rs) verifies bearer + HMAC user signature, then runs the request insideCoreContext::scope(profile.context(), …). The profile travels in the task-localCURRENT_CONTEXT(core/runtime/context.rs). -
Tenant-sensitive reads go through
CoreContext::scoped()/tenant::current_tenant, which fail closed withNoTenant(core/runtime/tenant.rs).storage::scope_fromrefuses SaaS calls without a profile. SaaS config loading fails closed without scope (config/ops/loader/load.rs). -
The task-local does not cross the bus. tinybus runs each incoming call in a fresh task (
vendor/tinybus/crates/tinybus/src/connection.rs). Inside a host-served interface handler the profile is absent unless it was captured when the handler was built. -
Existing coverage:
tests/saas_profile_isolation_e2e.rs(canary fuzz overUSER_METHODS)tests/saas_mode_e2e.rscrates/openhuman-embed/tests/saas_profiles.rs- tenant proptests
None of these exercise module bus calls from interleaved profiles.
Findings (verified against code; paths under crates/openhuman-core/src/ unless noted)
Module bus
| # | Risk | Reachable in SaaS today? | Finding |
|---|---|---|---|
| 1 | High | No (becomes yes if Integrations is enabled for profiles; affects desktop user switch + multi-config embedders now) | tinyconnectors route swap race. modules/connectors.rs proxy() → ensure_routed() sends Configure (the Composio bearer/API key) under a lock that is released before the actual member call. Caller A can execute on caller B's credential, i.e. against B's connected accounts. The module keeps one Composio client per process (vendor/tinyconnectors/.../tinybus_module/mod.rs). Scope prefs, which gate Execute, are process-wide under the first loader's state_dir. The serializing lock in integrations/composio/module_client.rs is test-only. |
| 2 | Medium | Yes (runs on every tool result) | tinyjuice install/compact race + global CCR store. inference/tokenjuice/mod.rs::install_from_config holds its mutex only for Install; CompactWith runs after release. With ccr_disk_enabled / repl_save_enabled on (default off), A's raw tool output can be written under B's .tokenjuice/. The CCR store is process-global (vendor/tinyjuice/src/cache/store.rs) and keyed by content hash. Retrieve has no scope check (vendor/tinyjuice/crates/tinyjuice-module/src/service.rs), so any holder of a handle reads it, and possession of the content tests whether another profile fetched it. The savings snapshot moves between workspaces (inference/tokenjuice/savings.rs). The summary cache is keyed by thread id + raw content. |
| 3 | Medium | No (desktop/embedder) | tinycomputer reconfigure race. modules/desktop.rs releases its lock before long calls (RunGoal, up to 330 s). Another caller's bearer and trace path can be swapped in mid-run, so screen traces land in the wrong workspace. |
| 4 | Medium-low | No (channel runtime not started in SaaS) | Channel host callbacks are not scoped. channels/runtime/startup/callback.rs: persist_allowed_identity writes root ~/.openhuman/config.toml (channels/host/adapters.rs), not users/<id>/config.toml. report_status / publish_event publish untagged DomainEvents outside the captured scope. |
| 5 | Low | Fails closed in SaaS | Wallet host callbacks resolve config ambiently (modules/wallet_host.rs). On desktop/embed they get the default context, not the caller's. authorize_x402_payment checks a task-local that never crosses the bus, so it always refuses (safe, but likely a functional bug). |
| 6 | Low | — | tinybus has no tenant or ACL concept. No tenant field on Header/CallContext/MatchRule. The broker routes any peer to any destination. The default call_with_context ignores the caller, and nothing in crates/ uses authenticated_sender. Well-known names go to whoever claims first (ChannelsHost is claimed lazily and could be squatted). accept_stream does not check stream ownership, and stream ids are sequential. Mitigated today because all peers are first-party, digest-pinned and in-memory. |
Process-global state adjacent to the bus
| # | Risk | Finding |
|---|---|---|
| 7 | Medium (unverified path) | Shared attachment stash. ATTACHMENTS_DIR (agent/multimodal.rs) is only initialized when the Agent domain is on, which it is not in SaaS. All profiles then share fallback_attachments_dir() (OS user cache openhuman-attachments). rehydrate_image_placeholders resolves #att:<id> against that shared content-hash index on every session-host turn. There is no live writer today, but the read path is unscoped. |
| 8 | Medium-low | CURRENT_USER identity slot (security/credentials/identity.rs) is one process slot read by every turn's prompt/tracing identity. In SaaS it holds the operator identity (writes are refused), so users see the operator's identity, not each other's. Any future writer leaks to all. |
| 9 | Low-medium | Tool-discovery SETTINGS/RANKER (agent/tinyagents/discovery/mod.rs) is a single slot overwritten per session. |
| 10 | Low | DomainEvent has no profile field. Handlers do not inherit the publisher's scope. Mitigated per subscriber (several are not registered in SaaS). /events/domain streams all events unfiltered to the service bearer, but the SaaS gateway closes /events/*. |
Already properly confined (keep, and cover with tests)
- tinyjuice model-callback tickets (random, one-use, turn-bound).
- tinychannels per-lease random object paths with captured scope + workspace.
channel_relay_inboundrequires a profile.- tinysearch reconfigures and calls under one lock with a profile-binding check (
modules/search/proxy.rs). - tinymcp per-workspace objects.
- tinyconnectors archive handles (random 128-bit).
- Web chat events are profile-stamped from the task scope and cannot be forged by a module.
- Credentials are sent only to attested artifacts.
Proposed design: profile confinement as a bus invariant
- Profile travels on every host→module call, set by the host.
- Add a host-stamped
tenant(opaque profile key fromtenant::profile_key) to the module call context. This means a tinybusHeaderextension that only the host connection may set, and the broker overwrites it likesender. - Modules key every piece of per-user state by it: caches, clients, configs, stores.
- Contract crates gain no per-method profile parameters; it is ambient on the call, not in the body.
- Add a host-stamped
- No process-wide per-user module config.
- Replace "reconfigure, then call" with per-call credentials or per-tenant instances inside the module (a
tenant -> clientmap with LRU). tinysearch's lock-across-call is the interim pattern;call_stateless(credential on the request) is the target pattern. - Remove the global
Configure/Install/reinitializefor anything that carries a credential or a workspace path.
- Replace "reconfigure, then call" with per-call credentials or per-tenant instances inside the module (a
- Host-served interfaces authenticate and re-derive scope.
- Every
serve_atinterface implementscall_with_context, checksauthenticated_sender()against the expected module, and runs the handler under the scope captured at lease time (or derived from the stamped tenant). It never uses ambient config. - Claim all host well-known names at broker start, before any module loads.
- Every
- Module-held caches and stores are tenant-partitioned. tinyjuice CCR/summary/savings, tinyconnectors prefs, tinycomputer traces. With Storage: make tinystoragedrivers the only storage owner, provisioned to every tiny* crate through ports and TinyBus #7522 these move onto
ScopedStoragehanded out per tenant, which removes module-owned disk paths entirely. - Signals and events carry tenant. Module signals and the
DomainEvents that host callbacks publish are stamped with the tenant. Subscribers that act on user data filter by it, and untagged events are dropped in SaaS (as web chat already does). - tinybus hardening upstream (ROADMAP M4): a per-interface caller policy, stream accept ownership, random stream ids.
Task list
- tinybus: host-stamped tenant on call context; per-interface caller policy;
accept_streamownership check; random stream ids. - tinyconnectors: per-call credential / per-tenant client and per-tenant scope prefs; delete process-wide
Configurefor credentials. Host: removeensure_routedrace. - tinyjuice: per-tenant CCR store +
Retrievescope check, per-tenant disk/save dirs, summary-cache tenant key. Host: one call carrying install settings, or install + compact under one lock as a stopgap. - tinycomputer: per-call bearer/trace path; host holds no global reconfigure.
- Channels host callbacks: write the per-profile config; publish under the captured scope with tenant-stamped events.
- Wallet host: resolve config from the lease-captured context; fix the
authorize_x402_paymenttask-local check. - Attachments: per-profile attachments dir (
users/<id>/attachments) orScopedStorageblobs ([cloud-storage] blobs: attachments, artifact bytes, generated media and downloads onto BlobStore #7425); refuse rehydration without scope in SaaS. -
CURRENT_USER, discoverySETTINGS: move intoCoreContext. - CI ratchet: extend
scripts/ci/check-saas-ambient.mjs/check-process-statics.mjsto flag host interfaces withoutcall_with_contextand module calls preceded by a global reconfigure.
Acceptance criteria
- A new e2e (
tests/saas_bus_isolation_e2e.rs) runs two profiles concurrently through every module reachable in SaaS (tinyjuice, tinychannels relay, tinysearch) and, with Integrations force-enabled, tinyconnectors.- It plants canaries (credentials, tool outputs, CCR handles, attachments) per profile.
- It asserts none appear in the other profile's replies, files, events or upstream requests.
- It fails on today's code for findings 1 and 2.
- Unit/regression test per finding (1–5, 7), failing before the fix.
- Every host-served bus interface rejects calls from an unexpected sender (negative tests).
process-state.mdupdated: each row in the findings tables above is either fixed or explicitly accepted with a reason.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
tinysweeper commentedon Oct 13, 2026
Design/hardening request making per-profile confinement a structural guarantee on the TinyBus module bus in SaaS mode: host-stamped tenant on call contexts, removal of process-wide per-user module config, authenticated host-served interfaces, tenant-partitioned caches/stores, and tenant-stamped events. No confirmed cross-profile leak exists today (isolation is incidental), but reachable latent races are documented (tinyjuice CCR/install-compact, reachable on every tool result; tinyconnectors route swap) alongside several latent ones, plus an e2e canary test and CI ratchet as acceptance criteria. Follow-up to #7522 and #7433; security-adjacent hardening with no demonstrated exploit, so p2.
Labelled
priority: p2.M3gA-Mind commentedon Nov 16, 2026
Re-checked on current main. Module-bus calls still carry no tenant (tinybus
Header/CallContexthave no tenant field), so the guarantee still rests on the narrow SaaS surface described here. One step landed: #8578 and #8579 make the host answer callbacks only from the module they belong to. Keeping this open, together with #7647.