Skip to content

fix(CPL-300): drop root in lit-api-server and lit-actions containers#333

Open
GTC6244 wants to merge 1 commit intonextfrom
feature/cpl-300-high-dockerfilelit-api-server-and-dockerfilelit-actions-have
Open

fix(CPL-300): drop root in lit-api-server and lit-actions containers#333
GTC6244 wants to merge 1 commit intonextfrom
feature/cpl-300-high-dockerfilelit-api-server-and-dockerfilelit-actions-have

Conversation

@GTC6244
Copy link
Copy Markdown
Contributor

@GTC6244 GTC6244 commented May 6, 2026

Summary

Closes the defense-in-depth gap from CPL-300 (audit finding from .context/CSO-CPL-281-report.md#11). Both Dockerfiles previously had no USER directive, so the containers ran as root inside the Phala CVM. Any RCE in lit-api-server (sandbox escape, panic-handler exploit, etc.) would have inherited root with full access to /var/run/dstack.sock — turning the dstack KMS into a signing/attestation oracle for arbitrary report_data.

Both Dockerfiles now drop to a non-root lit user (uid 10001, matching the existing convention in Dockerfile.otel-collector:9):

  • Dockerfile.lit-api-server: useradd -u 10001 -m lit + USER lit before CMD
  • Dockerfile.lit-actions: same pattern

Why this works without compose changes

  • /tmp/lit_actions.socklit-actions/grpc/unix.rs:66 already chmods the bound socket to 0o777, so the lit-api-server side connects regardless of UID. The shared lit-socket named volume initialises from the image's /tmp (mode 1777), so non-root binds.
  • /var/run/dstack.sock — bind-mounted from the host; the same compose's dstack-ingress service already accesses this socket without privileged mode, confirming non-root works.

Verification

  • docker buildx build --checkpasses both Dockerfiles, no warnings.
  • Live container check: useradd -u 10001 -m lit succeeds in debian:bookworm-slim, /tmp is mode 1777 (drwxrwxrwt), the lit user can create files there. So lit-actions can bind /tmp/lit_actions.sock.

Out of scope

The unrelated root-level Dockerfile (development convenience build) is also missing a USER directive but is not deployed to Phala. Tracked separately if the audit decides to widen scope.

Test plan

  • Phala Simulator Validation CI passes (validates dstack socket access end-to-end).
  • After merge: trigger Phala deploy on next and confirm lit-api-server and lit_actions start, id shows uid=10001(lit), and /attestation endpoint still returns a valid quote.

🤖 Generated with Claude Code

Both Dockerfiles now create a non-root lit user (uid 10001, matching
Dockerfile.otel-collector) and switch via USER before CMD. Closes the
defense-in-depth gap where any RCE in lit-api-server would yield root
in the Phala CVM with full access to /var/run/dstack.sock as a KMS
signing/attestation oracle.

Compatibility verified: lit-actions chmods /tmp/lit_actions.sock to 0o777
(see lit-actions/grpc/unix.rs), so lit-api-server connects regardless of
UID. dstack-ingress already runs non-root with the same dstack.sock mount.
docker buildx --check passes both files.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@GTC6244 GTC6244 requested review from a team and Copilot May 6, 2026 00:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the deployed Phala CVM containers by ensuring lit-api-server and lit-actions no longer run as root, reducing blast radius if an RCE or sandbox escape occurs.

Changes:

  • Add a dedicated non-root lit user (UID 10001) to the lit-api-server runtime image and switch execution to that user.
  • Add the same non-root lit user (UID 10001) to the lit-actions runtime image and switch execution to that user.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Dockerfile.lit-api-server Creates non-root lit user (uid 10001) and sets USER lit before starting lit-api-server.
Dockerfile.lit-actions Creates non-root lit user (uid 10001) and sets USER lit before starting lit_actions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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