Skip to content

fix(gcp-metadata): ignore 42:01 MAC addresses on macOS - #9384

Open
Shubham-Padkonde wants to merge 1 commit into
googleapis:mainfrom
Shubham-Padkonde:fix-gcp-metadata-macos-mac
Open

Shubham-Padkonde wants to merge 1 commit into
googleapis:mainfrom
Shubham-Padkonde:fix-gcp-metadata-macos-mac

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown

Fixes #9338 🦕

On macOS, isGoogleComputeEngineMACAddress() could report a laptop as a GCE instance.

macOS gives the AWDL and low-latency WLAN interfaces (awdl0, llw0, used by AirDrop and Continuity) random, locally administered MAC addresses, and these can start with 42:01. When that happens:

  • detectGCPResidency() returns true;
  • requestTimeout() returns 0, so metadata requests to 169.254.169.254 never time out;
  • google-auth-library's _checkIsGCE() short-circuits before METADATA_SERVER_DETECTION=none is read.

The issue shows the result: firebase emulators:start hangs indefinitely.

Compute Engine doesn't offer macOS instances, so isGoogleComputeEngineMACAddress() now returns false on darwin:

  • On Linux, detection is unchanged: the BIOS check runs first, and the MAC check is still used as a fallback.
  • On Windows, detection is unchanged.

This PR only covers the misdetection. Whether METADATA_SERVER_DETECTION=none should override residency detection in google-auth-library (option 1 in the issue) is a separate behaviour change, and I left it out of this PR.

Testing

I ran these locally in core/packages/gcp-metadata with Node 26:

  • New test: on darwin, an interface with a 42:01 MAC makes neither isGoogleComputeEngineMACAddress() nor isGoogleComputeEngine() return true. It fails without the change and passes with it.
  • The existing setGCPResidency test ("should match gcp residency results by default") stubbed a 42:01 interface but used the real platform, so it would now fail on a macOS dev machine. It now pins the platform to linux, like the other residency tests do.
  • tsc + mocha build/test: 72 passing (71 passing and 1 failing without the source change).
  • gts check is clean on the changed files.

This change was written with help from an AI coding assistant (Claude Code). I reviewed and tested it as described above.

🤖 Generated with Claude Code

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 googleapis#9338
@Shubham-Padkonde
Shubham-Padkonde requested a review from a team as a code owner September 19, 2026 11:05

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the GCP residency check to always return false on macOS (darwin) within isGoogleComputeEngineMACAddress(), preventing false positives caused by macOS assigning random MAC addresses that might start with 42:01. It also adds corresponding unit tests to verify this behavior and updates an existing test to explicitly set the platform to 'linux'. There are no review comments, and I have no additional feedback to provide.

@github-actions
github-actions Bot requested a review from feywind September 19, 2026 11:06

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gcp-metadata: macOS AWDL interface with a 42:01 MAC is detected as GCE; METADATA_SERVER_DETECTION=none is then ignored and metadata requests hang

1 participant