Skip to content

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

fix(core): enforce provider matching for native media scope

Steven Enamakelaa9ccdc7a2dc
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media.rs
index 462237709d..85b363ffe9 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media.rs
@@ -273,6 +273,9 @@ fn media_scope(envelope: &ChannelInboundEnvelope) -> Result<HostVoiceScope, Stri
{
return Err("native media has an incomplete conversation scope".into());
}
+ if tinychannels_bus::provider_id(configured_instance) != envelope.channel.id {
+ return Err("native media account does not match its provider".into());
+ }
Ok(HostVoiceScope {
configured_instance: configured_instance.to_owned(),
channel: envelope.channel.clone(),
@@ -531,7 +534,6 @@ impl Drop for MediaReadLease {
self.dispatch.spawn(async move {
let _ = client
.call_confidential::<()>(
- "tinychannels",
tinychannels_bus::methods::ABORT_MEDIA_READ,
(MediaReadFinish(handle),),
)
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media_tests.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media_tests.rs
index 29730aef18..f03fe49dd5 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media_tests.rs
@@ -156,6 +156,15 @@ fn module_media_scope_preserves_account_full_conversation_and_provider_turn() {
..envelope
};
assert!(media_scope(&missing_account).is_err());
+
+ let mismatched_account = ChannelInboundEnvelope {
+ channel: tinychannels_bus::ChannelRef {
+ id: "telegram".into(),
+ account_id: Some("discord:work".into()),
+ },
+ ..envelope
+ };
+ assert!(media_scope(&mismatched_account).is_err());
}
#[test]
diff --git a/crates/openhuman-core/src/channels/runtime/startup/module_providers_tests.rs b/crates/openhuman-core/src/channels/runtime/startup/module_providers_tests.rs
index 8c788e6386..b2a14f23ea 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/module_providers_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/module_providers_tests.rs
@@ -550,7 +550,7 @@ async fn dropped_scoped_media_read_lease_aborts_the_compiled_module_handle() {
assert_eq!(replay, first_chunk);
let handle = read.handle.clone();
crate::channels::runtime::dispatch::drop_media_read_lease_for_test(
- runtime.client.clone(),
+ runtime.lease.object().clone(),
dispatch_ctx,
read.handle,
);