Skip to content

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

fix(live_voice): validate origin on live voice WebSocket upgrade

Steven Enamakelfbe1bb954e00
diff --git a/crates/openhuman-rpc/src/server/http/live_voice.rs b/crates/openhuman-rpc/src/server/http/live_voice.rs
index 4d6af6b076..75d0956d98 100644
--- a/crates/openhuman-rpc/src/server/http/live_voice.rs
+++ b/crates/openhuman-rpc/src/server/http/live_voice.rs
@@ -6,23 +6,35 @@
use std::sync::Arc;
-use axum::extract::{Extension, Query, WebSocketUpgrade};
+use axum::extract::{Extension, WebSocketUpgrade};
+use axum::http::{header, HeaderMap, StatusCode};
use axum::response::{IntoResponse, Response};
+use axum::Json;
use crate::core_host::core::runtime::DispatchCtx;
-use super::dictation::{authorize_dictation_request, DictationQuery};
-
/// WebSocket upgrade handler for live voice sessions.
pub(super) async fn live_voice_ws_handler(
- headers: axum::http::HeaderMap,
+ headers: HeaderMap,
ctx: Option<Extension<DispatchCtx>>,
- Query(query): Query<DictationQuery>,
ws: WebSocketUpgrade,
) -> Response {
log::info!("[ws] live voice WebSocket upgrade requested");
- if let Err(error) = authorize_dictation_request(&headers, &query) {
- return error.into_response();
+ let origin = headers
+ .get(header::ORIGIN)
+ .and_then(|value| value.to_str().ok())
+ .map(str::trim);
+ if !crate::server::socketio::origin_is_allowed(origin) {
+ log::warn!("[ws] live voice upgrade rejected: disallowed origin {origin:?}");
+ return (
+ StatusCode::FORBIDDEN,
+ Json(serde_json::json!({
+ "ok": false,
+ "error": "forbidden",
+ "message": "Origin not allowed for the live voice WebSocket.",
+ })),
+ )
+ .into_response();
}
// The context the serving middleware attached: the upgraded socket runs on
// its own task, so it cannot be read back from the request task. A request