Skip to content

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

feat(platform): add safety check for credential-bearing socket endpoints

Steven Enamakelb34144b999a2
diff --git a/crates/openhuman-core/src/platform/socket/url.rs b/crates/openhuman-core/src/platform/socket/url.rs
index fadef32e1c..dc435f8581 100644
--- a/crates/openhuman-core/src/platform/socket/url.rs
+++ b/crates/openhuman-core/src/platform/socket/url.rs
@@ -2,6 +2,19 @@
use url::Url;
+/// Permit credential-bearing socket connections only over TLS or loopback.
+pub(super) fn is_safe_socket_endpoint(endpoint: &str) -> bool {
+ let Ok(mut url) = Url::parse(endpoint) else { return false; };
+ match url.scheme() {
+ "wss" => url.set_scheme("https").is_ok(),
+ "ws" => {
+ if url.set_scheme("http").is_err() { return false; }
+ crate::inference::provider::openhuman_backend_model::is_safe_endpoint_for_managed_bearer(url.as_str())
+ }
+ _ => false,
+ }
+}
+
/// Build a Socket.IO WebSocket URL from an HTTP(S) API base (e.g. `https://api.tinyhumans.ai`).
pub fn websocket_url(http_or_https_base: &str) -> String {
let Ok(mut url) = Url::parse(http_or_https_base) else {