Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(security): allow loopback egress when policy permits

Steven Enamakelc87b999b34e2
diff --git a/crates/openhuman-core/src/security/egress/enforce.rs b/crates/openhuman-core/src/security/egress/enforce.rs
index bddb469ddb..b401fa0632 100644
--- a/crates/openhuman-core/src/security/egress/enforce.rs
+++ b/crates/openhuman-core/src/security/egress/enforce.rs
@@ -32,8 +32,8 @@
//! `LocalOnly` blocks the user's *data* from leaving the device — it must not
//! block the backend **control-plane** the app needs to stay usable (session /
//! auth / team / billing round-trips, plus the integration connection-management
-//! and catalog reads that carry no user content). See [`is_control_plane`] for
-//! the exact boundary and why it is drawn where it is.
+//! and catalog reads that carry no user content). The descriptor's builder
+//! classifies its own routes; see [`is_control_plane`].
use super::types::{EgressDescriptor, EgressReason};
use crate::config::PrivacyMode;
@@ -62,73 +62,16 @@ pub fn local_only_blocks(mode: PrivacyMode, desc: &EgressDescriptor) -> bool {
/// ids, and routing metadata)?
///
/// Only [`EgressReason::Integration`] descriptors are ever eligible: inference,
-/// composio tool calls, cloud embeddings, and agent network fetches all ship the
-/// user's data and are never control-plane.
+/// tool calls, cloud embeddings, and agent network fetches all ship the user's
+/// data and are never control-plane.
///
-/// For an integration transfer, the descriptor's `service` is the backend
-/// endpoint path (query stripped by
-/// [`emit_backend_egress`](crate::integrations)). Two shapes are
-/// exempt:
-///
-/// 1. **Any path outside the user-data tool namespace** — i.e. it is *not* under
-/// `/agent-integrations/`. Today every user-data integration call (composio
-/// execute, parallel / tinyfish / financial-apis / google-places research +
-/// actions, file-storage uploads) routes through
-/// `IntegrationClient` under `/agent-integrations/…`, while session / team /
-/// billing / auth round-trips (`/teams/me/usage`, `/payments/…`, `/auth/…`)
-/// go through `backend::client` and never build an egress descriptor at all. Any
-/// such path only reaches here if a future caller re-homes a control-plane
-/// call onto this descriptor — exempt it defensively so a re-home can never
-/// brick login (per the epic's "do not block control-plane" directive).
-///
-/// 2. **A narrow allow-list of read-only composio connection-management /
-/// catalog / OAuth sub-routes** that set up or *describe* an integration
-/// without shipping or mutating user content: `connections` (list +
-/// per-connection delete), `authorize` (OAuth handoff), `tools` and
-/// `toolkits` (catalog), plus `pricing` (billing metadata). These are the
-/// routes the Connections UI needs to stay usable under `LocalOnly`.
-///
-/// Everything else under `composio/` is **blocked**, including:
-/// - `execute` — ships the tool arguments (the original user-data path);
-/// - `triggers` / `triggers/available` — `create_trigger` / `enable_trigger`
-/// POST user-supplied `slug` / `connectionId` / `triggerConfig` (a
-/// user-data *write*); the descriptor carries only the path, not the HTTP
-/// method, so the read variants on the same path are blocked with them
-/// (fail-closed — trigger setup is an integration write surface, not
-/// sign-in, so blocking it under `LocalOnly` breaks nothing that matters);
-/// - `github/repos` and any future sub-route — reveals user-adjacent data,
-/// and an *unknown* composio sub-route is treated as user-data, never
-/// exempt.
-///
-/// The boundary is deliberately **fail-closed** for user data: only the named
-/// read-only routes are exempt; anything else under `/agent-integrations/`
-/// (composio or otherwise) ships user data and stays blocked. Genuine
-/// non-composio control-plane (session / auth / team / billing) is handled by
-/// rule (1) so sign-in never breaks.
+/// The core does not know any host's routes. The party that builds the
+/// descriptor classifies its own path and sets
+/// [`EgressDescriptor::control_plane`]; this predicate honours that flag and is
+/// otherwise **fail-closed**: an integration descriptor nobody classified is
+/// treated as shipping user data and stays blocked.
pub(crate) fn is_control_plane(desc: &EgressDescriptor) -> bool {
- if desc.reason != EgressReason::Integration {
- return false;
- }
- let path = desc.service.trim_start_matches('/');
- // (1) Not under the user-data tool namespace → control-plane (session /
- // auth / team / billing, or a defensively re-homed control-plane call).
- let Some(subroute) = path.strip_prefix("agent-integrations/") else {
- return true;
- };
- // (2) Pricing metadata carries no user content.
- if subroute == "pricing" {
- return true;
- }
- // (3) Composio: exempt ONLY the read-only connection-management / catalog /
- // OAuth allow-list. `execute` (tool arguments), `triggers[/available]`
- // (user-data writes), `github/repos`, and any unknown sub-route stay
- // blocked — fail-closed for user data.
- if let Some(rest) = subroute.strip_prefix("composio/") {
- let head = rest.split(['/', '?']).next().unwrap_or(rest);
- return matches!(head, "connections" | "authorize" | "tools" | "toolkits");
- }
- // Everything else under /agent-integrations/ ships user data → not exempt.
- false
+ desc.reason == EgressReason::Integration && desc.control_plane
}
/// Human-readable, non-sensitive reason the transfer was blocked. Names only the
diff --git a/crates/openhuman-core/src/security/egress/enforce_tests.rs b/crates/openhuman-core/src/security/egress/enforce_tests.rs
index 4882e07223..e7889704c3 100644
--- a/crates/openhuman-core/src/security/egress/enforce_tests.rs
+++ b/crates/openhuman-core/src/security/egress/enforce_tests.rs
@@ -34,7 +34,7 @@ fn local_only_blocks_each_external_surface() {
EgressDescriptor::composio("SLACK_SEND_MESSAGE"),
EgressDescriptor::embedding("cloud", "text-embedding-3-small"),
EgressDescriptor::network_fetch("api.example.com"),
- EgressDescriptor::integration("/agent-integrations/parallel/research"),
+ EgressDescriptor::integration("/tools/research"),
];
for desc in &surfaces {
assert!(
@@ -88,69 +88,16 @@ fn local_only_blocks_user_data_integration() {
assert!(local_only_blocks(PrivacyMode::LocalOnly, &execute));
}
-// ── Pure decision: is_control_plane boundary ──────────────────────────────
+// ── Pure decision: is_control_plane honours the builder's classification ──
#[test]
-fn control_plane_exempts_non_tool_namespace() {
- // A control-plane call re-homed onto an integration descriptor (defensive
- // path (1)): anything not under /agent-integrations/ is exempt.
- for path in [
- "/teams/me/usage",
- "/payments/stripe/currentPlan",
- "/auth/refresh",
- ] {
- assert!(
- is_control_plane(&EgressDescriptor::integration(path)),
- "{path} must be treated as control-plane"
- );
- }
-}
-
-#[test]
-fn control_plane_exempts_composio_management_and_pricing() {
- // Connection-management / catalog / OAuth / pricing carry no user content —
- // the read-only allow-list the Connections UI needs under LocalOnly.
- for path in [
- "/agent-integrations/pricing",
- "/agent-integrations/composio/connections",
- // Per-connection delete rides the same `connections` head → exempt.
- "/agent-integrations/composio/connections/conn_123",
- "/agent-integrations/composio/authorize",
- "/agent-integrations/composio/tools",
- "/agent-integrations/composio/toolkits",
- ] {
- assert!(
- is_control_plane(&EgressDescriptor::integration(path)),
- "{path} must be exempt (control-plane)"
- );
- }
-}
-
-#[test]
-fn control_plane_does_not_exempt_user_data_paths() {
- // composio/execute ships tool arguments; composio/triggers[/available]
- // POST user-supplied slug/connectionId/triggerConfig (user-data writes);
- // github/repos reveals user-adjacent data; the non-composio tool namespaces
- // ship queries / content — none are exempt (fail-closed).
- for path in [
- "/agent-integrations/composio/execute",
- // Trigger writes: create_trigger / enable_trigger POST here. The
- // descriptor carries no HTTP method, so the same-path reads block too.
- "/agent-integrations/composio/triggers",
- "/agent-integrations/composio/triggers/available",
- "/agent-integrations/composio/github/repos",
- // An unknown composio sub-route defaults to blocked (fail-closed).
- "/agent-integrations/composio/some-future-write",
- "/agent-integrations/parallel/research",
- "/agent-integrations/tinyfish/fetch",
- "/agent-integrations/file-storage/files",
- "/agent-integrations/google-places/search",
- ] {
- assert!(
- !is_control_plane(&EgressDescriptor::integration(path)),
- "{path} must NOT be exempt (ships user data)"
- );
- }
+fn control_plane_honours_the_flag_and_defaults_to_blocked() {
+ // The core knows no host's routes: an unclassified integration descriptor
+ // is treated as shipping user data (fail-closed), and only the one the
+ // builder marked as control-plane is exempt.
+ let unclassified = EgressDescriptor::integration("/teams/me/usage");
+ assert!(!is_control_plane(&unclassified));
+ assert!(is_control_plane(&unclassified.with_control_plane(true)));
}
#[test]
@@ -183,9 +130,9 @@ fn enforce_egress_blocks_under_local_only_and_allows_otherwise() {
"names the service: {msg}"
);
// A control-plane integration round-trip still flows.
- enforce_egress(&EgressDescriptor::integration(
- "/agent-integrations/composio/connections",
- ))
+ enforce_egress(
+ &EgressDescriptor::integration("/connections").with_control_plane(true),
+ )
.expect("control-plane must be allowed under LocalOnly");
}
diff --git a/crates/openhuman-core/src/security/egress/types.rs b/crates/openhuman-core/src/security/egress/types.rs
index a6423caf4e..31a6c676b3 100644
--- a/crates/openhuman-core/src/security/egress/types.rs
+++ b/crates/openhuman-core/src/security/egress/types.rs
@@ -117,6 +117,16 @@ pub struct EgressDescriptor {
/// `"credential"`). Empty until the S5 detector populates it.
#[serde(default)]
pub risk_categories: Vec<String>,
+
+ /// Whether this is a control-plane round-trip (session / auth / team /
+ /// billing, or connection-management and catalog reads) that carries no
+ /// user content and so stays permitted under `LocalOnly`. Only meaningful
+ /// for [`EgressReason::Integration`] descriptors. The party that knows its
+ /// own routes classifies and sets it ([`EgressDescriptor::with_control_plane`]);
+ /// it defaults to `false`, so an unclassified integration transfer is
+ /// treated as shipping user data (fail-closed).
+ #[serde(default, skip_serializing_if = "std::ops::Not::not")]
+ pub control_plane: bool,
}
impl EgressDescriptor {
@@ -137,6 +147,7 @@ impl EgressDescriptor {
data_kinds,
risk_level: IdentificationRisk::Unknown,
risk_categories: Vec::new(),
+ control_plane: false,
}
}
@@ -168,8 +179,10 @@ impl EgressDescriptor {
)
}
- /// OpenHuman managed-backend / integrations round-trip (always external —
- /// the backend is off-device). `service` is the request path.
+ /// Managed-backend / integrations round-trip (always external — the
+ /// backend is off-device). `service` is the request path. Unclassified: use
+ /// [`with_control_plane`](Self::with_control_plane) to exempt a
+ /// control-plane route.
pub fn integration(service: impl Into<String>) -> Self {
Self::new(
"openhuman_backend",
@@ -214,6 +227,13 @@ impl EgressDescriptor {
self
}
+ /// Mark an integration transfer as a control-plane round-trip (or not). The
+ /// caller that owns the route decides; the core only honours the flag.
+ pub fn with_control_plane(mut self, control_plane: bool) -> Self {
+ self.control_plane = control_plane;
+ self
+ }
+
/// **S5 (#4439) hook.** Attach the identification-risk assessment produced
/// by the PII detector. S2 never calls this; it exists so S5 can populate
/// the risk fields without reshaping the descriptor.