diff --git a/backend/src/main.rs b/backend/src/main.rs index aa3eee4a18..f92ba6602e 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -58,7 +58,7 @@ use windmill_common::{ Mode, GIT_VERSION, HOSTNAME, MODE_AND_ADDONS, }, worker::{ - reload_custom_tags_setting, Connection, HUB_CACHE_DIR, TMP_DIR, TMP_LOGS_DIR, WORKER_GROUP, + reload_custom_tags_setting, Connection, CLOUD_HOSTED, HUB_CACHE_DIR, TMP_DIR, TMP_LOGS_DIR, WORKER_GROUP }, KillpillSender, METRICS_ENABLED, }; @@ -268,6 +268,21 @@ async fn windmill_main() -> anyhow::Result<()> { tracing::error!("Failed to install rustls crypto provider"); } + #[cfg(feature = "enterprise")] + if *CLOUD_HOSTED { + // Block access to AWS/GCP metadata endpoints for security in cloud-hosted mode. + // This is a best-effort attempt; if it fails, just warn and continue. + if let Err(e) = std::process::Command::new("sh") + .arg("-c") + .arg("iptables -A OUTPUT -d 169.254.169.254 -j DROP && iptables -A FORWARD -d 169.254.169.254 -j DROP") + .status() + { + tracing::warn!("Failed to run iptables to block metadata endpoint: {e}"); + } else { + tracing::info!("Successfully blocked metadata endpoint using iptables"); + } + } + let hostname = HOSTNAME.to_owned(); let mode_and_addons = MODE_AND_ADDONS.clone(); diff --git a/docker/DockerfileNsjail b/docker/DockerfileNsjail index 4a1e04b8d1..2e9b0b0580 100644 --- a/docker/DockerfileNsjail +++ b/docker/DockerfileNsjail @@ -72,7 +72,6 @@ RUN /usr/bin/java -jar /usr/bin/coursier about # iptables RUN apt-get install -y iptables -RUN iptables -A OUTPUT -d 169.254.169.254 -j DROP && iptables -A FORWARD -d 169.254.169.254 -j DROP COPY --from=nsjail /nsjail/nsjail /bin/nsjail