Skip to content

fix(image): default OpenClaw sandbox to non-root - #7890

Open
deepujain wants to merge 10 commits into
NVIDIA:mainfrom
deepujain:fix/7882-default-sandbox-user
Open

fix(image): default OpenClaw sandbox to non-root#7890
deepujain wants to merge 10 commits into
NVIDIA:mainfrom
deepujain:fix/7882-default-sandbox-user

Conversation

@deepujain

@deepujain deepujain commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

The OpenClaw sandbox image now defaults to the sandbox user so OpenShell can accept its OCI metadata. Root-only image setup still completes during the build, and direct container runtimes can explicitly override the runtime user to root when gateway and agent UID separation is required.

Related Issue

Fixes #7882

Changes

  • Set the completed OpenClaw image's default OCI user to sandbox after all root-only build steps.
  • Verify the non-root default, no-new-privileges startup, and explicit root override against the built production image.
  • Keep root-only gateway-isolation tests explicit instead of relying on the image default.
  • Assert non-root PID 1 for the OpenClaw security-posture E2E shard.
  • Document the topology tradeoff and preserve USER sandbox in the custom OpenClaw plugin example.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification:
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: Pending maintainer review.
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes the DCO sign-off declaration and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above
    • docker build --progress=plain -t nemoclaw-7882-e2e .
    • NEMOCLAW_TEST_IMAGE=nemoclaw-7882-e2e bash test/e2e-non-root-smoke.sh (4 passed)
    • NEMOCLAW_TEST_IMAGE=nemoclaw-7882-e2e bash test/e2e-gateway-isolation.sh (45 passed)
    • npx vitest run --project e2e-support test/e2e/support/security-posture-workflow-boundary.test.ts test/e2e/support/security-posture.test.ts (5 passed)
    • Focused test/nemoclaw-start.test.ts integration selection (4 passed)
  • Applicable broad gate passed — committed-range pre-commit, commitlint, npm run build:cli, npm run typecheck:cli, and pre-push gates passed
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Deepak Jain deepujain@gmail.com

Summary by CodeRabbit

  • Bug Fixes

    • Container images now run as the non-root sandbox user by default, while still supporting explicit root overrides when required.
  • Tests

    • Expanded end-to-end coverage for default non-root behavior and explicit root-mode startup.
    • Strengthened security posture validation across supported runtime modes.
  • Documentation

    • Clarified guidance for gateway and agent user isolation.
    • Updated installation examples to return to sandbox after required root setup.

@copy-pr-bot

copy-pr-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The Docker image now defaults to sandbox. Runtime tests, workflow validation, gateway-isolation checks, deployment documentation, and security guidance cover non-root operation and explicit root overrides.

Changes

Non-root container execution

Layer / File(s) Summary
Set and validate runtime user
Dockerfile, docs/deployment/install-openclaw-plugins.mdx, scripts/nemoclaw-start.sh, test/e2e-non-root-smoke.sh
The image and documented extension stage default to sandbox. Smoke tests validate the OCI user metadata and explicit root-entrypoint behavior. Root mode emits a diagnostic marker.
Run root-mode isolation checks explicitly
test/e2e-gateway-isolation.sh
Gateway, configuration, proxy, model, and recovery scenarios explicitly start containers as root before internal user switching.
Parameterize entrypoint expectations
.github/workflows/e2e.yaml, tools/e2e/security-posture-workflow-boundary.mts, test/e2e/support/security-posture-workflow-boundary.test.ts
The security-posture matrix passes and validates OpenClaw and Hermes-specific non-root entrypoint expectations.
Document process-UID topology
docs/security/best-practices.mdx
Security guidance describes sandbox-default images, shared OpenShell UIDs, direct root overrides, and restrictions on root agent execution.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested labels: area: security, area: e2e, platform: container

Suggested reviewers: prekshivyas

Sequence Diagram(s)

sequenceDiagram
  participant Docker
  participant nemoclaw_start
  participant E2E_Runtime
  participant Workflow_Validator

  Docker->>nemoclaw_start: Start image as sandbox
  nemoclaw_start->>E2E_Runtime: Run non-root smoke checks
  Docker->>nemoclaw_start: Start image with --user root
  nemoclaw_start->>E2E_Runtime: Emit root mode and run command as sandbox
  Workflow_Validator->>E2E_Runtime: Validate matrix-specific entrypoint expectation
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: defaulting the OpenClaw image to the non-root sandbox user.
Linked Issues check ✅ Passed The Dockerfile ends with USER sandbox after root-only setup, and tests, entrypoint behavior, workflow validation, and documentation support issue #7882.
Out of Scope Changes check ✅ Passed The changes address non-root image defaults, explicit root overrides, security-posture validation, gateway isolation, and related documentation.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — Informational

Advisor assessment: Informational / low confidence
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions
Status: Same-session synthesis validation failed; the advisor result is incomplete.

Model lanes

  • GPT-5.6 Terra (primary): Completed · low confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Skipped

Second-opinion terminology and E2E selections are advisory. They do not change the primary assessment or E2E / PR Gate.

2 semantic terminology decisions

Terminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.

  • established — root-entrypoint at docs/security/best-practices.mdx:469: Keep `root-entrypoint` for this topology and retain the UID contrast in the surrounding text.
  • define — OpenShell compatibility at docs/security/best-practices.mdx:466: Define the phrase at first use as OpenShell acceptance of an OCI image whose default user is non-root.

E2E guidance

