Skip to content

fix(ci): use BuildKit secrets instead of build-arg for GITHUB_TOKEN#327

Merged
drew merged 1 commit intomainfrom
fix-ci-token-leak/an
Mar 15, 2026
Merged

fix(ci): use BuildKit secrets instead of build-arg for GITHUB_TOKEN#327
drew merged 1 commit intomainfrom
fix-ci-token-leak/an

Conversation

@drew
Copy link
Collaborator

@drew drew commented Mar 15, 2026

Summary

  • MISE_GITHUB_TOKEN was passed via --build-arg in the CI image build, which persists the value in Docker image layer metadata (extractable via docker history / docker inspect)
  • Switched to BuildKit --mount=type=secret so the token is only available as a tmpfs file during the RUN step and is never written to any image layer
  • Local builds without the secret continue to work (graceful fallback to empty string)

Changes

  • .github/workflows/ci-image.yml — replaced --build-arg MISE_GITHUB_TOKEN=... with --secret id=MISE_GITHUB_TOKEN,env=MISE_GITHUB_TOKEN; token is set as a step-level env var
  • deploy/docker/Dockerfile.ci — removed ARG MISE_GITHUB_TOKEN; added --mount=type=secret,id=MISE_GITHUB_TOKEN to the RUN instruction that calls mise install

Testing

  • The Dockerfile already has # syntax=docker/dockerfile:1.4 (BuildKit enabled), so --mount=type=secret is fully supported
  • The 2>/dev/null || true fallback ensures local builds without the secret still work
  • CI will validate on next push to main after merge

Build arguments persist in Docker image layer metadata and can be
extracted with docker history or docker inspect. Switch to
--mount=type=secret so the token is only available during the RUN
step and never written to any image layer.
@drew drew self-assigned this Mar 15, 2026
@drew drew requested review from johntmyers and pimlock March 15, 2026 19:49
@drew drew merged commit 66ba07f into main Mar 15, 2026
9 checks passed
@drew drew deleted the fix-ci-token-leak/an branch March 15, 2026 19:53
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