Skip to content

Fix UWORKER initialization crash by bypassing Wi-Fi Datastore queries in Android#5290

Open
jardondiego wants to merge 3 commits into
masterfrom
fix-uworker-wifi-datastore
Open

Fix UWORKER initialization crash by bypassing Wi-Fi Datastore queries in Android#5290
jardondiego wants to merge 3 commits into
masterfrom
fix-uworker-wifi-datastore

Conversation

@jardondiego
Copy link
Copy Markdown
Collaborator

@jardondiego jardondiego commented May 22, 2026

Overview

This PR fixes a critical initialization crash that occurs when untrusted workers (UWORKERs) attempt to set up Android emulators.

The Bug

During the Android device initialization sequence, wifi.configure() is called to ensure the device is connected to the network. This function attempts to retrieve Wi-Fi credentials (SSID/password) by calling db_config.get(), which queries Google Cloud Datastore.

However, UWORKER containers run under a restricted security boundary and are explicitly denied IAM permissions to access Datastore (to prevent malicious fuzzers from escalating privileges or stealing project secrets). When the Datastore SDK intercepts the request, it returns a 403 Missing or insufficient permissions exception. Because this exception is
unhandled, it violently crashes the entire setup process, preventing the UWORKER from ever reaching the fuzzing loop.

The Fix

This PR introduces an environment check at the top of wifi.configure():

if environment.is_uworker():
   return

This gracefully short-circuits the function for untrusted workers, bypassing the illegal Datastore query.

Notes

  1. Networking works without it: Android emulators executed via Swarming in this architecture share the host network namespace (--network=host). They inherit outbound internet access directly from the Swarming bot's host machine and do not require explicit Wi-Fi credentials to be injected.
  2. Established Pattern: This mirrors the exact same security bypass we already use in device.add_test_accounts_if_needed(), which also short-circuits to avoid Datastore queries in UWORKERs.

Fixed line too long and trailing whitespace issues to pass the CI.
@jardondiego jardondiego marked this pull request as ready for review May 22, 2026 01:37
@jardondiego jardondiego requested a review from a team as a code owner May 22, 2026 01:37
@jardondiego jardondiego changed the title Fix wifi.configure UWORKER Datastore access crash Fix UWORKER initialization crash by bypassing Wi-Fi Datastore queries in Android May 22, 2026
This adds a unit test to verify that wifi.configure() safely returns early when executed inside a UWORKER environment, preventing a crash caused by illegal Datastore queries for Wi-Fi credentials.
Copy link
Copy Markdown
Collaborator

@fernandofloresg fernandofloresg left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -0,0 +1,40 @@
# Copyright 2024 Google LLC
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# Copyright 2024 Google LLC
# Copyright 2026 Google LLC

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