Skip to content

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

fix(threads): validate inbound envelope identity before persisting

Steven Enamakel11c7037397fc
diff --git a/crates/openhuman-core/src/threads/store/bus.rs b/crates/openhuman-core/src/threads/store/bus.rs
index 7769b52df5..0cb69bc2de 100644
--- a/crates/openhuman-core/src/threads/store/bus.rs
+++ b/crates/openhuman-core/src/threads/store/bus.rs
@@ -398,6 +398,14 @@ async fn persist_channel_turn(
workspace_dir: &Path,
descriptor: ChannelTurnDescriptor<'_>,
) -> Result<(), String> {
+ if let Some(envelope) = descriptor.inbound_envelope
+ && (envelope.channel.id != descriptor.channel
+ || envelope.message_id != descriptor.message_id
+ || envelope.sender.id != descriptor.sender
+ || envelope.conversation.id != descriptor.reply_target)
+ {
+ return Err("inbound envelope identity does not match message".into());
+ }
// The fixture exists only where both features compile it (channels/mod.rs).
#[cfg(all(test, feature = "channels", feature = "modules"))]
let client = crate::channels::module_fixture::client().await;