From 27b2db7d5ee5953cfeaad4d2e9495c3d1cdcf76e Mon Sep 17 00:00:00 2001 From: Blake Date: Wed, 21 Jan 2026 17:24:36 +0800 Subject: [PATCH 1/2] fix: simplify loop detection logic in proof_handler --- node/src/rpc_service/handler/proof_handler.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/node/src/rpc_service/handler/proof_handler.rs b/node/src/rpc_service/handler/proof_handler.rs index f1cda440..e199a3b9 100644 --- a/node/src/rpc_service/handler/proof_handler.rs +++ b/node/src/rpc_service/handler/proof_handler.rs @@ -11,12 +11,7 @@ use std::sync::Arc; /// Checks if the request host matches the configured proof builder host to prevent forwarding loops. fn is_loop_detected(host: &str, request_host: Option<&str>) -> bool { - if let Some(request_host) = request_host { - host == request_host - || host.starts_with(&format!("{}:", request_host.split(':').next().unwrap_or(""))) - } else { - false - } + request_host == Some(host) } /// Handles forwarding to proof builder service or returning mock data. From 4cca7162c2496559baa04930356c5f99b07cce3d Mon Sep 17 00:00:00 2001 From: Blake Date: Wed, 21 Jan 2026 18:42:43 +0800 Subject: [PATCH 2/2] fix: enhance loop detection logic --- node/src/rpc_service/handler/proof_handler.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/node/src/rpc_service/handler/proof_handler.rs b/node/src/rpc_service/handler/proof_handler.rs index e199a3b9..788ec241 100644 --- a/node/src/rpc_service/handler/proof_handler.rs +++ b/node/src/rpc_service/handler/proof_handler.rs @@ -11,7 +11,24 @@ use std::sync::Arc; /// Checks if the request host matches the configured proof builder host to prevent forwarding loops. fn is_loop_detected(host: &str, request_host: Option<&str>) -> bool { - request_host == Some(host) + if let Some(req_host) = request_host { + let mut clean_host = host; + + // Remove scheme if present (e.g. "http://") + if let Some(rest) = clean_host.strip_prefix("http://") { + clean_host = rest; + } else if let Some(rest) = clean_host.strip_prefix("https://") { + clean_host = rest; + } + + // Remove trailing slash + clean_host = clean_host.trim_end_matches('/'); + + // Case-insensitive comparison + clean_host.eq_ignore_ascii_case(req_host) + } else { + false + } } /// Handles forwarding to proof builder service or returning mock data.