Repository navigation
Description
Summary
Four production Dockerfiles run their CMD as root. Only docker/base-image/Dockerfile (agent base) drops to a non-root developer user. This is a defense-in-depth gap — not a standalone exploit, but it amplifies the blast radius of any future RCE.
Flagged by /cso at MEDIUM, 10/10 confidence, persistent since the 2026-04-05 audit (~6 weeks).
Affected Files
-
docker/backend/Dockerfile— FastAPI backend,python:3.11-slimbase, noUSERdirective (ends at line 70). Highest risk — backend has/var/run/docker.sock:romounted, so root inside this container can enumerate every Trinity agent container by label. -
docker/scheduler/Dockerfile— APScheduler service,python:3.11-slimbase, noUSERdirective. -
docker/frontend/Dockerfile.prod—FROM nginx:alpine, noUSERdirective. nginx master defaults to root; only worker processes drop tonginx. -
src/mcp-server/Dockerfile— TypeScript MCP server,node:22-alpinebase, noUSERdirective.
No user: override in docker-compose.yml or docker-compose.prod.yml, confirming containers actually run as root in production.
Exploit Scenario
Any RCE in the FastAPI backend (e.g., a future variant of #590 file-write RCE, a deserialization bug in a router, a vulnerable dep introduced via supply chain) lands as root inside the backend container. Because /var/run/docker.sock is bind-mounted read-only:
- Attacker reads Docker socket → enumerates every agent container, owner labels, network bindings.
- Reads in-container env vars (
ANTHROPIC_API_KEY,REDIS_URLwith backend creds,SECRET_KEY). - Reaches Redis on
trinity-platform-networkwith the credential pair already in env. - If combined with any write primitive (volume bind to host paths, Redis ops on platform queue), pivots further.
Read-only socket blocks docker exec / docker run, so this is not a direct container escape. But "no USER" turns a single-point RCE into a fleet-wide reconnaissance primitive.
Acceptance Criteria
-
docker/backend/Dockerfileends onUSER trinity(or equivalent non-root UID 1000). -
docker/scheduler/Dockerfileends on a non-rootUSER. -
docker/frontend/Dockerfile.prodruns nginx unprivileged. EitherUSER nginxwithlisten 8080;adjustment + compose port remap, or thenginxinc/nginx-unprivilegedbase image. -
src/mcp-server/Dockerfileends on a non-rootUSER. -
./scripts/deploy/start.shbrings up the full stack with no permission-denied errors. - Backend can still read
/data/trinity.db(bind mount),/data/agent-files/, write logs. - Vector still scrapes container logs (Docker socket access unaffected — Vector has its own
:romount, no change needed). - MCP server binds port 8080 and authenticates Bearer tokens normally.
- nginx (frontend.prod) serves
/, reverse-proxies/api/*to backend, serves WebSocket upgrades. - No CI workflow breakage (frontend-e2e.yml uses these images).
Reference Pattern
docker/base-image/Dockerfile:70-132 already demonstrates the working pattern — groupadd / useradd near the top, USER root only around steps that need it (e.g., apt-get), USER developer for the final state. Use this as a template.
For the backend specifically:
# docker/backend/Dockerfile (end of file)
RUN groupadd --gid 1000 trinity && \
useradd --uid 1000 --gid trinity --home /app --shell /bin/bash trinity && \
chown -R trinity:trinity /app
USER trinityTechnical Notes
nginx:alpinerequires either (a) switching tonginxinc/nginx-unprivilegedwhich listens on 8080 by default and runs asnginxuser, then remapping80 → 8080in compose, or (b) writing a customnginx.confwithlisten 8080;+ creating writable temp dirs for thenginxuser. The unprivileged image is simpler.- MCP server (Node) needs the workspace ownership flipped:
RUN chown -R node:node /app && USER nodeafter thenpm cistep. - Scheduler reads/writes the same SQLite DB as backend via
/databind mount. If backend uses UID 1000, scheduler must use the same UID to share file ownership. - Confirm Docker socket mount stays
:ro(it should — Vector also mounts:ro). No change to compose volumes needed.
Prior Reports
docs/security-reports/cso-2026-04-05.md:33— original finding (MEDIUM, 10/10, VERIFIED)docs/security-reports/cso-2026-04-05.md:151— trend table marks this PERSISTENTdocs/security-reports/cso-2026-05-17.md— re-verified today, still all 4 files, nouser:override in compose
Why Bundle as One PR
All four Dockerfiles share the same UID-1000 strategy (consistent with docker/base-image/Dockerfile). Splitting per-file creates 4× the review overhead with no isolation benefit — these images are independent at runtime, so the only shared risk is "did the dev test the stack came up cleanly". One PR with one ./scripts/deploy/start.sh smoke test covers all of them.
Activity
AndriiPasternak31 commentedon May 17, 2026
/claim
github-actions commentedon May 17, 2026
Claimed by @AndriiPasternak31. Label
status-in-progressadded.Next steps:
feature/874-<short-slug>Fixes #874fix(security): non-root USER directives for production images (#874)
ci(security): split non-root container guards into dedicated workflow
fix(security): non-root USER directives for production images (#874)
ci(security): split non-root container guards into dedicated workflow
fix(security): non-root USER directives for production images (#874)
ci(security): split non-root container guards into dedicated workflow
fix(security): non-root USER directives for production images (#874) (#…
Merge pull request #969 from Abilityai/fix/958-deploy-non-root-volume…
fix(deploy-local): write templates to host-mapped path (#950) (#971)
vybe commentedon Jun 1, 2026
Shipped in v0.6.0 (released via #998).
fix(deploy): probe in-container docker.sock GID so non-root backend r…
fix(deploy): auto re-own data volumes to UID 1000 (Abilityai#958 / Ab…