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(mcp): scrub short query credentials inside other text
Steven Enamakel197366606963
diff --git a/crates/openhuman-core/src/tools/impl/network/mcp.rs b/crates/openhuman-core/src/tools/impl/network/mcp.rsindex ddf8dacbd7..b648b5d514 100644--- a/crates/openhuman-core/src/tools/impl/network/mcp.rs+++ b/crates/openhuman-core/src/tools/impl/network/mcp.rs@@ -300,6 +300,7 @@ const CREDENTIAL_QUERY_PARAM_NEEDLES: [&str; 7] = [struct SecretScrubber {secrets: Vec<String>,+ strict: Vec<String>,}impl SecretScrubber {@@ -307,6 +308,7 @@ impl SecretScrubber {let Some(definition) = registry.get(server) else {return Self {secrets: Vec::new(),+ strict: Vec::new(),};};Self::new(&definition.auth, &definition.endpoint)@@ -314,6 +316,7 @@ impl SecretScrubber {fn new(auth: &McpDefinitionAuth, endpoint: &str) -> Self {let mut raw: Vec<String> = Vec::new();+ let mut strict: Vec<String> = Vec::new();match auth {McpDefinitionAuth::BearerToken { token } => raw.push(token.clone()),McpDefinitionAuth::Basic { username, password } => {@@ -333,7 +336,7 @@ impl SecretScrubber {}if endpoint_query(endpoint).is_some() {if let Ok(url) = url::Url::parse(endpoint) {- raw.extend(url.query_pairs().filter_map(|(name, value)| {+ strict.extend(url.query_pairs().filter_map(|(name, value)| {let name = name.to_ascii_lowercase();let credential_like = CREDENTIAL_QUERY_PARAM_NEEDLES.iter()@@ -354,7 +357,7 @@ impl SecretScrubber {.iter().any(|needle| decoded_name.contains(needle)){- raw.push(value.to_string());+ strict.push(value.to_string());}}}@@ -362,6 +365,14 @@ impl SecretScrubber {}}+ strict.retain(|value| !value.trim().is_empty());+ let encoded_strict = strict+ .iter()+ .map(|value| urlencoding::encode(value).into_owned())+ .collect::<Vec<_>>();+ strict.extend(encoded_strict);+ raw.extend(strict.iter().cloned());+let mut secrets: Vec<String> = Vec::new();for value in raw {let value = value.trim();@@ -376,13 +387,13 @@ impl SecretScrubber {}secrets.sort_by(|a, b| b.len().cmp(&a.len()).then_with(|| a.cmp(b)));secrets.dedup();- Self { secrets }+ Self { secrets, strict }}fn scrub(&self, text: &str) -> String {let mut out = text.to_string();for secret in &self.secrets {- if secret.len() < MIN_QUERY_SECRET_LEN {+ if secret.len() < MIN_QUERY_SECRET_LEN && !self.strict.contains(secret) {// Short credentials are common words or field-name fragments;// only replace a complete token so unrelated text stays usable.let mut next = String::with_capacity(out.len());diff --git a/crates/openhuman-core/src/tools/impl/network/mcp_tests.rs b/crates/openhuman-core/src/tools/impl/network/mcp_tests.rsindex 949dda1dec..b3161737dd 100644--- a/crates/openhuman-core/src/tools/impl/network/mcp_tests.rs+++ b/crates/openhuman-core/src/tools/impl/network/mcp_tests.rs@@ -453,18 +453,33 @@ fn scrubber_redacts_credential_query_value() {}#[test]-fn scrubber_redacts_short_query_credentials_without_rewriting_words() {+fn scrubber_redacts_short_query_credentials_even_inside_other_text() {let scrubber = SecretScrubber::new(&McpDefinitionAuth::None,"https://example.com/mcp?api_key=abc&v=2",);assert_eq!(- scrubber.scrub("abc is a credential; alphabet and abc_def are not"),- "[redacted] is a credential; alphabet and abc_def are not"+ scrubber.scrub("abc is a credential; prefixabc also contains it"),+ "[redacted] is a credential; prefix[redacted] also contains it");assert_eq!(scrubber.scrub("v=2"), "v=2");}+#[test]+fn short_auth_values_do_not_rewrite_unrelated_words() {+ let scrubber = SecretScrubber::new(+ &McpDefinitionAuth::Basic {+ username: "abc".into(),+ password: "private12345".into(),+ },+ "https://example.com/mcp",+ );+ assert_eq!(+ scrubber.scrub("abc identifies the user; alphabet is unrelated"),+ "[redacted] identifies the user; alphabet is unrelated"+ );+}+#[test]fn scrub_value_keeps_both_entries_when_keys_collide_after_redaction() {let scrubber = SecretScrubber::new(