Skip to content

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

fix(attachments): reject unsupported media URL schemes

Steven Enamakeld1aaebcfae78
diff --git a/crates/openhuman-core/src/attachments/provider_owner.rs b/crates/openhuman-core/src/attachments/provider_owner.rs
index 881a6f9d25..90497065dd 100644
--- a/crates/openhuman-core/src/attachments/provider_owner.rs
+++ b/crates/openhuman-core/src/attachments/provider_owner.rs
@@ -71,6 +71,12 @@ impl MediaSourceResolver<AttachmentAccessScope> for AttachmentModel {
max_bytes: usize,
mime_hint: Option<&str>,
) -> Result<ResolvedMedia, String> {
+ if source.contains("://")
+ && !source.starts_with("http://")
+ && !source.starts_with("https://")
+ {
+ return Err("unsupported media URL scheme".into());
+ }
let block = match modality {
InputModality::Image => ContentBlock::Image(ImageRef {
url: source.to_owned(),
diff --git a/crates/openhuman-core/src/attachments/provider_routing_tests.rs b/crates/openhuman-core/src/attachments/provider_routing_tests.rs
index dfbb7ec4e1..8024171555 100644
--- a/crates/openhuman-core/src/attachments/provider_routing_tests.rs
+++ b/crates/openhuman-core/src/attachments/provider_routing_tests.rs
@@ -265,7 +265,7 @@ async fn text_archive_and_unavailable_pdf_dispatch_to_distinct_fallbacks() {
ContentBlock::Text(text) => text.as_str(),
_ => panic!("expected fallback text"),
};
- assert!(text(1).contains("Document content (untrusted)"));
+ assert!(text(1).contains("[FILE-EXTRACTED: name=\"note.txt\""));
assert!(text(1).contains("visible text payload"));
assert!(text(2).contains("Archive listing"));
assert!(text(2).contains("inside.txt"));
diff --git a/crates/openhuman-core/src/attachments/provider_tests.rs b/crates/openhuman-core/src/attachments/provider_tests.rs
index 9281b8565b..9ee636fa2a 100644
--- a/crates/openhuman-core/src/attachments/provider_tests.rs
+++ b/crates/openhuman-core/src/attachments/provider_tests.rs
@@ -225,7 +225,7 @@ async fn unknown_video_retains_path_as_metadata_without_specialist() {
let captured = probe.requests.lock().unwrap().clone();
let text = captured[0].messages[0].text();
assert!(text.contains("clip.mp4"));
- assert!(text.contains("14 bytes"));
+ assert!(text.contains("size=\"14 B\""));
assert!(!serde_json::to_string(&captured[0])
.unwrap()
.contains("base64"));