From d0a1668a69e6181a578de6bde4d3960676ceded9 Mon Sep 17 00:00:00 2001 From: max Date: Mon, 16 Nov 2026 17:51:42 +0000 Subject: [PATCH 1/2] action: send X-Blacksmith-VM-Token on metadata reads so testbox keeps working once the host requires it The host agent identifies a VM by the token it puts on the kernel cmdline (vm_token=) and answers metadata requests only when that token is presented in X-Blacksmith-VM-Token. The three metadata reads in the phone-home step (installationModelID, backendURL, stickyDiskToken) sent no header, so they are the tokenless requests the host counts today and would be 401s under enforcement. Read the token the same way as metadata_port, mask it in the job log, and send it on every read. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- action.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index b1e636a..f617256 100644 --- a/action.yml +++ b/action.yml @@ -54,11 +54,27 @@ runs: mkdir -p "$STATE" chmod 700 "$STATE" - INSTALLATION_MODEL_ID=$(curl -sf --connect-timeout 2 --max-time 5 "http://${METADATA_ADDR}/installationModelID" || true) + # The host hands each VM its own token on the kernel cmdline and the + # metadata service only answers requests that present it in + # X-Blacksmith-VM-Token. Read it the same way as metadata_port. + VM_TOKEN="${BLACKSMITH_VM_TOKEN:-}" + if [ -z "$VM_TOKEN" ]; then + VM_TOKEN=$(tr ' ' '\n' < /proc/cmdline | grep '^vm_token=' | cut -d'=' -f2- || true) + fi + if [ -n "$VM_TOKEN" ]; then + echo "::add-mask::${VM_TOKEN}" + fi + metadata_get() { + curl -sf --connect-timeout 2 --max-time 5 \ + -H "X-Blacksmith-VM-Token: ${VM_TOKEN}" \ + "http://${METADATA_ADDR}/$1" || true + } + + INSTALLATION_MODEL_ID=$(metadata_get installationModelID) if [ -n "$API_URL_OVERRIDE" ]; then API_URL="$API_URL_OVERRIDE" else - API_URL=$(curl -sf --connect-timeout 2 --max-time 5 "http://${METADATA_ADDR}/backendURL" || true) + API_URL=$(metadata_get backendURL) fi # Piggyback on the VM's stickyDiskToken for phone-home authentication. @@ -66,7 +82,7 @@ runs: # installation, and the backend binds it to the runner that adopted this # testbox's run. It's only accessible from inside the VM via the metadata # service and is not publicly visible. - AUTH_TOKEN=$(curl -sf --connect-timeout 2 --max-time 5 "http://${METADATA_ADDR}/stickyDiskToken" || true) + AUTH_TOKEN=$(metadata_get stickyDiskToken) # The host agent serves the literal "unset" when the backend minted no token. if [ "$AUTH_TOKEN" = "unset" ]; then AUTH_TOKEN="" From 7126961073c88d3256bb7f078cd29fe721676258 Mon Sep 17 00:00:00 2001 From: max Date: Mon, 16 Nov 2026 20:33:08 +0000 Subject: [PATCH 2/2] action: read the VM token from BLACKSMITH_VM_TOKEN only The runner exports the host-minted token into every step's environment on Linux, Windows and macOS, so the step relies on that variable and does not fall back to parsing vm_token= from /proc/cmdline. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- action.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index f617256..6c354c0 100644 --- a/action.yml +++ b/action.yml @@ -54,13 +54,10 @@ runs: mkdir -p "$STATE" chmod 700 "$STATE" - # The host hands each VM its own token on the kernel cmdline and the - # metadata service only answers requests that present it in - # X-Blacksmith-VM-Token. Read it the same way as metadata_port. + # The runner exports the host-minted per-VM token as BLACKSMITH_VM_TOKEN + # and the metadata service only answers requests that present it in + # X-Blacksmith-VM-Token. VM_TOKEN="${BLACKSMITH_VM_TOKEN:-}" - if [ -z "$VM_TOKEN" ]; then - VM_TOKEN=$(tr ' ' '\n' < /proc/cmdline | grep '^vm_token=' | cut -d'=' -f2- || true) - fi if [ -n "$VM_TOKEN" ]; then echo "::add-mask::${VM_TOKEN}" fi