Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ apt-get clean
rm -rf /var/lib/apt/lists/*
EOF
COPY --chmod=0755 --from=docker/mcp-gateway:v2 /docker-mcp /usr/local/lib/docker/cli-plugins/docker-mcp
COPY --chmod=0755 --from=registry.k8s.io/kubectl:v1.37.0 /bin/kubectl /usr/local/bin/kubectl

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium/security] Mutable image tag used for kubectl COPY source — no digest pin

The COPY --from=registry.k8s.io/kubectl:v1.37.0 instruction references a mutable version tag. If this tag is ever overwritten on the registry, future builds will silently pull a different binary, which is a supply-chain integrity risk. While registry.k8s.io is the official, well-governed Kubernetes registry and the realistic risk of tag mutation for a versioned release tag is low, pinning to an immutable digest fully eliminates the risk.

To fix, pin the image to a specific digest alongside the version tag:

COPY --chmod=0755 --from=registry.k8s.io/kubectl:v1.37.0@sha256:<digest> /bin/kubectl /usr/local/bin/kubectl

You can obtain the digest by running:

crane digest registry.k8s.io/kubectl:v1.37.0

or by checking the image manifest on the registry.

Note: The existing docker/mcp-gateway:v2 line above uses the same mutable-tag pattern, so this is consistent with current project practice — but both lines carry this risk.

Confidence Score
🟡 moderate 70/100

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid of the compatibility. K8s is still ensuring the compat with 2 minor versions up and down ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point about Kubernetes version skew policy. You're right that digest pinning locks you to the exact binary, preventing even patch-level updates that might improve compatibility or fix bugs.

However, digest pinning doesn't prevent you from updating — it just makes updates explicit. When you need to bump kubectl (for compatibility, security, or features), you'd update both the tag and digest together. The trade-off is: mutable tags give silent updates (convenient but risky), while digest pins give explicit updates (safer but require active maintenance).

For a kubectl client used by Docker Agent, the skew policy means v1.37.0 works with clusters running 1.35–1.38. If you're comfortable with the supply-chain risk from mutable tags (especially since registry.k8s.io is well-governed), and you value the flexibility of automatic patch updates, keeping the tag-only reference is a reasonable choice. Just be aware that if the tag is ever republished, your builds will silently use the new artifact.

COPY --chmod=0755 --from=amazon/aws-cli:2.36.42 /usr/local/aws-cli/ /usr/local/aws-cli/
RUN ln -s /usr/local/aws-cli/v2/current/bin/aws /usr/local/bin/aws && \
ln -s /usr/local/aws-cli/v2/current/bin/aws_completer /usr/local/bin/aws_completer
USER agent
ENV DOCKER_AGENT_NO_TOUR=1 \
DOCKER_AGENT_HIDE_TELEMETRY_BANNER=1 \
Expand Down
2 changes: 2 additions & 0 deletions docs/configuration/sandbox/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ layers onto `docker/sandbox-templates:shell-docker` and adds:

- The `docker-agent` binary.
- `vim` and `tmux`, for interactive debugging inside the VM.
- `kubectl`, for interacting with Kubernetes clusters from inside the VM.
- The **AWS CLI** (`aws`), for working with AWS from inside the VM.
- The **`docker-mcp`** Docker CLI plugin, installed at `~/.docker/cli-plugins/docker-mcp`.

The image carries the label `com.docker.sandboxes.flavor=docker-agent-docker`
Expand Down
Loading