Skip to content

push-current-arch.sh: TOCTOU between git HEAD snapshot and per-variant filesystem read #953

Open

Description

@joelteply

airc-queue card

Coordinates work via the AIRC queue substrate (airc#562). Edit this card by commenting OR by running airc queue claim/airc queue release/airc queue heartbeat (later PRs).

{
  "kind": "airc-queue-card-v1",
  "id": "#953",
  "owner": "claude-tab-2",
  "status": "claimed",
  "evidence": "Adopted existing GitHub issue into airc queue.",
  "next_action": "Triage, claim, or close this adopted backlog card."
}

Close this issue when the work is done (status=merged/abandoned).

Original issue body

Pre-adoption body

Problem

`scripts/push-current-arch.sh` snapshots `git rev-parse --short HEAD` once at startup and tags all built images with that SHA. But `docker buildx` re-reads the live filesystem per variant. If the working directory mutates mid-push (rebase, pull, commit), later variants get built from new source but tagged with the old SHA — silent contamination.

Caught how

Hit live during 2026-04-23 PR session. bigmama-wsl ran `push-current-arch.sh` for 4 amd64 variants (~60min), and during the cuda compile they fetched + rebased + committed a livekit-bridge fix. Result:

  • `continuum-core-cuda:7da9dbea3` was actually built from `b4cb6157e` source
  • `--version` flag in the cuda image showed the NEW behavior despite the OLD tag
  • Verified via in-container exec: behavior didn't match the SHA on the tag

Carl/contributor impact

A contributor starts a 60-80min push, pulls + commits during it (totally normal during a long-running build), and silently produces an inconsistent image set. The discrepancy only shows up if someone explicitly tests behavior against tag — most won't.

Fix direction

In `push-current-arch.sh`:

  1. Refuse to start if working directory has any tracked-file modifications:
    `if ! git diff-index --quiet HEAD --; then die "working directory has uncommitted changes; commit, stash, or use a worktree"; fi`
  2. Snapshot HEAD at startup, then per-variant assert `git rev-parse HEAD == $STARTUP_SHA`. Fail loud if it changed.
  3. Even safer: `git worktree add /tmp/push-arch-$$ $STARTUP_SHA` and build from THAT path → guaranteed-stable source regardless of what happens to the live working directory. Cleanup on exit.

Estimated diff: ~20 lines.

Owner

@bigmama-wsl (drafted patch at /tmp/push-current-arch-toctou.patch on bigmama-1; applying after the in-flight rebuild finishes — committing now would trigger the very bug being fixed)

Activity

  1. added
    bug
    grid
    on Apr 23, 2026
  2. added a commit that references this issue on Apr 23, 2026
    6fa90ac
  3. added
    airc-queue
    on May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    airc-queuebuggrid

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions