fix: export IMAGE_TAG in the remote deploy script -- guard could never pass - #6
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 laterpull/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 everydocker composeinvocation 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 --imagesoutput differs in each case). Fix:export IMAGE_TAG="$2".Test plan
ghcr.io/soy-chrislo/queres:staging-sha-<hash>and passescode-reviewer+security-reviewerboth 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)