Skip to content

fix: hash the machine id from an address unique to the machine - #32

Merged
Jen-Uno merged 2 commits into
mainfrom
dev/jen/machine-id-collisions
Oct 8, 2026
Merged

Jen-Uno merged 2 commits into
mainfrom
dev/jen/machine-id-collisions

Conversation

@Jen-Uno

@Jen-Uno Jen-Uno commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue (If applicable): n/a (issues are disabled on this repository)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Documentation content changes

What is the current behavior?

GetMachineId() hashes the address of the first network interface that is up:

  • On iOS, Android and macOS, that is the loopback adapter, which has no address.
  • On Linux, it is the loopback adapter's 000000000000.
  • On Windows, it is often a VPN or VM adapter whose address is identical on every machine with that product installed.

Every machine in one of those groups therefore reports the same Machine ID. The Machine ID is also the Application Insights user_Id (Telemetry.cs), so user counts and anything keyed on user_Id merge those machines into a single user.

Two details make it worse:

  • The fallback never runs. It tests for null, and an empty PhysicalAddress converts to "", so "" is hashed instead (e3b0c44298fc1c149afbf4c8996fb924, the truncated SHA-256 of an empty string).
  • The id is cached. The result is stored in .machinehash and reused on every start, so fixing the derivation alone would not change any machine that has already run.

What is the new behavior?

Address selection (MachineIdSource.GetUniqueAddress). The first interface that is up is still used, but only if its address identifies one machine. That means it must be:

  • six bytes and not all zero;
  • assigned by the manufacturer, not a group or a locally administered address (the iOS/Android placeholder, containers, randomized Wi-Fi addresses, many VPN and VM adapters);
  • not one of the fixed addresses that VMware, VirtualBox, Cisco AnyConnect, FortiClient or GlobalProtect give their adapters on every machine, or that Intel Macs with a T2 chip give their internal bridge adapter.

Loopback interfaces are skipped. An interface that throws no longer hides the ones after it.

Fallback. With no such address, a random GUID is hashed and stored in .machinehash, just like an address-based id. This is always the case on iOS and Android, and on Macs whose Wi-Fi uses a private address. Before, a failure to enumerate interfaces produced an id that was never stored, so it changed on every run.

Stored ids (MachineIdSource.IsSharedMachineId). A stored id equal to the hash of one of those shared addresses is discarded and replaced, so machines that have already run get an id of their own on their next start.

What stays the same:

  • Stored ids that are not shared are kept as they are.
  • A machine whose first interface was already acceptable derives the same id as before.
  • The WebAssembly path is untouched.

docs/usage.md now describes how the desktop Machine ID is derived.

PR Checklist

  • Tested code with current supported SDKs: the library builds for netstandard2.0, net8.0 and net9.0 with no warnings. Unit tests ran on net8.0, macOS arm64.
  • Docs have been added/updated (docs/usage.md)
  • Unit Tests and/or UI Tests for the changes have been added: MachineIdSourceTests, 38 cases. All 117 unit tests pass.
  • Wasm UI Tests: not run. The WebAssembly path returns before any of the changed code.
  • Contains NO breaking changes: no public API change (only internal types change). Machine IDs do change for the affected machines, which is the point.
  • Updated the Release Notes: this repository has no release notes file.
  • Associated with an issue (GitHub or internal)

Other information

Effect on consumers

  • A machine that reported a shared id gets a new, distinct one on the first start of a build that includes this change. Expect per-platform unique-user counts to rise at that version.
  • .machinehash is shared by every product on a machine. Once any product with this change has run there, products still on older versions read the corrected id too.
  • Building the set of shared ids costs about 4 ms once per process, on the background initialization path. Lookups after that take well under a microsecond.

Known limitation. On a machine that needs a random id, several products with this change starting at the same instant can each generate one. The last write wins, so for that one session they may report different ids.

Tests. MachineIdSourceTests covers:

  • the address rules: manufacturer-assigned, placeholder, loopback, multicast, tunnel, the VPN/VM adapters and the Apple T2 bridge;
  • selection order;
  • interface and enumeration failures;
  • the pinned hashes of the shared ids earlier versions stored;
  • the stored-id lifecycle through TelemetryCommonProperties.

Against the previous implementation, two of the stored-id tests fail and the enumeration-failure test stops the test host (through Debug.Fail).

Internal Issue (If applicable): tracked internally.

🤖 Generated with Claude Code

The machine id hashed the first network interface that was up. That is
the loopback adapter on iOS, Android, macOS and Linux, and on Windows
often a VPN or VM adapter whose address is the same on every machine, so
all of those machines reported one id. The GUID fallback never ran,
because an empty address converts to "" rather than null.

Only accept a six-byte, manufacturer-assigned address that is not one of
the fixed VMware, VirtualBox, Cisco AnyConnect, FortiClient or
GlobalProtect adapter addresses; otherwise hash a random GUID and store
it. Replace a stored id that was hashed from one of those shared
addresses, so machines that have already run get an id of their own.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Jen-Uno
Jen-Uno marked this pull request as ready for review October 8, 2026 16:58
@Jen-Uno
Jen-Uno requested a review from DerekRaven October 8, 2026 17:27
@rajamatt
rajamatt self-requested a review October 8, 2026 18:19
Intel Macs with a T2 chip expose an internal bridge adapter whose
address, ac:de:48:00:11:22, is the same on every one of them and is not
marked as locally administered. When Wi-Fi uses a private address it
was the one picked, so those Macs would again share one id.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Jen-Uno
Jen-Uno enabled auto-merge October 8, 2026 19:20
@mergify

mergify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@Jen-Uno
Jen-Uno merged commit 284bf70 into main Oct 8, 2026
11 checks passed
@Jen-Uno
Jen-Uno deleted the dev/jen/machine-id-collisions branch October 8, 2026 19:28
@welcome

welcome Bot commented Oct 8, 2026

Copy link
Copy Markdown

Congrats on your first pull-request! We ❤ the people who are involved in this project, and we’d love to pay it forward by sending you some swag. If you have any feedback (or ideas how to improve Uno as a open-source project) please open a feedback issue.
giphy
Merci beaucoup 👋

opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-unoplatform__uno that referenced this pull request Oct 23, 2026
Picks up the machine id fix (unoplatform/uno.devtools.telemetry#32),
which stops hashing the loopback or a shared VPN/VM adapter address
into one id shared by unrelated machines, and replaces a cached
shared id on the next start.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

2 participants