Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(security): validate admission webhook URL scheme at config load
OpenSourceAssistb9d7a53cf5cc
diff --git a/crates/ai-memory-wiki/src/admission.rs b/crates/ai-memory-wiki/src/admission.rsindex 8c7f532d..b6e786d8 100644--- a/crates/ai-memory-wiki/src/admission.rs+++ b/crates/ai-memory-wiki/src/admission.rs@@ -359,6 +359,22 @@ impl AdmissionChain {webhooks.len()))));}++ // Validate each webhook URL scheme before any HTTP client is built.+ // Only http and https are accepted; file://, ftp://, custom schemes,+ // or bare hostnames would otherwise let an attacker that controls the+ // operator config redirect writes to local files or unexpected+ // network targets.+ for hook in &webhooks {+ if !is_supported_webhook_url(&hook.url) {+ return Err(WikiError::Io(std::io::Error::other(format!(+ "admission webhook '{}' has unsupported URL scheme '{}'; \+ only http:// and https:// are allowed",+ hook.name, hook.url,+ ))));+ }+ }+let client = reqwest::Client::builder().build().map_err(|e| {WikiError::Io(std::io::Error::other(format!("admission http client: {e}")))})?;@@ -739,6 +755,22 @@ fn decides(hook: &WebhookConfig) -> bool {hook.blocking && matches!(hook.failure_policy, FailurePolicy::Reject)}+/// Accept only `http://` and `https://` admission webhook URLs.+///+/// Rejects `file://`, `ftp://`, custom schemes, and bare hostnames — any of+/// those would let a misconfigured or attacker-controlled operator config+/// send page payloads to the local filesystem, non-HTTP services, or+/// unresolvable targets. Relative URLs are also refused: every webhook must+/// be an absolute, network-addressable endpoint.+fn is_supported_webhook_url(url: &str) -> bool {+ let trimmed = url.trim();+ if trimmed.is_empty() {+ return false;+ }+ let lower = trimmed.to_ascii_lowercase();+ lower.starts_with("http://") || lower.starts_with("https://")+}+fn webhook_timeout(timeout_ms: u64) -> Duration {Duration::from_millis(timeout_ms.clamp(1, MAX_WEBHOOK_TIMEOUT_MS))}