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
feat(platform): enforce secure socket endpoints
Steven Enamakel869b0f0d8fd2
diff --git a/crates/openhuman-core/src/platform/socket/manager.rs b/crates/openhuman-core/src/platform/socket/manager.rsindex 5d5a340c25..51380a5172 100644--- a/crates/openhuman-core/src/platform/socket/manager.rs+++ b/crates/openhuman-core/src/platform/socket/manager.rs@@ -389,6 +389,10 @@ impl SocketManager {provider: TokenProvider,token: String,) -> Result<(), String> {+ let ws_url = super::url::websocket_url(url);+ if !super::url::is_safe_socket_endpoint(&ws_url) {+ return Err("socket credential requires WSS or a loopback WS endpoint".to_string());+ }// Ensure the rustls crypto provider is installed (needed for wss:// TLS).// This is a no-op if already installed.let _ = rustls::crypto::ring::default_provider().install_default();diff --git a/crates/openhuman-core/src/platform/socket/token_provider.rs b/crates/openhuman-core/src/platform/socket/token_provider.rsindex 5cf62f3afa..0259d755b4 100644--- a/crates/openhuman-core/src/platform/socket/token_provider.rs+++ b/crates/openhuman-core/src/platform/socket/token_provider.rs@@ -76,11 +76,15 @@ pub(super) fn static_token_provider(token: String) -> TokenProvider {/// refreshed or re-stored since the previous attempt.pub(crate) fn token_provider_from_config(config: Arc<crate::config::Config>) -> TokenProvider {Arc::new(move || {- crate::security::credentials::session_support::backend_bearer_secret(&config)+ let token = crate::security::credentials::session_support::backend_bearer_secret(&config).map_err(|e| format!("failed to read session token: {e}"))?.ok_or_else(|| {"no session token stored — user must log in first or set an API key".to_string()- })+ })?;+ if crate::security::credentials::session_support::is_local_session_token(&token) {+ return Err("offline local session cannot connect to hosted socket".to_string());+ }+ Ok(token)})}diff --git a/crates/openhuman-core/src/platform/socket/ws_loop/connect.rs b/crates/openhuman-core/src/platform/socket/ws_loop/connect.rsindex d746d5bfe1..9ac49a9ce9 100644--- a/crates/openhuman-core/src/platform/socket/ws_loop/connect.rs+++ b/crates/openhuman-core/src/platform/socket/ws_loop/connect.rs@@ -407,6 +407,12 @@ pub(super) async fn connect_with_redirects_within() -> Result<WsStream, WsError> {let original = ws_url.clone();for hop in 0..=MAX_REDIRECT_HOPS {+ if !crate::platform::socket::url::is_safe_socket_endpoint(ws_url) {+ return Err(WsError::Io(std::io::Error::new(+ std::io::ErrorKind::PermissionDenied,+ "socket credential requires WSS or a loopback WS endpoint",+ )));+ }let attempt =match tokio::time::timeout(connect_timeout, connect_async(ws_url.as_str())).await {Ok(attempt) => attempt,