Skip to content

fix: export IMAGE_TAG in the remote deploy script -- guard could never pass - #6

Merged
soy-chrislo merged 1 commit into
mainfrom
fix/export-image-tag
Jul 31, 2026
Merged

fix: export IMAGE_TAG in the remote deploy script -- guard could never pass#6
soy-chrislo merged 1 commit into
mainfrom
fix/export-image-tag

Conversation

@soy-chrislo

Copy link
Copy Markdown
Owner

Summary

Found by a security-reviewer pass requested before editing the live VPS compose file (ahead of the actual cutover), not by code review alone -- this was caught empirically, not by inspection.

docker compose config --images (and the later pull/up -d) run as separate child processes. A compose file's ${IMAGE_TAG:-...} interpolation only sees variables actually present in that child process's environment. IMAGE_TAG="$2" in the remote deploy script was a plain shell assignment, never exported -- so every docker compose invocation would silently fall back to the compose file's default (<env>-latest) instead of the immutable per-commit tag. Practical effect: the guard that verifies the pin would never match (deploy always aborts, safely, but for the wrong stated reason), and if that guard were ever bypassed, a real deploy would pull/run the wrong, mutable image -- the opposite of what IMAGE_TAG-pinning exists for.

Verified empirically: a minimal compose file with ${IMAGE_TAG:-x} resolves to the default when IMAGE_TAG is a plain assignment in the calling shell, and resolves correctly once exported (docker compose config --images output differs in each case). Fix: export IMAGE_TAG="$2".

Test plan

  • Empirical local test confirms the exact failure mode and the fix
  • Full remote-script simulation against a mock compose file: guard now correctly resolves ghcr.io/soy-chrislo/queres:staging-sha-<hash> and passes
  • code-reviewer + security-reviewer both run on the actual diff -- traced DEPLOY_PATH/TMP_DIR to confirm neither has the same exposure (both are shell-only usages, no export needed), confirmed no unintended leak of IMAGE_TAG into the alpine or app containers, confirmed the export must survive through pull/up -d (un-exporting after the guard would just relocate the bug)

…r pass

docker compose config --images runs as a separate child process, and a
compose file's \${IMAGE_TAG:-...} interpolation only sees variables that
are actually in that process's environment. IMAGE_TAG was a plain shell
assignment, not exported, so every docker compose invocation in the
remote script would silently fall back to the compose file's default
(<env>-latest) instead of the immutable per-commit tag -- meaning the
guard that verifies the pin would never match, and had it ever been
bypassed, an actual deploy would pull/run the wrong, mutable image
instead of the pinned commit.

Verified empirically: a minimal compose file with \${IMAGE_TAG:-x}
resolves to the default when IMAGE_TAG is a plain assignment in the
calling shell, and resolves correctly once exported. Caught by a
security-reviewer pass requested before editing the live VPS compose
file, ahead of any real cutover attempt.
@soy-chrislo
soy-chrislo merged commit b995e8b into main Jul 31, 2026
4 checks passed
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