From 1a1a8e7cef4fdb1fd49fa2ac2566ee2d10b6dd58 Mon Sep 17 00:00:00 2001 From: Shubham Padkonde Date: Sat, 19 Sep 2026 16:34:52 +0530 Subject: [PATCH] fix(gcp-metadata): ignore 42:01 MAC addresses on macOS isGoogleComputeEngineMACAddress() matched any interface whose MAC starts with 42:01. macOS assigns random, locally administered MACs to its AWDL and low-latency WLAN interfaces (awdl0, llw0), which can start with 42:01, so a Mac was detected as GCE. Detection then short-circuits METADATA_SERVER_DETECTION and requestTimeout() returns 0, so metadata requests hang. Compute Engine does not run macOS, so skip the MAC check there. Fixes #9338 --- core/packages/gcp-metadata/src/gcp-residency.ts | 6 ++++++ core/packages/gcp-metadata/test/gcp-residency.test.ts | 9 +++++++++ core/packages/gcp-metadata/test/index.test.ts | 1 + 3 files changed, 16 insertions(+) diff --git a/core/packages/gcp-metadata/src/gcp-residency.ts b/core/packages/gcp-metadata/src/gcp-residency.ts index b64425f4915..dcbdf48a7ff 100644 --- a/core/packages/gcp-metadata/src/gcp-residency.ts +++ b/core/packages/gcp-metadata/src/gcp-residency.ts @@ -85,9 +85,15 @@ export function isGoogleComputeEngineLinux(): boolean { * Determines if the process is running on a Google Compute Engine instance with a known * MAC address. * + * Always `false` on macOS: Compute Engine does not run macOS, and macOS assigns + * random, locally administered MAC addresses (which can begin with `42:01`) to + * interfaces such as `awdl0` and `llw0`. + * * @returns {boolean} `true` if the process is running on GCE (as determined by MAC address), `false` otherwise. */ export function isGoogleComputeEngineMACAddress(): boolean { + if (platform() === 'darwin') return false; + const interfaces = networkInterfaces(); for (const item of Object.values(interfaces)) { diff --git a/core/packages/gcp-metadata/test/gcp-residency.test.ts b/core/packages/gcp-metadata/test/gcp-residency.test.ts index 5255374b459..1e18e2194b7 100644 --- a/core/packages/gcp-metadata/test/gcp-residency.test.ts +++ b/core/packages/gcp-metadata/test/gcp-residency.test.ts @@ -101,6 +101,15 @@ describe('gcp-residency', () => { assert.equal(gcpResidency.isGoogleComputeEngine(), true); }); + it('should return `false` on macOS even if a MAC address begins with `42:01`', () => { + residency.setGCENetworkInterface(true); + residency.setGCEPlatform('darwin'); + residency.setGCELinuxBios(null); + + assert.equal(gcpResidency.isGoogleComputeEngineMACAddress(), false); + assert.equal(gcpResidency.isGoogleComputeEngine(), false); + }); + it('should return `false` if the host MAC address does not begin with `42:01` & is not Linux', () => { residency.setGCENetworkInterface(false); residency.setGCEPlatform('win32'); diff --git a/core/packages/gcp-metadata/test/index.test.ts b/core/packages/gcp-metadata/test/index.test.ts index 4d7eea65c36..cc615fb615f 100644 --- a/core/packages/gcp-metadata/test/index.test.ts +++ b/core/packages/gcp-metadata/test/index.test.ts @@ -785,6 +785,7 @@ describe('unit test', () => { it('should match gcp residency results by default', () => { // Set as GCP residency.setGCENetworkInterface(true); + residency.setGCEPlatform('linux'); gcp.setGCPResidency(); assert.equal(gcp.gcpResidencyCache, true);