fix(mcp): rmcp 3.9, with the Host check of the Streamable HTTP server
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 4m32s
CI / Check (pull_request) Successful in 17m1s
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 4m32s
CI / Check (pull_request) Successful in 17m1s
rmcp 0.16.0 has three advisories in the Streamable HTTP server transport the MCP server uses: DNS rebinding (CVE-2026-42559, no Host validation), an unauthenticated session-table leak (CVE-2026-63128, remote DoS) and missing resource validation in OAuth metadata discovery (CVE-2026-63127). - rmcp and rmcp-macros 0.16.0 -> 3.9.0. The tool macros are unchanged; Content is now ContentBlock, and get_info returns a ServerConfig built with its builder (same protocol version, server info and instructions). - rmcp 3 accepts only loopback Host headers by default. MCP_ALLOWED_HOSTS names the hosts the server answers to, comma-separated (the public hostname and the in-network name). Unset, the Host header is not checked and a warning says so, so a deployment keeps working until it is set. - The rmcp ignore in .cargo/audit.toml (RUSTSEC-2026-0189) is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4480e8b509
commit
4fd5639464
12 files changed
+129
-51
No files matched your search
@@ -6,17 +6,4 @@ ignore = [
|
||||
# MITM/controlled DNS server against MongoDB's hostname resolution — not a
|
||||
# realistic attack surface here. Revisit when hickory ships a fix.
|
||||
"RUSTSEC-2026-0118", # NSEC3 loop, no fix available upstream
|
||||
|
||||
# rmcp 0.16.0 — DNS rebinding in Streamable HTTP server transport (missing
|
||||
# Host header validation). Patched in rmcp >= 1.4.0, which is a major API
|
||||
# version jump from our pin; rmcp shipped 0.x → 1.x → 2.x in three months
|
||||
# and the migration touches every tool handler + the auth middleware we
|
||||
# just landed in #92. Threat model in our deployment: the MCP server is
|
||||
# exposed at a public hostname (comp-mcp-dev.breakpilot.com) behind orca's
|
||||
# TLS-terminating ingress with per-tenant bearer auth — the attack model
|
||||
# (browser DNS-rebinding into localhost MCP server) doesn't directly apply.
|
||||
# Defense-in-depth Host-header check is still a worthwhile follow-up.
|
||||
# FOLLOW-UP: bump rmcp to 2.x in a dedicated PR (M7.3 follow-up, sized
|
||||
# multi-hour due to API surface change).
|
||||
"RUSTSEC-2026-0189",
|
||||
]
|
||||
@@ -146,6 +146,11 @@ DASHBOARD_SESSION_KEY=
|
||||
|
||||
# MCP Server
|
||||
MCP_ENDPOINT_URL=http://localhost:8090
|
||||
# The hostnames (or host:port) clients reach the MCP server at, comma-separated:
|
||||
# the public hostname behind the ingress and the in-network name the dashboard
|
||||
# uses. Requests with another Host header are refused (DNS rebinding
|
||||
# protection). Unset, the Host header is not checked and a warning is logged.
|
||||
# MCP_ALLOWED_HOSTS=pruefwerk-stage.breakpilot.com,compliance-mcp:8090
|
||||
# Absolute health URL for the default MCP server card. Set it where an ingress
|
||||
# routes /mcp/* to a server that serves /health at its own root (staging:
|
||||
# https://pruefwerk-stage.breakpilot.com/mcp/health). Derived from
|
||||
|
||||
Generated
+46
-9
@@ -1166,6 +1166,16 @@ dependencies = [
|
||||
"darling_macro 0.23.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec"
|
||||
dependencies = [
|
||||
"darling_core 0.24.1",
|
||||
"darling_macro 0.24.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_core"
|
||||
version = "0.21.3"
|
||||
@@ -1193,6 +1203,19 @@ dependencies = [
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_core"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff"
|
||||
dependencies = [
|
||||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_macro"
|
||||
version = "0.21.3"
|
||||
@@ -1215,6 +1238,17 @@ dependencies = [
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_macro"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785"
|
||||
dependencies = [
|
||||
"darling_core 0.24.1",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dashmap"
|
||||
version = "6.1.0"
|
||||
@@ -4831,18 +4865,20 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rmcp"
|
||||
version = "0.16.0"
|
||||
version = "3.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc4c9c94680f75470ee8083a0667988b5d7b5beb70b9f998a8e51de7c682ce60"
|
||||
checksum = "d24a7e92f4bcaa36b97fa93c4fa7ca8f3e669eced949345b3462dba333c7f909"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.22.1",
|
||||
"base64 0.23.1",
|
||||
"bytes",
|
||||
"chrono",
|
||||
"futures",
|
||||
"http",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"indexmap",
|
||||
"libc",
|
||||
"pastey",
|
||||
"pin-project-lite",
|
||||
"rand 0.10.3",
|
||||
@@ -4850,6 +4886,7 @@ dependencies = [
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2 0.11.1",
|
||||
"sse-stream",
|
||||
"thiserror 2.0.18",
|
||||
"tokio",
|
||||
@@ -4862,15 +4899,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rmcp-macros"
|
||||
version = "0.16.0"
|
||||
version = "3.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90c23c8f26cae4da838fbc3eadfaecf2d549d97c04b558e7bd90526a9c28b42a"
|
||||
checksum = "b3140f24a766f80f9ec1607bde85680959a69b83d46fa9ce87dadab7e67ab029"
|
||||
dependencies = [
|
||||
"darling 0.23.0",
|
||||
"darling 0.24.1",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde_json",
|
||||
"syn 2.0.117",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5509,9 +5546,9 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||
|
||||
[[package]]
|
||||
name = "sse-stream"
|
||||
version = "0.2.1"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb4dc4d33c68ec1f27d386b5610a351922656e1fdf5c05bbaad930cd1519479a"
|
||||
checksum = "c25ac7aff0abd1dbc474536e40416e1102c7dd9bfba0b9861c6d357f835dcfb4"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-util",
|
||||
|
||||
@@ -5,7 +5,7 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
compliance-core = { workspace = true, features = ["mongodb", "axum"] }
|
||||
rmcp = { version = "0.16", features = ["server", "macros", "transport-io", "transport-streamable-http-server"] }
|
||||
rmcp = { version = "3.9", features = ["server", "macros", "transport-io", "transport-streamable-http-server"] }
|
||||
tokio = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
@@ -60,7 +60,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
))
|
||||
},
|
||||
Arc::new(LocalSessionManager::default()),
|
||||
StreamableHttpServerConfig::default(),
|
||||
http_config(std::env::var("MCP_ALLOWED_HOSTS").ok().as_deref()),
|
||||
);
|
||||
|
||||
let router = axum::Router::new()
|
||||
@@ -112,3 +112,57 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The Streamable HTTP configuration, with the `Host` values the server
|
||||
/// answers to (DNS rebinding protection).
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `allowed_hosts` - `MCP_ALLOWED_HOSTS`: the hostnames or `host:port`
|
||||
/// authorities clients reach the server at, comma-separated (the public
|
||||
/// hostname behind the ingress, and the in-network name the dashboard
|
||||
/// uses). Unset or empty, `Host` is not checked: the server sits behind the
|
||||
/// ingress and per-tenant bearer tokens, as before rmcp checked it, and a
|
||||
/// warning says so.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// rmcp's defaults with the host check set from `allowed_hosts`.
|
||||
fn http_config(allowed_hosts: Option<&str>) -> StreamableHttpServerConfig {
|
||||
let hosts: Vec<&str> = allowed_hosts
|
||||
.unwrap_or_default()
|
||||
.split(',')
|
||||
.map(str::trim)
|
||||
.filter(|h| !h.is_empty())
|
||||
.collect();
|
||||
let config = StreamableHttpServerConfig::default();
|
||||
if hosts.is_empty() {
|
||||
tracing::warn!("MCP_ALLOWED_HOSTS is not set; the Host header is not checked");
|
||||
config.disable_allowed_hosts()
|
||||
} else {
|
||||
tracing::info!(?hosts, "MCP server answers to these hosts");
|
||||
config.with_allowed_hosts(hosts)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn allowed_hosts_are_read_from_a_comma_separated_list() {
|
||||
let config = http_config(Some(
|
||||
" pruefwerk-stage.breakpilot.com, compliance-mcp:8090 ,",
|
||||
));
|
||||
assert_eq!(
|
||||
config.allowed_hosts,
|
||||
["pruefwerk-stage.breakpilot.com", "compliance-mcp:8090"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn without_allowed_hosts_the_host_is_not_checked() {
|
||||
assert!(http_config(None).allowed_hosts.is_empty());
|
||||
assert!(http_config(Some(" , ")).allowed_hosts.is_empty());
|
||||
}
|
||||
}
|
||||
@@ -256,17 +256,12 @@ impl ComplianceMcpServer {
|
||||
|
||||
#[tool_handler]
|
||||
impl ServerHandler for ComplianceMcpServer {
|
||||
fn get_info(&self) -> ServerInfo {
|
||||
ServerInfo {
|
||||
protocol_version: ProtocolVersion::V_2024_11_05,
|
||||
capabilities: ServerCapabilities::builder()
|
||||
.enable_tools()
|
||||
.build(),
|
||||
server_info: Implementation::from_build_env(),
|
||||
instructions: Some(
|
||||
"Prüfwerk MCP server. Start with list_targets; each target's id is the repo_id/target_id the other tools take. Query findings, the CRA control mapping (OSCAL), SBOMs (CycloneDX, SPDX), CVE alerts, scan runs, DAST results and pentest sessions of your tenant."
|
||||
.to_string(),
|
||||
),
|
||||
}
|
||||
fn get_info(&self) -> ServerConfig {
|
||||
ServerConfig::new(ServerCapabilities::builder().enable_tools().build())
|
||||
.with_protocol_version(ProtocolVersion::V_2024_11_05)
|
||||
.with_server_info(Implementation::from_build_env())
|
||||
.with_instructions(
|
||||
"Prüfwerk MCP server. Start with list_targets; each target's id is the repo_id/target_id the other tools take. Query findings, the CRA control mapping (OSCAL), SBOMs (CycloneDX, SPDX), CVE alerts, scan runs, DAST results and pentest sessions of your tenant.",
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ pub async fn list_dast_findings(
|
||||
let json = serde_json::to_string_pretty(&results)
|
||||
.map_err(|e| McpError::internal_error(format!("json error: {e}"), None))?;
|
||||
|
||||
Ok(CallToolResult::success(vec![Content::text(json)]))
|
||||
Ok(CallToolResult::success(vec![ContentBlock::text(json)]))
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, JsonSchema)]
|
||||
@@ -210,5 +210,5 @@ pub async fn dast_scan_summary(
|
||||
let json = serde_json::to_string_pretty(&summary)
|
||||
.map_err(|e| McpError::internal_error(format!("json error: {e}"), None))?;
|
||||
|
||||
Ok(CallToolResult::success(vec![Content::text(json)]))
|
||||
Ok(CallToolResult::success(vec![ContentBlock::text(json)]))
|
||||
}
|
||||
@@ -153,7 +153,7 @@ pub async fn list_findings(
|
||||
let json = serde_json::to_string_pretty(&results)
|
||||
.map_err(|e| McpError::internal_error(format!("json error: {e}"), None))?;
|
||||
|
||||
Ok(CallToolResult::success(vec![Content::text(json)]))
|
||||
Ok(CallToolResult::success(vec![ContentBlock::text(json)]))
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, JsonSchema)]
|
||||
@@ -179,7 +179,7 @@ pub async fn get_finding(
|
||||
let json = serde_json::to_string_pretty(&finding)
|
||||
.map_err(|e| McpError::internal_error(format!("json error: {e}"), None))?;
|
||||
|
||||
Ok(CallToolResult::success(vec![Content::text(json)]))
|
||||
Ok(CallToolResult::success(vec![ContentBlock::text(json)]))
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, JsonSchema)]
|
||||
@@ -252,5 +252,5 @@ pub async fn findings_summary(
|
||||
let json = serde_json::to_string_pretty(&summary)
|
||||
.map_err(|e| McpError::internal_error(format!("json error: {e}"), None))?;
|
||||
|
||||
Ok(CallToolResult::success(vec![Content::text(json)]))
|
||||
Ok(CallToolResult::success(vec![ContentBlock::text(json)]))
|
||||
}
|
||||
@@ -39,7 +39,7 @@ where
|
||||
pub fn json_result<T: serde::Serialize>(value: &T) -> Result<CallToolResult, McpError> {
|
||||
let json = serde_json::to_string_pretty(value)
|
||||
.map_err(|e| McpError::internal_error(format!("json error: {e}"), None))?;
|
||||
Ok(CallToolResult::success(vec![Content::text(json)]))
|
||||
Ok(CallToolResult::success(vec![ContentBlock::text(json)]))
|
||||
}
|
||||
|
||||
/// A database error as an internal MCP error.
|
||||
|
||||
@@ -47,5 +47,5 @@ pub async fn oscal_assessment(
|
||||
let document = assess(&findings, chrono::Utc::now());
|
||||
let json = serde_json::to_string_pretty(&document)
|
||||
.map_err(|e| McpError::internal_error(format!("json error: {e}"), None))?;
|
||||
Ok(CallToolResult::success(vec![Content::text(json)]))
|
||||
Ok(CallToolResult::success(vec![ContentBlock::text(json)]))
|
||||
}
|
||||
@@ -152,7 +152,7 @@ pub async fn list_pentest_sessions(
|
||||
let json = serde_json::to_string_pretty(&results)
|
||||
.map_err(|e| McpError::internal_error(format!("json error: {e}"), None))?;
|
||||
|
||||
Ok(CallToolResult::success(vec![Content::text(json)]))
|
||||
Ok(CallToolResult::success(vec![ContentBlock::text(json)]))
|
||||
}
|
||||
|
||||
// ── Get Pentest Session ────────────────────────────────────────
|
||||
@@ -181,7 +181,7 @@ pub async fn get_pentest_session(
|
||||
let json = serde_json::to_string_pretty(&session)
|
||||
.map_err(|e| McpError::internal_error(format!("json error: {e}"), None))?;
|
||||
|
||||
Ok(CallToolResult::success(vec![Content::text(json)]))
|
||||
Ok(CallToolResult::success(vec![ContentBlock::text(json)]))
|
||||
}
|
||||
|
||||
// ── Get Attack Chain ───────────────────────────────────────────
|
||||
@@ -223,7 +223,7 @@ pub async fn get_attack_chain(
|
||||
let json = serde_json::to_string_pretty(&results)
|
||||
.map_err(|e| McpError::internal_error(format!("json error: {e}"), None))?;
|
||||
|
||||
Ok(CallToolResult::success(vec![Content::text(json)]))
|
||||
Ok(CallToolResult::success(vec![ContentBlock::text(json)]))
|
||||
}
|
||||
|
||||
// ── Get Pentest Messages ───────────────────────────────────────
|
||||
@@ -265,7 +265,7 @@ pub async fn get_pentest_messages(
|
||||
let json = serde_json::to_string_pretty(&results)
|
||||
.map_err(|e| McpError::internal_error(format!("json error: {e}"), None))?;
|
||||
|
||||
Ok(CallToolResult::success(vec![Content::text(json)]))
|
||||
Ok(CallToolResult::success(vec![ContentBlock::text(json)]))
|
||||
}
|
||||
|
||||
// ── Pentest Stats ──────────────────────────────────────────────
|
||||
@@ -344,5 +344,5 @@ pub async fn pentest_stats(
|
||||
let json = serde_json::to_string_pretty(&summary)
|
||||
.map_err(|e| McpError::internal_error(format!("json error: {e}"), None))?;
|
||||
|
||||
Ok(CallToolResult::success(vec![Content::text(json)]))
|
||||
Ok(CallToolResult::success(vec![ContentBlock::text(json)]))
|
||||
}
|
||||
@@ -134,7 +134,7 @@ pub async fn list_sbom_packages(
|
||||
let json = serde_json::to_string_pretty(&results)
|
||||
.map_err(|e| McpError::internal_error(format!("json error: {e}"), None))?;
|
||||
|
||||
Ok(CallToolResult::success(vec![Content::text(json)]))
|
||||
Ok(CallToolResult::success(vec![ContentBlock::text(json)]))
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, JsonSchema)]
|
||||
@@ -190,7 +190,7 @@ pub async fn sbom_vuln_report(
|
||||
let json = serde_json::to_string_pretty(&report)
|
||||
.map_err(|e| McpError::internal_error(format!("json error: {e}"), None))?;
|
||||
|
||||
Ok(CallToolResult::success(vec![Content::text(json)]))
|
||||
Ok(CallToolResult::success(vec![ContentBlock::text(json)]))
|
||||
}
|
||||
|
||||
/// The SBOM exchange formats `get_sbom` writes.
|
||||
@@ -405,5 +405,5 @@ pub async fn third_party_notices(
|
||||
include_build_only: params.include_build_only,
|
||||
},
|
||||
);
|
||||
Ok(CallToolResult::success(vec![Content::text(text)]))
|
||||
Ok(CallToolResult::success(vec![ContentBlock::text(text)]))
|
||||
}
|
||||
Reference in new issue
Block a user