Skip to content

mcp: run image as numeric non-root user - #94

Merged
djannot merged 1 commit into
kagent-dev:mainfrom
SarthakB11:harden/mcp-rootless-user
Nov 2, 2026
Merged

djannot merged 1 commit into
kagent-dev:mainfrom
SarthakB11:harden/mcp-rootless-user

Conversation

@SarthakB11

Copy link
Copy Markdown
Contributor

What

mcp/Dockerfile creates a non-root user but never sets USER, so the container runs as root. This sets USER to the numeric UID 14000 and aligns the runtime user with the root image's doc2vec:14000 account.

Why

With no USER, the image runs as root, which forces consumers to pin runAsUser in their pod spec and blocks rootless or OpenShift-style deployments. A numeric USER lets kubelet verify runAsNonRoot at admission time (a non-numeric username cannot be checked). It also lets downstream charts, such as kagent's querydoc subchart that pulls this image, drop their runAsUser pin.

How verified

Built with buildx and ran the image:

  • docker run --entrypoint id reports uid=14000(doc2vec) gid=14000(doc2vec)
  • docker inspect -f '{{.Config.User}}' reports 14000
  • /app and /app/build are owned by doc2vec, and the runtime user can write to /app/build (needed for SQLite journal/WAL files)
  • the entrypoint starts as UID 14000 with no permission errors

The mcp image created a non-root user but never set USER, so the
container still ran as root. Set USER to the numeric UID 14000 and
align the user with the root image's doc2vec:14000 account.

A numeric USER lets kubelet enforce runAsNonRoot and lets downstream
charts (such as kagent's querydoc subchart) drop their runAsUser pin.

Signed-off-by: Sarthak Bhardwaj <[email protected]>
@djannot
djannot merged commit 4d09fd4 into kagent-dev:main Nov 2, 2026
3 checks passed
@djannot djannot mentioned this pull request Nov 2, 2026
djannot added a commit that referenced this pull request Nov 2, 2026
- #94 mcp: run image as numeric non-root user 14000
- #134 chore(deps): upgrade cheerio, chonkie, sqlite-vec and the S3 client

Signed-off-by: Denis Jannot <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

2 participants