The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix: reject non-ASCII input instead of panicking on byte slices
M3gA-Minde20f589e59da
diff --git a/crates/openhuman-core/src/security/secret_storage/crypto.rs b/crates/openhuman-core/src/security/secret_storage/crypto.rsindex 37d7f60afa..dd5067ffb0 100644--- a/crates/openhuman-core/src/security/secret_storage/crypto.rs+++ b/crates/openhuman-core/src/security/secret_storage/crypto.rs@@ -42,6 +42,11 @@ pub(super) fn hex_encode(data: &[u8]) -> String {/// Decode a hex string into bytes.pub(super) fn hex_decode(hex: &str) -> Result<Vec<u8>, String> {+ // Decoding slices by byte, so a non-ASCII character would split mid-char+ // and panic. Hex is ASCII; reject anything else as invalid input.+ if !hex.is_ascii() {+ return Err("hex string is not ASCII".to_string());+ }if !hex.len().is_multiple_of(2) {return Err("hex string has odd length".to_string());}diff --git a/crates/openhuman-core/src/security/secret_storage/crypto_tests.rs b/crates/openhuman-core/src/security/secret_storage/crypto_tests.rsindex 41b8a7ac2a..f716d13e72 100644--- a/crates/openhuman-core/src/security/secret_storage/crypto_tests.rs+++ b/crates/openhuman-core/src/security/secret_storage/crypto_tests.rs@@ -29,3 +29,11 @@ fn hex_roundtrip() {assert_eq!(hex_encode(&data), "deadbeef");assert_eq!(hex_decode("deadbeef").unwrap(), data);}++#[test]+fn hex_decode_rejects_non_ascii_input_without_panicking() {+ // Even byte length, but byte 2 falls inside 'é'.+ let decoded = std::panic::catch_unwind(|| hex_decode("aéb"))+ .expect("hex_decode panicked on non-ASCII input");+ assert!(decoded.is_err());+}diff --git a/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend.rs b/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend.rsindex d33a01afc8..85fcce24c6 100644--- a/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend.rs+++ b/crates/openhuman-core/src/security/secret_storage/encrypted_file_backend.rs@@ -290,11 +290,6 @@ fn parse_master_key_hex(hex: &str) -> Result<[u8; KEY_LEN], String> {if got != expected {return Err(format!("expected {expected} hex characters, got {got}"));}- // `hex_decode` slices by byte; a non-ASCII value of the right character- // count would panic there instead of being rejected.- if !hex.is_ascii() {- return Err("value is not valid hex".to_string());- }let bytes = crypto::hex_decode(hex).map_err(|_| "value is not valid hex".to_string())?;let mut key = [0u8; KEY_LEN];key.copy_from_slice(&bytes);diff --git a/crates/openhuman-core/src/web_chat/session.rs b/crates/openhuman-core/src/web_chat/session.rsindex 8e2254f36d..0c0c803f76 100644--- a/crates/openhuman-core/src/web_chat/session.rs+++ b/crates/openhuman-core/src/web_chat/session.rs@@ -164,11 +164,7 @@ pub(super) fn build_session_agent(json!({"client_id": client_id, "thread_id": thread_id}).to_string(),"web_channel",);- let short_thread = if thread_id.len() > 12 {- &thread_id[..12]- } else {- thread_id- };+ let short_thread: String = thread_id.chars().take(12).collect();agent.set_agent_definition_name(format!("{target_agent_id}_{short_thread}"));// Bind the conversation's durable identity here, not after// checkout: everything downstream — resume, transcript binding,diff --git a/crates/openhuman-core/src/web_chat/session_routing_tests.rs b/crates/openhuman-core/src/web_chat/session_routing_tests.rsindex 379fd13dcc..250cc1e256 100644--- a/crates/openhuman-core/src/web_chat/session_routing_tests.rs+++ b/crates/openhuman-core/src/web_chat/session_routing_tests.rs@@ -454,3 +454,26 @@ fn persisted_mixed_case_cloud_default_uses_configured_slug_after_restart() {"restoring a persisted picker default must remain turn-local");}++#[tokio::test]+async fn a_non_ascii_thread_id_builds_a_session_agent_without_panicking() {+ let tmp = tempfile::tempdir().unwrap();+ let config = super::session_checkout_tests::test_config(&tmp);+ // 11 ASCII bytes, then a 3-byte char: byte 12 falls inside '日'.+ let thread_id = "abcdefghijk日本";+ let built = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {+ super::build_session_agent(+ &crate::core::runtime::DispatchCtx::ambient(),+ &config,+ "client-1",+ thread_id,+ "orchestrator",+ None,+ None,+ )+ .map(|_| ())+ }))+ .expect("build_session_agent panicked on a non-ASCII thread id");+ // The label truncation only runs once the agent builds.+ built.expect("session agent must build");+}