Advisory only. E2E / PR Gate selects and runs jobs independently.

Recommended E2E: cloud-inference, cloud-onboard, full-e2e, managed-image-multiarch-startup, security-posture

1 optional E2E recommendation
  • rebuild-openclaw

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

@deepujain

Copy link
Copy Markdown
Contributor Author

Updated the root-path coverage, OpenClaw security-posture assertion, and UID-isolation documentation. The production-image smoke and gateway-isolation suites pass.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/security/best-practices.mdx`:
- Around line 578-584: Update the security guidance near the “Never run as root”
recommendation to distinguish OpenShell’s default sandbox user from the explicit
direct-runtime root override. State that OpenShell should use sandbox by
default, while direct runtimes may use root only when separate gateway and agent
UIDs are required, keeping the surrounding security recommendation consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 2d81b3c3-dd44-47bb-afbe-6a86dbdcd625

📥 Commits

Reviewing files that changed from the base of the PR and between 1b2b457 and 5f722d5.

📒 Files selected for processing (7)
  • .github/workflows/e2e.yaml
  • docs/deployment/install-openclaw-plugins.mdx
  • docs/security/best-practices.mdx
  • test/e2e-gateway-isolation.sh
  • test/e2e-non-root-smoke.sh
  • test/e2e/support/security-posture-workflow-boundary.test.ts
  • tools/e2e/security-posture-workflow-boundary.mts

Comment thread docs/security/best-practices.mdx
@deepujain
deepujain force-pushed the fix/7882-default-sandbox-user branch from 7bb2703 to e60e529 Compare July 30, 2026 15:24
@deepujain

Copy link
Copy Markdown
Contributor Author

Rebased onto current main. Focused tests and npm run validate:pr pass; all commits remain verified.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/e2e-non-root-smoke.sh`:
- Around line 103-115: Update Test 3 in the root override assertion to require a
stable root-mode marker emitted by nemoclaw-start, rather than relying on the
absence of the free-form “Running as non-root” message. Keep the child command’s
UID check as a separate assertion, and make the test pass only when both the
root-only marker and expected sandbox UID are present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 7896ff63-d81c-446a-a732-110ad29173df

📥 Commits

Reviewing files that changed from the base of the PR and between 7bb2703 and e60e529.

📒 Files selected for processing (8)
  • .github/workflows/e2e.yaml
  • Dockerfile
  • docs/deployment/install-openclaw-plugins.mdx
  • docs/security/best-practices.mdx
  • test/e2e-gateway-isolation.sh
  • test/e2e-non-root-smoke.sh
  • test/e2e/support/security-posture-workflow-boundary.test.ts
  • tools/e2e/security-posture-workflow-boundary.mts
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/security/best-practices.mdx

Comment thread test/e2e-non-root-smoke.sh
@deepujain
deepujain force-pushed the fix/7882-default-sandbox-user branch from e60e529 to a0562b0 Compare July 31, 2026 06:11
@wscurran wscurran added area: packaging Packages, images, registries, installers, or distribution bug-fix PR fixes a bug or regression integration: openclaw OpenClaw integration behavior labels Jul 31, 2026
@wscurran

Copy link
Copy Markdown
Contributor

✨ Thanks for the PR. This fixes OpenShell compatibility by defaulting the OpenClaw sandbox image to the sandbox user instead of root. Maintainers will review the image build changes, non-root verification, and documentation updates.


Related open issues:


Related open issues:

@apurvvkumaria apurvvkumaria left a comment

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.

Reviewed exact head a0562b0. The OpenClaw image now defaults to the non-root sandbox user required by OpenShell, while direct runtimes retain an explicit root override that enters the existing privileged supervisor path and steps agent commands back down. Workflow, isolation, smoke, plugin-image, and operator documentation changes are consistent. I found no blocking security, compatibility, or regression defect. The failed E2E gate is a trusted-verdict timeout, not an attributable test failure.

Signed-off-by: Deepak Jain <deepujain@gmail.com>
Signed-off-by: Deepak Jain <deepujain@gmail.com>
Signed-off-by: Deepak Jain <deepujain@gmail.com>
Signed-off-by: Deepak Jain <deepujain@gmail.com>
@deepujain
deepujain force-pushed the fix/7882-default-sandbox-user branch from fa5987a to 8091faf Compare August 4, 2026 07:49
@deepujain

Copy link
Copy Markdown
Contributor Author

Rebased on current main. The image build, focused non-root checks, and full PR validation pass, and all commits are verified. @coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@deepujain I will review the rebased changes and the non-root runtime behavior.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@deepujain

Copy link
Copy Markdown
Contributor Author

Synced with latest main. Focused non-root checks and PR validation pass; CI is rerunning.

@deepujain

Copy link
Copy Markdown
Contributor Author

Synced with current main while preserving the reviewed history. CodeRabbit and guardrails are clean; E2E and advisor checks are rerunning.

@deepujain

Copy link
Copy Markdown
Contributor Author

Synced with today's main. The reviewed history remains verified; CodeRabbit and fast gates pass, with advisors and E2E still running.

@deepujain

Copy link
Copy Markdown
Contributor Author

Synced with current main. All commits remain verified, approval and CodeRabbit are intact, and E2E is running. The failed primary advisor lane stopped before analysis and reported no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: packaging Packages, images, registries, installers, or distribution bug-fix PR fixes a bug or regression integration: openclaw OpenClaw integration behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dockerfile should default to USER sandbox for OpenShell compatibility

5 participants