Skip to content

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

fix(search): enforce profile capability boundary on search tools

Steven Enamakelc113213c74db
diff --git a/crates/openhuman-core/src/core/runtime/saas.rs b/crates/openhuman-core/src/core/runtime/saas.rs
index 8fab322c5e..f1cd882415 100644
--- a/crates/openhuman-core/src/core/runtime/saas.rs
+++ b/crates/openhuman-core/src/core/runtime/saas.rs
@@ -204,7 +204,7 @@ impl SaasConfig {
let raw = std::fs::read_to_string(path)
.map_err(|e| anyhow::anyhow!("reading SaaS config {}: {e}", path.display()))?;
let config: Self = toml::from_str(&raw)
- .map_err(|e| anyhow::anyhow!("parsing SaaS config {}: {e}", path.display()))?;
+ .map_err(|_| anyhow::anyhow!("parsing SaaS config {}: invalid operator settings", path.display()))?;
log::debug!(
"[saas] loaded operator config from {} (root={})",
path.display(),
@@ -330,6 +330,7 @@ pub async fn build_with_profile_capabilities(
port: Option<u16>,
capabilities: Option<Arc<crate::profiles::capabilities::ProfileCapabilities>>,
) -> anyhow::Result<CoreRuntime> {
+ crate::profiles::provider_settings::ProfileProviderSettings::from_saas(&config)?;
if CoreContext::current().is_some() {
anyhow::bail!(
"[saas] a core is already running in this process; a SaaS core must be the only one"
diff --git a/crates/openhuman-core/src/modules/search/proxy.rs b/crates/openhuman-core/src/modules/search/proxy.rs
index 7a14852936..04c63599ed 100644
--- a/crates/openhuman-core/src/modules/search/proxy.rs
+++ b/crates/openhuman-core/src/modules/search/proxy.rs
@@ -174,7 +174,11 @@ pub async fn list_tools(config: &Config) -> Result<ListToolsResponse, String> {
let mut listed: ListToolsResponse = proxy(&current).await?
.call(names::methods::LIST_TOOLS, ()).await
.map_err(|error| format!("search ListTools failed: {error}"))?;
- if let Some(binding) = &current.profile_providers { binding.present(&mut listed.tools); }
+ if let Some(binding) = &current.profile_providers {
+ binding.present(&mut listed.tools);
+ let capabilities = crate::profiles::capabilities::ProfileCapabilities::current();
+ listed.tools.retain(|tool| capabilities.as_ref().is_some_and(|capabilities| capabilities.admits(&tool.name)));
+ }
Ok(listed)
}).await
}
@@ -182,6 +186,9 @@ pub async fn list_tools(config: &Config) -> Result<ListToolsResponse, String> {
/// The presentation and route boundary is checked before any module load or call.
fn canonical_request(config: &Config, mut request: ExecuteToolRequest) -> Result<ExecuteToolRequest, String> {
let Some(binding) = &config.profile_providers else { return Ok(request) };
+ if !crate::profiles::capabilities::ProfileCapabilities::current().is_some_and(|capabilities| capabilities.admits(&request.name)) {
+ return Err("search tool is outside the profile capability boundary".into());
+ }
let canonical = binding.canonical_role_name(&request.name)
.ok_or_else(|| "search tool was not advertised by this profile".to_owned())?;
if !super::configured_tool_specs(config).iter().any(|tool| tool.name == request.name) {
diff --git a/crates/openhuman-core/src/search/providers.rs b/crates/openhuman-core/src/search/providers.rs
index 545fbad0ba..3871995085 100644
--- a/crates/openhuman-core/src/search/providers.rs
+++ b/crates/openhuman-core/src/search/providers.rs
@@ -78,11 +78,15 @@ pub fn direct_configured(config: &Config, provider: &str) -> bool {
/// Whether the process holds a credential the managed backend accepts.
pub fn backend_credential_available(config: &Config) -> bool {
+ if config.profile_providers.is_some() { return false; }
crate::security::credentials::session_support::resolve_backend_credential(config).is_ok()
}
/// Resolve every known provider, in catalog order.
pub fn resolve(config: &Config) -> Vec<ResolvedProvider> {
+ if let Some(binding) = &config.profile_providers {
+ return resolve_with(&binding.effective_search(config), false);
+ }
resolve_with(config, backend_credential_available(config))
}