Skip to content

Fix GitHub token leak in Docker image builds#313

Merged
butschster merged 1 commit into
masterfrom
fix/docker-secret-token-leak
Mar 26, 2026
Merged

Fix GitHub token leak in Docker image builds#313
butschster merged 1 commit into
masterfrom
fix/docker-secret-token-leak

Conversation

@butschster
Copy link
Copy Markdown
Member

Summary

  • Security fix: GH_TOKEN was passed as --build-arg and stored via ENV in image layers, making it visible through docker history/docker inspect to anyone pulling the published image
  • Switch to BuildKit secrets (RUN --mount=type=secret): the token is mounted in memory only during the RUN command and never persisted in any image layer
  • Update both GitHub Actions workflows (docker-image.yml, docker-dev-image.yml) to pass token via secrets: instead of build-args:
  • Update docker-compose.yaml to use secrets definition sourced from GH_TOKEN environment variable

Test plan

  • Verify Docker image builds successfully in CI with the new secret mount
  • Run docker history on the built image and confirm no token is visible
  • Verify local GH_TOKEN=... docker compose build still works

🤖 Generated with Claude Code

The GH_TOKEN was passed as a build-arg and stored via ENV in image
layers, making it visible through docker history/inspect to anyone
pulling the published image.

Switch to BuildKit secrets:
- Dockerfile: use RUN --mount=type=secret,id=gh_token so the token
  is only available in memory during the RUN command and never
  persisted in any layer
- GitHub Actions workflows: pass token via secrets instead of
  build-args
- docker-compose.yaml: use secrets definition sourced from
  environment variable

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@butschster butschster merged commit f5d82b4 into master Mar 26, 2026
7 checks passed
@butschster butschster deleted the fix/docker-secret-token-leak branch March 26, 2026 21:10
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.

1 participant