fix(gcp-metadata): ignore 42:01 MAC addresses on macOS - #9384
Open
Shubham-Padkonde wants to merge 1 commit into
Open
Shubham-Padkonde wants to merge 1 commit into
Shubham-Padkonde wants to merge 1 commit into
Conversation
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
Contributor
There was a problem hiding this comment.
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.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 with42:01. When that happens:detectGCPResidency()returnstrue;requestTimeout()returns0, so metadata requests to169.254.169.254never time out;google-auth-library's_checkIsGCE()short-circuits beforeMETADATA_SERVER_DETECTION=noneis read.The issue shows the result:
firebase emulators:starthangs indefinitely.Compute Engine doesn't offer macOS instances, so
isGoogleComputeEngineMACAddress()now returnsfalseondarwin:This PR only covers the misdetection. Whether
METADATA_SERVER_DETECTION=noneshould override residency detection ingoogle-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-metadatawith Node 26:darwin, an interface with a42:01MAC makes neitherisGoogleComputeEngineMACAddress()norisGoogleComputeEngine()returntrue. It fails without the change and passes with it.setGCPResidencytest ("should match gcp residency results by default") stubbed a42:01interface but used the real platform, so it would now fail on a macOS dev machine. It now pins the platform tolinux, like the other residency tests do.tsc+mocha build/test: 72 passing (71 passing and 1 failing without the source change).gts checkis 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