Conversation
ecr_scan.py resolved the image digest and then never used it — `sha` was
read from describe_images and passed only to a log line, while both
describe_image_scan_findings callers still addressed the image by its
mutable tag.
CI tags are deterministic: compute_ci_tag.sh derives them from config
metadata, so every rebuild of a config pushes the same tag to a new
digest. The gate then reads findings across a window where the tag can
move — SCAN_WAIT_PERIOD * SCAN_WAIT_LENGTH is up to 20 minutes of
polling, followed by another SCAN_POST_COMPLETE_WAIT of 120 seconds
before findings are read. A re-run, dispatch build, or any other caller
pushing the same tag inside that window redirects the query to a
different image. The pipeline concurrency key includes inputs.config-file,
which serializes runs of the same config but nothing else.
The direction that matters for a security gate is the bad one: an image
carrying non-allowlisted CRITICAL/HIGH CVEs can pass on findings that
belong to a different, cleaner digest.
Thread the resolved digest through get_scan_status() and
get_scan_findings() as imageId={"imageDigest": sha}, which ECR accepts in
place of a tag. The tag is kept in log output for readability.
Closes aws#6517
Signed-off-by: Aditya Jain <adityaj0@uci.edu>
Author
|
@Jyothirmaikottu can you review this? |
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.
Purpose
Fixes #6517.
test/security/scripts/ecr_scan.pyresolved the image digest and then never used it.shawas read fromdescribe_imagesat L206 and passed only to a log line, while bothdescribe_image_scan_findingscallers still addressed the image by its mutable tag (L53, L63).CI tags are deterministic and overwritten:
compute_ci_tag.shderives the CI tag from config metadata, so every rebuild of a config pushes the same tag to a new digest. The gate reads findings across a window in which that tag can move:SCAN_WAIT_PERIOD(40) ×SCAN_WAIT_LENGTH(30) = up to 20 minutes of pollingSCAN_POST_COMPLETE_WAIT(120s) before findings are readA re-run, a dispatch build, or any other caller pushing the same CI tag inside that window redirects the query to a different image. The pipeline concurrency key includes
inputs.config-file, which serializes runs of the same config, but nothing else.The failure direction that matters for a security gate is the bad one: an image carrying non-allowlisted CRITICAL/HIGH CVEs can pass on findings belonging to a different, cleaner digest.
Change: thread the already-resolved digest through
get_scan_status()andget_scan_findings()asimageId={"imageDigest": sha}— ECR accepts a digest in place of a tag inimageId. The tag stays in log output for readability. An added comment records why the digest is used, so it does not get collapsed back to the tag later.Deliberately minimal: this is the tag/digest defect only.
Test Plan
No behavioural test is included, and I want to be straightforward about why: exercising this needs a live ECR repository with an Inspector v2 enhanced scan and a tag re-pushed mid-scan. That is beyond what a unit test can reach, and a mock that asserts "we passed a digest" would only restate the diff. The issue documents the race in full so it can be validated against real infrastructure.
What is checkable statically, and what I ran:
Test Result
No callers outside the file, so the signature change is self-contained.
The only remaining
imageTagis thedescribe_imageslookup that resolves the digest in the first place — which is correct, that is the tag→digest resolution.Adjacent observations (not addressed here)
Both in
wait_for_status()(test/test_utils/__init__.py), independent of this fix:period_lengthlate — 30s for this caller.FAILEDstill polls for the full 20 minutes.Left alone to keep this PR to one defect. Happy to file separately.
Toggle if you are merging into main Branch
PR Checklist
pre-commit run --all-fileslocally before creating this PR.Not fully run — disclosing rather than checking the box.
pre-commitcould not install its hook environments in my sandbox (URLError: CERTIFICATE_VERIFY_FAILEDfetching the hook repos). What I ran instead, directly:ruff format --checkon the changed file — pass (1 file already formatted), using the repo'spyproject.tomlconfig (line-length 100, py312)python3 -m py_compile— passNot run: typos, gitleaks, mdformat.