diff --git a/substrate/utils/wasm-builder/src/prerequisites.rs b/substrate/utils/wasm-builder/src/prerequisites.rs
index 7236b8169bcb54f20a5136494fcb8ee56e5f106b..88b1073a2951f4e404eece8612d829acfbef815d 100644
--- a/substrate/utils/wasm-builder/src/prerequisites.rs
+++ b/substrate/utils/wasm-builder/src/prerequisites.rs
@@ -120,6 +120,9 @@ fn check_wasm_toolchain_installed(
 	let manifest_path = temp.path().join("Cargo.toml").display().to_string();
 
 	let mut build_cmd = cargo_command.command();
+	// Chdir to temp to avoid including project's .cargo/config.toml
+	// by accident - it can happen in some CI environments.
+	build_cmd.current_dir(&temp);
 	build_cmd.args(&[
 		"build",
 		"--target=wasm32-unknown-unknown",
@@ -132,6 +135,9 @@ fn check_wasm_toolchain_installed(
 	}
 
 	let mut run_cmd = cargo_command.command();
+	// Chdir to temp to avoid including project's .cargo/config.toml
+	// by accident - it can happen in some CI environments.
+	run_cmd.current_dir(&temp);
 	run_cmd.args(&["run", "--manifest-path", &manifest_path]);
 
 	// Unset the `CARGO_TARGET_DIR` to prevent a cargo deadlock