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(http-host): constant-time Basic auth compare; pin the symlink escape
M3gA-Mindc0b892d2643b
diff --git a/crates/openhuman-rpc/src/http_host/auth.rs b/crates/openhuman-rpc/src/http_host/auth.rsindex 47a39e6a33..51bff0c74f 100644--- a/crates/openhuman-rpc/src/http_host/auth.rs+++ b/crates/openhuman-rpc/src/http_host/auth.rs@@ -40,7 +40,11 @@ pub(crate) fn ensure_authorized(headers: &HeaderMap, auth: &HostedDirAuth) -> Relet Some((username, password)) = rendered.split_once(':') else {return Err(unauthorized_response());};- if username == expected_user && password == expected_pass {+ // Constant-time, and both halves always compared, so the response time+ // reveals neither how much of a credential matched nor which half failed.+ let user_ok = crate::core_host::core::auth::bearer_matches(username, expected_user);+ let pass_ok = crate::core_host::core::auth::bearer_matches(password, expected_pass);+ if user_ok & pass_ok {Ok(())} else {Err(unauthorized_response())diff --git a/crates/openhuman-rpc/src/http_host/http_host_tests.rs b/crates/openhuman-rpc/src/http_host/http_host_tests.rsindex ebc3fcefe4..07deedc83e 100644--- a/crates/openhuman-rpc/src/http_host/http_host_tests.rs+++ b/crates/openhuman-rpc/src/http_host/http_host_tests.rs@@ -46,6 +46,54 @@ fn resolve_request_path_rejects_traversal() {assert!(err.contains("path traversal"));}+#[cfg(unix)]+#[test]+fn resolve_request_path_rejects_a_symlink_out_of_the_hosted_directory() {+ let tmp = tempfile::tempdir().unwrap();+ let root = std::fs::canonicalize(tmp.path()).unwrap().join("shared");+ let outside = std::fs::canonicalize(tmp.path()).unwrap().join("outside");+ std::fs::create_dir_all(&root).unwrap();+ std::fs::create_dir_all(&outside).unwrap();+ std::fs::write(outside.join("secret.txt"), "not shared").unwrap();+ std::os::unix::fs::symlink(&outside, root.join("link")).unwrap();++ let err = resolve_request_path(&root, "link/secret.txt").unwrap_err();+ assert!(err.contains("escapes"), "{err}");+}++#[test]+fn basic_auth_accepts_only_the_exact_credentials() {+ use axum::http::{header, HeaderMap, HeaderValue};+ use base64::Engine as _;++ let auth = crate::http_host::types::HostedDirAuth {+ enabled: true,+ username: Some("ada".into()),+ password: Some("s3cret".into()),+ };+ let headers_for = |user: &str, pass: &str| {+ let token = base64::engine::general_purpose::STANDARD.encode(format!("{user}:{pass}"));+ let mut headers = HeaderMap::new();+ headers.insert(+ header::AUTHORIZATION,+ HeaderValue::from_str(&format!("Basic {token}")).unwrap(),+ );+ headers+ };+ let check = |user: &str, pass: &str| {+ crate::http_host::auth::ensure_authorized(&headers_for(user, pass), &auth).is_ok()+ };+ assert!(check("ada", "s3cret"));+ for (user, pass) in [+ ("ada", "s3cre"),+ ("ada", "s3cretX"),+ ("adb", "s3cret"),+ ("", ""),+ ] {+ assert!(!check(user, pass), "{user}:{pass} must be refused");+ }+}+#[tokio::test]async fn start_serves_files_with_basic_auth() {let _guard = TEST_MUTEX.lock().unwrap();