diff --git a/crates/tinysecurity-module/src/adapter.rs b/crates/tinysecurity-module/src/adapter.rs index d9cee565..220de3db 100644 --- a/crates/tinysecurity-module/src/adapter.rs +++ b/crates/tinysecurity-module/src/adapter.rs @@ -1014,11 +1014,17 @@ impl PolicyService { .await } /// Authorize one browser proxy destination using its registered egress policy. + /// + /// The three browser dial members answer even when audit is required. A dial + /// carries no payload and no host audit correlation (the proxy opens one per + /// connection, with no turn behind it to bind an event to), and it only ever + /// applies the destination rules of a policy the authenticated host + /// registered. Refusing them under required audit refused every page of a + /// host that runs this module as its secret authority. async fn authorize_browser_dial( &self, request: tinysecurity_bus::BrowserDialRequest, ) -> BusResult { - self.require_unbound_permission()?; let scope = self .egress .lock() @@ -1037,7 +1043,6 @@ impl PolicyService { &self, request: tinysecurity_bus::ConsumeBrowserDialRequest, ) -> BusResult { - self.require_unbound_permission()?; let scope = self .egress .lock() @@ -1054,7 +1059,6 @@ impl PolicyService { &self, request: tinysecurity_bus::ValidateBrowserDialRequest, ) -> BusResult { - self.require_unbound_permission()?; let scope = self .egress .lock() diff --git a/crates/tinysecurity-module/src/adapter_tests.rs b/crates/tinysecurity-module/src/adapter_tests.rs index 4a6fa3f5..be2a5b53 100644 --- a/crates/tinysecurity-module/src/adapter_tests.rs +++ b/crates/tinysecurity-module/src/adapter_tests.rs @@ -1622,6 +1622,73 @@ async fn native_open_public_policy_and_credentials_only_redaction_dispatch() Ok(()) } +/// A host that runs TinySecurity as its secret authority makes audit required, +/// and the browser dial members carry no audit correlation. They must still +/// authorize, consume and validate: refusing them refused every browser +/// navigation ("required audit needs bound permission", seen as Chrome's +/// ERR_TUNNEL_CONNECTION_FAILED on every page). +#[tokio::test] +async fn browser_dials_are_authorized_when_audit_is_required() +-> std::result::Result<(), Box> { + let bus = MemoryBus::new(); + let task = Broker::new().spawn(bus.clone()); + let host = Connection::connect(bus.connect().await?).await?; + let module = Connection::connect(bus.connect().await?).await?; + let audit = crate::callbacks::AuditClient::new_for_test( + module, + crate::callbacks::PeerBinding::new( + host.unique_name().as_ref().map(tinybus::BusName::as_str), + )?, + AuditConfig2 { + scope: SubjectScope { + user: "user".into(), + workspace: "workspace".into(), + agent: "agent".into(), + }, + stream_id: "a".repeat(32), + timeout_ms: 100, + required: true, + native_path: None, + max_bytes: 10000, + max_archives: 3, + journal_max_bytes: 100_000, + journal_max_events: 1000, + }, + tinysecurity::Redactor::new(&RedactorConfig::default())?, + )?; + let server = Connection::connect(bus.connect().await?).await?; + let service = service_for( + Arc::new(RwLock::new(Policy::new(ModuleConfig::default())?)), + Some(Arc::new(audit)), + ); + assert!(service.audit_required()); + server.serve_at(names::OBJECT_PATH.try_into()?, service).await?; + server.request_name(names::INTERFACE).await?; + let client = Connection::connect(bus.connect().await?).await?; + let proxy = client.proxy(names::INTERFACE, names::OBJECT_PATH, names::INTERFACE)?; + let policy = EgressPolicy { + owner: SubjectScope { + user: "user".into(), + workspace: "workspace".into(), + agent: "agent".into(), + }, + ceiling: AccessTier::Full, + privacy: PrivacyMode::Standard, + destinations: vec![], + data_categories: vec![DataCategory::OpaqueBrowserTraffic], + local_capabilities: vec![], + validity_ms: 30000, + open_public: true, + preflight_transports: vec![EgressTransport::Browser], + }; + let id: EgressPolicyId = proxy + .call(names::methods::REGISTER_EGRESS_POLICY, (policy,)) + .await?; + assert_browser_dial_contract(&proxy, id).await?; + task.abort(); + Ok(()) +} + /// Exercise existing scoped egress dispatch against a live native module fixture. async fn assert_scoped_egress_contract( proxy: &tinybus::Proxy, diff --git a/docs/specs/browser-dial-contract-1.28.md b/docs/specs/browser-dial-contract-1.28.md index 55ed8358..5f29828d 100644 --- a/docs/specs/browser-dial-contract-1.28.md +++ b/docs/specs/browser-dial-contract-1.28.md @@ -38,3 +38,11 @@ oversized answer sets, private or otherwise non-global candidates, expired grants, stale generations, mismatched scope or destination, and replayed consumption all deny. The host must call this member only through its private authenticated adapter; JSON identity fields never authenticate themselves. + +Required audit does not refuse these three members. A host that makes +TinySecurity its secret authority runs with audit required, which refuses +every permission member that carries no audit correlation. A browser dial has +none to carry: the proxy opens one per connection, with no agent turn behind +it to bind a durable event to, and the member only applies the destination +rules of a policy the authenticated host registered. Refusing them refused +every page such a host's browser opened.