Skip to content

Commit 7dda580

Browse files
committed
chore(security): harden ML API URL handling to mitigate SSRF
1 parent d2f8ed3 commit 7dda580

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/rust/server.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,22 @@ struct ProofSession {
4747
history: Vec<String>,
4848
}
4949

50+
const DEFAULT_ML_API_URL: &str = "http://127.0.0.1:8090";
51+
5052
/// Start the HTTP server
5153
pub async fn start_server(port: u16, host: String, enable_cors: bool) -> Result<()> {
5254
// Create HTTP client for Julia ML API
5355
let ml_client = Client::builder()
5456
.timeout(Duration::from_secs(10))
5557
.build()?;
5658

57-
let ml_api_url = "http://127.0.0.1:8090".to_string();
59+
let ml_api_url = std::env::var("ECHIDNA_ML_API_URL")
60+
.unwrap_or_else(|_| DEFAULT_ML_API_URL.to_string());
61+
62+
// Security: Validate that the ML API URL is either local or explicitly allowed
63+
if !ml_api_url.starts_with("http://127.0.0.1") && !ml_api_url.starts_with("http://localhost") {
64+
info!("⚠ Untrusted ML API URL detected: {}. Baseline security policy requires local or trusted endpoint.", ml_api_url);
65+
}
5866

5967
// Test Julia ML connection
6068
match ml_client.get(format!("{}/health", ml_api_url)).send().await {

0 commit comments

Comments
 (0)