Skip to content

Commit bb8ba78

Browse files
ericksoacvclaude
authored
fix(security): isolate gateway process from sandbox agent (#721)
* fix(install): prevent nvm/login shell from resetting PATH in subshells Two issues caused install_nemoclaw() subshells to lose the caller's PATH, making install-preflight tests fail on macOS while passing in CI: 1. `bash -lc` sourced /etc/profile which runs path_helper on macOS, resetting PATH to system defaults and hiding the caller's binaries. Fix: replace `bash -lc` with `bash -c` — the parent shell already has the correct PATH, so a login shell is unnecessary. 2. `ensure_nvm_loaded()` unconditionally sourced nvm.sh, which also resets PATH. Fix: skip sourcing when node is already on PATH. Also export `info` and `warn` helpers via `declare -f` so pre_extract_openclaw can use them in the subshell. Additionally: - Fix SC2206 shellcheck warning in version_gte() by using `read -ra` instead of unquoted word splitting into arrays. - Add .shellcheckrc to suppress SC2059 (printf format string with color vars) and SC1091 (dynamically sourced files) across the project. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix(ci): drop stray '.' arg from pyright pre-push hook Passing '.' to pyright overrides the include/exclude paths in pyproject.toml, causing it to scan .venv and test files. Without the argument, pyright respects the configured include paths. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * chore: apply shfmt formatting to shell scripts Auto-formatted by shfmt via pre-commit hooks after merging upstream/main. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix(ci): exclude test files from pyright strict type-checking The test_endpoint_validation.py file imports pytest which is only available as a dev dependency. Pyright in strict mode cannot resolve it, breaking the pre-push hook. Exclude test files from pyright's include paths since they have their own type discipline via pytest. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix(ci): drop stray '.' arg from pyright in blueprint Makefile Same issue as the pre-commit hook fix — passing '.' to pyright overrides the include/exclude paths in pyproject.toml, causing it to scan .venv and site-packages (17k+ errors in CI). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix(security): isolate gateway process from sandbox agent The sandboxed agent could bypass config immutability by creating a copy of openclaw.json in a writable directory, modifying auth tokens and CORS origins, then killing the gateway and restarting it with HOME pointing to the tampered config. This was publicly demonstrated and is being actively discussed. Fix: run the gateway as a dedicated 'gateway' user via gosu. The 'sandbox' user (agent) cannot kill processes owned by a different UID. The fake-HOME attack no longer works because the agent cannot restart the gateway. Additional defense-in-depth: - Pin config hash at build time (sha256sum), verify at startup - Entrypoint runs as root, drops to gateway/sandbox as appropriate - gosu for clean privilege separation (no shell, no env leakage) * chore: apply shfmt formatting to brev-setup.sh Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix(security): harden entrypoint against symlink injection, PATH hijacking, and log tampering Additional mitigations beyond gateway process isolation: - Lock PATH to system dirs at entrypoint start - Resolve openclaw binary path once, pass as absolute path to auto-pair - Verify .openclaw symlinks point to expected targets at startup - Protect gateway log (chown gateway, chmod 600) - Change .openclaw dir from 1777 to 755 (prevents symlink replacement) * fix(security): pin apt and pip package versions in Dockerfile Addresses hadolint DL3008, DL3013, DL3042, and DL3059: pin all apt packages to exact versions, pin pyyaml, add --no-cache-dir, and consolidate consecutive RUN instructions. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix: address CodeRabbit review feedback on gateway isolation - Use separate /tmp/auto-pair.log for the auto-pair watcher (runs as sandbox user) instead of appending to /tmp/gateway.log which is owned by gateway:gateway with mode 600 — fixes permission denied on write. - Wait on GATEWAY_PID at end of entrypoint so PID 1 stays alive and Docker does not terminate the container immediately after launch. * test: add E2E test for gateway process isolation (10 checks) Builds the sandbox image and verifies: 1. Gateway and sandbox are different UIDs 2. openclaw.json not writable by sandbox 3. Symlinks in .openclaw cannot be replaced by sandbox 4. Config hash exists and matches 5. Config hash not writable by sandbox 6. gosu installed 7. PATH locked in entrypoint 8. openclaw resolved to absolute path 9. Symlink verification present 10. Sandbox user cannot kill gateway-user processes Added as test-e2e-gateway-isolation parallel CI job in pr.yaml. * fix: remove hadolint ignore and quote pyyaml version pin Remove stale DL3008 suppression (versions are pinned) and add quotes around the pyyaml version specifier for consistency with upstream. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix: prevent infinite recursion when openshell passes nemoclaw-start as command arg * fix: document -h short alias in usage output Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix: suppress hadolint DL3002 — root USER is intentional for gosu privilege separation * chore: consolidate apt-get layers (merge gosu into main install) * fix: address review feedback on gateway isolation PR - Pin gosu=1.14-1+b10 in Dockerfile - Remove dead setfacl ACL lines (acl package not installed) - Fail closed on missing config hash file instead of warn-and-continue - Only strip nemoclaw-start from $1, not all arg positions - Capture Docker build output on failure instead of /dev/null - Replace grep-based tests 7-9 with behavioral assertions - Share single Docker image build across both e2e CI jobs * ci: allow 'merge' type in commitlint config Merge commits from conflict resolution use the 'merge:' prefix, which was not in the allowed type list, causing commit-lint CI to fail. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix: add hadolint ignore for intentional root USER and fix CI image builds - Add hadolint DL3002 ignore on USER root (intentional for config locking) - Build both test and production Docker images in CI: sandbox-test for e2e fixtures, production for gateway isolation tests * fix: resolve remaining CI failures and address symlink review comment - Move hadolint DL3002 ignore to directly before USER root (fixes lint) - Rebase test/Dockerfile.sandbox on the production image instead of rebuilding from scratch — shares the build-sandbox-image artifact while layering test fixtures on top (fixes test-e2e-sandbox) - Verify all symlinks in .openclaw dynamically instead of hardcoding a fixed list, so future OpenClaw symlinks are covered automatically Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * chore: apply shfmt formatting * fix: upgrade gosu from 1.14 (Debian bookworm) to 1.19 (2025-09) Install gosu directly from GitHub release with SHA-256 checksum verification instead of Debian bookworm's 5-year-old apt package. * fix: add hadolint DL4006 ignore for gosu checksum pipe * fix: apply shfmt indent to case pattern in nemoclaw-start Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * chore: re-sign with verified SSH key --------- Co-authored-by: Carlos Villela <[email protected]> Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
1 parent a354c5a commit bb8ba78

6 files changed

Lines changed: 389 additions & 76 deletions

File tree

‎.github/workflows/pr.yaml‎

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,78 @@ jobs:
8484
- name: Check coverage ratchet
8585
run: bash scripts/check-coverage-ratchet.sh
8686

87+
build-sandbox-images:
88+
runs-on: ubuntu-latest
89+
timeout-minutes: 15
90+
steps:
91+
- name: Checkout
92+
uses: actions/checkout@v6
93+
94+
- name: Build production image
95+
run: docker build -t nemoclaw-production .
96+
97+
- name: Build sandbox test image (fixtures layered on production)
98+
run: docker build -f test/Dockerfile.sandbox --build-arg BASE_IMAGE=nemoclaw-production -t nemoclaw-sandbox-test .
99+
100+
- name: Save images to tarballs
101+
run: |
102+
docker save nemoclaw-sandbox-test | gzip > /tmp/sandbox-test-image.tar.gz
103+
docker save nemoclaw-production | gzip > /tmp/isolation-image.tar.gz
104+
105+
- name: Upload sandbox test image
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: sandbox-test-image
109+
path: /tmp/sandbox-test-image.tar.gz
110+
retention-days: 1
111+
112+
- name: Upload isolation image
113+
uses: actions/upload-artifact@v4
114+
with:
115+
name: isolation-image
116+
path: /tmp/isolation-image.tar.gz
117+
retention-days: 1
118+
87119
test-e2e-sandbox:
88120
runs-on: ubuntu-latest
89121
timeout-minutes: 15
122+
needs: build-sandbox-images
90123
steps:
91124
- name: Checkout
92125
uses: actions/checkout@v6
93126

94-
- name: Build sandbox test image
95-
run: docker build -f test/Dockerfile.sandbox -t nemoclaw-sandbox-test .
127+
- name: Download image artifact
128+
uses: actions/download-artifact@v4
129+
with:
130+
name: sandbox-test-image
131+
path: /tmp
132+
133+
- name: Load image
134+
run: gunzip -c /tmp/sandbox-test-image.tar.gz | docker load
96135

97136
- name: Run sandbox E2E tests
98137
run: docker run --rm -v "${{ github.workspace }}/test:/opt/test" nemoclaw-sandbox-test /opt/test/e2e-test.sh
99138

139+
test-e2e-gateway-isolation:
140+
runs-on: ubuntu-latest
141+
timeout-minutes: 15
142+
needs: build-sandbox-images
143+
steps:
144+
- name: Checkout
145+
uses: actions/checkout@v6
146+
147+
- name: Download image artifact
148+
uses: actions/download-artifact@v4
149+
with:
150+
name: isolation-image
151+
path: /tmp
152+
153+
- name: Load image
154+
run: gunzip -c /tmp/isolation-image.tar.gz | docker load
155+
156+
- name: Run gateway isolation E2E tests
157+
run: NEMOCLAW_TEST_IMAGE=nemoclaw-production bash test/e2e-gateway-isolation.sh
158+
100159
validate-profiles:
101160
runs-on: ubuntu-latest
102161
timeout-minutes: 5

‎Dockerfile‎

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2222
iproute2=6.1.0-3 \
2323
&& rm -rf /var/lib/apt/lists/*
2424

25-
# Create sandbox user (matches OpenShell convention)
26-
RUN groupadd -r sandbox && useradd -r -g sandbox -d /sandbox -s /bin/bash sandbox \
25+
# gosu for privilege separation (gateway vs sandbox user).
26+
# Install from GitHub release with checksum verification instead of
27+
# Debian bookworm's ancient 1.14 (2020). Pinned to 1.19 (2025-09).
28+
# hadolint ignore=DL4006
29+
RUN curl -fsSL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.19/gosu-amd64" \
30+
&& echo "52c8749d0142edd234e9d6bd5237dff2d81e71f43537e2f4f66f75dd4b243dd0 /usr/local/bin/gosu" | sha256sum -c - \
31+
&& chmod +x /usr/local/bin/gosu \
32+
&& gosu --version
33+
34+
# Create sandbox user (matches OpenShell convention) and gateway user.
35+
# The gateway runs as 'gateway' so the 'sandbox' user (agent) cannot
36+
# kill it or restart it with a tampered HOME/config.
37+
RUN groupadd -r gateway && useradd -r -g gateway -d /sandbox -s /usr/sbin/nologin gateway \
38+
&& groupadd -r sandbox && useradd -r -g sandbox -d /sandbox -s /bin/bash sandbox \
2739
&& mkdir -p /sandbox/.nemoclaw \
2840
&& chown -R sandbox:sandbox /sandbox
2941

@@ -159,12 +171,26 @@ RUN openclaw doctor --fix > /dev/null 2>&1 || true \
159171
# The Landlock policy (/sandbox/.openclaw in read_only) provides defense-in-depth
160172
# once OpenShell enables enforcement.
161173
# Ref: https://github.com/NVIDIA/NemoClaw/issues/514
174+
# Lock the entire .openclaw directory tree.
175+
# SECURITY: chmod 755 (not 1777) — the sandbox user can READ but not WRITE
176+
# to this directory. This prevents the agent from replacing symlinks
177+
# (e.g., pointing /sandbox/.openclaw/hooks to an attacker-controlled path).
178+
# The writable state lives in .openclaw-data, reached via the symlinks.
179+
# hadolint ignore=DL3002
162180
USER root
163181
RUN chown root:root /sandbox/.openclaw \
164182
&& find /sandbox/.openclaw -mindepth 1 -maxdepth 1 -exec chown -h root:root {} + \
165-
&& chmod 1777 /sandbox/.openclaw \
183+
&& chmod 755 /sandbox/.openclaw \
166184
&& chmod 444 /sandbox/.openclaw/openclaw.json
167-
USER sandbox
168185

169-
ENTRYPOINT ["/bin/bash"]
186+
# Pin config hash at build time so the entrypoint can verify integrity.
187+
# Prevents the agent from creating a copy with a tampered config and
188+
# restarting the gateway pointing at it.
189+
RUN sha256sum /sandbox/.openclaw/openclaw.json > /sandbox/.openclaw/.config-hash \
190+
&& chmod 444 /sandbox/.openclaw/.config-hash \
191+
&& chown root:root /sandbox/.openclaw/.config-hash
192+
193+
# Entrypoint runs as root to start the gateway as the gateway user,
194+
# then drops to sandbox for agent commands. See nemoclaw-start.sh.
195+
ENTRYPOINT ["/usr/local/bin/nemoclaw-start"]
170196
CMD []

‎commitlint.config.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = {
1616
"test",
1717
"ci",
1818
"perf",
19+
"merge",
1920
],
2021
],
2122
},

‎scripts/nemoclaw-start.sh‎

Lines changed: 88 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,52 @@
22
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
# SPDX-License-Identifier: Apache-2.0
44
#
5-
# NemoClaw sandbox entrypoint. Configures OpenClaw and starts the dashboard
6-
# gateway inside the sandbox so the forwarded host port has a live upstream.
5+
# NemoClaw sandbox entrypoint. Runs as root (via ENTRYPOINT) to start the
6+
# gateway as the 'gateway' user, then drops to 'sandbox' for agent commands.
7+
#
8+
# SECURITY: The gateway runs as a separate user so the sandboxed agent cannot
9+
# kill it or restart it with a tampered config (CVE: fake-HOME bypass).
10+
# The config hash is verified at startup to detect tampering.
711
#
812
# Optional env:
913
# NVIDIA_API_KEY API key for NVIDIA-hosted inference
1014
# CHAT_UI_URL Browser origin that will access the forwarded dashboard
1115

1216
set -euo pipefail
1317

18+
# SECURITY: Lock down PATH so the agent cannot inject malicious binaries
19+
# into commands executed by the entrypoint or auto-pair watcher.
20+
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
21+
22+
# Filter out self-invocation: openshell sandbox create passes "nemoclaw-start"
23+
# as the command, but since this script is now the ENTRYPOINT, receiving our
24+
# own name as $1 would cause infinite recursion via the NEMOCLAW_CMD exec path.
25+
# Only strip from $1 — later args with this name are legitimate user arguments.
26+
case "${1:-}" in
27+
nemoclaw-start | /usr/local/bin/nemoclaw-start) shift ;;
28+
esac
1429
NEMOCLAW_CMD=("$@")
1530
CHAT_UI_URL="${CHAT_UI_URL:-http://127.0.0.1:18789}"
1631
PUBLIC_PORT=18789
32+
OPENCLAW="$(command -v openclaw)" # Resolve once, use absolute path everywhere
33+
34+
# ── Config integrity check ──────────────────────────────────────
35+
# The config hash was pinned at build time. If it doesn't match,
36+
# someone (or something) has tampered with the config.
37+
38+
verify_config_integrity() {
39+
local hash_file="/sandbox/.openclaw/.config-hash"
40+
if [ ! -f "$hash_file" ]; then
41+
echo "[SECURITY] Config hash file missing — refusing to start without integrity verification"
42+
return 1
43+
fi
44+
if ! (cd /sandbox/.openclaw && sha256sum -c "$hash_file" --status 2>/dev/null); then
45+
echo "[SECURITY] openclaw.json integrity check FAILED — config may have been tampered with"
46+
echo "[SECURITY] Expected hash: $(cat "$hash_file")"
47+
echo "[SECURITY] Actual hash: $(sha256sum /sandbox/.openclaw/openclaw.json)"
48+
return 1
49+
fi
50+
}
1751

1852
write_auth_profile() {
1953
if [ -z "${NVIDIA_API_KEY:-}" ]; then
@@ -44,7 +78,7 @@ print_dashboard_urls() {
4478
python3 - <<'PYTOKEN'
4579
import json
4680
import os
47-
path = os.path.expanduser('~/.openclaw/openclaw.json')
81+
path = '/sandbox/.openclaw/openclaw.json'
4882
try:
4983
cfg = json.load(open(path))
5084
except Exception:
@@ -67,11 +101,15 @@ PYTOKEN
67101
}
68102

69103
start_auto_pair() {
70-
nohup python3 - <<'PYAUTOPAIR' >>/tmp/gateway.log 2>&1 &
104+
# Run auto-pair as sandbox user (it talks to the gateway via CLI)
105+
# SECURITY: Pass resolved openclaw path to prevent PATH hijacking
106+
OPENCLAW_BIN="$OPENCLAW" nohup gosu sandbox python3 - <<'PYAUTOPAIR' >>/tmp/auto-pair.log 2>&1 &
71107
import json
108+
import os
72109
import subprocess
73110
import time
74111
112+
OPENCLAW = os.environ.get('OPENCLAW_BIN', 'openclaw')
75113
DEADLINE = time.time() + 600
76114
QUIET_POLLS = 0
77115
APPROVED = 0
@@ -81,7 +119,7 @@ def run(*args):
81119
return proc.returncode, proc.stdout.strip(), proc.stderr.strip()
82120
83121
while time.time() < DEADLINE:
84-
rc, out, err = run('openclaw', 'devices', 'list', '--json')
122+
rc, out, err = run(OPENCLAW, 'devices', 'list', '--json')
85123
if rc != 0 or not out:
86124
time.sleep(1)
87125
continue
@@ -101,7 +139,7 @@ while time.time() < DEADLINE:
101139
request_id = (device or {}).get('requestId')
102140
if not request_id:
103141
continue
104-
arc, aout, aerr = run('openclaw', 'devices', 'approve', request_id, '--json')
142+
arc, aout, aerr = run(OPENCLAW, 'devices', 'approve', request_id, '--json')
105143
if arc == 0:
106144
APPROVED += 1
107145
print(f'[auto-pair] approved request={request_id}')
@@ -127,19 +165,56 @@ PYAUTOPAIR
127165
echo "[gateway] auto-pair watcher launched (pid $!)"
128166
}
129167

168+
# ── Main ─────────────────────────────────────────────────────────
169+
130170
echo 'Setting up NemoClaw...'
131171
[ -f .env ] && chmod 600 .env
132172

133-
# openclaw doctor --fix and openclaw plugins install already ran at build time
134-
# (Dockerfile Step 28). At runtime they fail with EPERM against the locked
135-
# /sandbox/.openclaw directory and accomplish nothing.
136-
write_auth_profile
173+
# Verify config integrity before starting anything
174+
verify_config_integrity
175+
176+
# Write auth profile as sandbox user (needs writable .openclaw-data)
177+
gosu sandbox bash -c "$(declare -f write_auth_profile); write_auth_profile"
137178

179+
# If a command was passed (e.g., "openclaw agent ..."), run it as sandbox user
138180
if [ ${#NEMOCLAW_CMD[@]} -gt 0 ]; then
139-
exec "${NEMOCLAW_CMD[@]}"
181+
exec gosu sandbox "${NEMOCLAW_CMD[@]}"
140182
fi
141183

142-
nohup openclaw gateway run >/tmp/gateway.log 2>&1 &
143-
echo "[gateway] openclaw gateway launched (pid $!)"
184+
# SECURITY: Protect gateway log from sandbox user tampering
185+
touch /tmp/gateway.log
186+
chown gateway:gateway /tmp/gateway.log
187+
chmod 600 /tmp/gateway.log
188+
189+
# Separate log for auto-pair so sandbox user can write to it
190+
touch /tmp/auto-pair.log
191+
chown sandbox:sandbox /tmp/auto-pair.log
192+
chmod 600 /tmp/auto-pair.log
193+
194+
# Verify ALL symlinks in .openclaw point to expected .openclaw-data targets.
195+
# Dynamic scan so future OpenClaw symlinks are covered automatically.
196+
for entry in /sandbox/.openclaw/*; do
197+
[ -L "$entry" ] || continue
198+
name="$(basename "$entry")"
199+
target="$(readlink -f "$entry" 2>/dev/null || true)"
200+
expected="/sandbox/.openclaw-data/$name"
201+
if [ "$target" != "$expected" ]; then
202+
echo "[SECURITY] Symlink $entry points to unexpected target: $target (expected $expected)"
203+
exit 1
204+
fi
205+
done
206+
207+
# Start the gateway as the 'gateway' user.
208+
# SECURITY: The sandbox user cannot kill this process because it runs
209+
# under a different UID. The fake-HOME attack no longer works because
210+
# the agent cannot restart the gateway with a tampered config.
211+
nohup gosu gateway "$OPENCLAW" gateway run >/tmp/gateway.log 2>&1 &
212+
GATEWAY_PID=$!
213+
echo "[gateway] openclaw gateway launched as 'gateway' user (pid $GATEWAY_PID)"
214+
144215
start_auto_pair
145216
print_dashboard_urls
217+
218+
# Keep container running by waiting on the gateway process.
219+
# This script is PID 1 (ENTRYPOINT); if it exits, Docker kills all children.
220+
wait "$GATEWAY_PID"

‎test/Dockerfile.sandbox‎

Lines changed: 16 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,27 @@
1-
# hadolint global ignore=DL3008,DL3013,DL3042,DL3059,DL4006,SC2038
2-
# Lightweight test sandbox for NemoClaw E2E testing
3-
# Simulates the OpenClaw-in-OpenShell environment without requiring
4-
# the full NVIDIA base image or openshell CLI
1+
# hadolint global ignore=DL3002,DL3059
2+
# Test sandbox for NemoClaw E2E testing.
3+
# Layers test fixtures on top of the production sandbox image so both
4+
# e2e jobs share a single Docker build for the base layers.
55

6-
FROM node:22-slim
6+
ARG BASE_IMAGE=nemoclaw-sandbox-test
7+
# hadolint ignore=DL3006
8+
FROM ${BASE_IMAGE}
79

8-
ENV DEBIAN_FRONTEND=noninteractive
9-
10-
RUN apt-get update && apt-get install -y --no-install-recommends \
11-
python3 python3-pip python3-venv \
12-
curl git ca-certificates \
13-
iproute2 \
14-
&& rm -rf /var/lib/apt/lists/*
15-
16-
# Create sandbox user (matches OpenShell convention)
17-
RUN groupadd -r sandbox && useradd -r -g sandbox -d /sandbox -s /bin/bash sandbox \
18-
&& mkdir -p /sandbox/.openclaw /sandbox/.nemoclaw \
19-
&& chown -R sandbox:sandbox /sandbox
20-
21-
# Install OpenClaw CLI
22-
RUN npm install -g [email protected]
23-
24-
# Install PyYAML for blueprint runner
25-
RUN pip3 install --break-system-packages pyyaml
26-
27-
# Copy our plugin and blueprint into the sandbox
28-
COPY nemoclaw/ /opt/nemoclaw/
29-
COPY nemoclaw-blueprint/ /opt/nemoclaw-blueprint/
30-
31-
# Build the TS plugin inside the container
32-
WORKDIR /opt/nemoclaw
33-
RUN npm install && rm -rf dist && npx tsc
34-
35-
# Patch OpenClaw's nvidia provider to replace Meta Llama 3.3 70B with
36-
# Nemotron 3 Super 120B. OpenClaw's embedded agent has a hardcoded model
37-
# catalog that doesn't include Nemotron 3 Super yet. This replaces the
38-
# one Meta/Llama model with NVIDIA's latest until OpenClaw ships an update.
39-
RUN find /usr/local/lib/node_modules/openclaw/dist -name "*.js" \
40-
-exec grep -l "meta/llama-3.3-70b-instruct" {} \; \
41-
| xargs -I{} sed -i \
42-
-e 's|meta/llama-3.3-70b-instruct|nvidia/nemotron-3-super-120b-a12b|g' \
43-
-e 's|Meta Llama 3.3 70B Instruct|Nemotron 3 Super 120B|g' \
44-
{}
45-
# Nemotron 3 Super supports reasoning; flip the flag and bump maxTokens
46-
RUN find /usr/local/lib/node_modules/openclaw/dist -name "*.js" \
47-
-exec grep -l "nemotron-3-super-120b-a12b" {} \; \
48-
| xargs -I{} python3 -c "import re,sys;\
49-
s=open('{}').read();\
50-
s=re.sub(r'(id:\\s*\"nvidia/nemotron-3-super-120b-a12b.*?reasoning:\\s*)false',r'\\1true',s,flags=re.DOTALL);\
51-
s=re.sub(r'(id:\\s*\"nvidia/nemotron-3-super-120b-a12b.*?maxTokens:\\s*)4096',r'\\g<1>8192',s,flags=re.DOTALL);\
52-
open('{}','w').write(s)"
53-
54-
# Set up blueprint for local resolution
55-
RUN mkdir -p /sandbox/.nemoclaw/blueprints/0.1.0 \
56-
&& cp -r /opt/nemoclaw-blueprint/* /sandbox/.nemoclaw/blueprints/0.1.0/
10+
# The production image locks .openclaw (root:root, 755, openclaw.json 444).
11+
# Tests need writable fixtures and a sandbox-owned config for rollback tests,
12+
# so relax permissions here.
13+
USER root
14+
RUN chown -R sandbox:sandbox /sandbox/.openclaw /sandbox/.openclaw-data \
15+
&& chmod 700 /sandbox/.openclaw \
16+
&& chmod 600 /sandbox/.openclaw/openclaw.json
5717

58-
WORKDIR /sandbox
5918
USER sandbox
6019

6120
# Simulate a host OpenClaw installation for migration testing.
6221
# Keep the legacy ~/.openclaw fixture for the blueprint snapshot tests.
22+
# Directories like hooks/ are symlinks to .openclaw-data/; mkdir -p follows
23+
# them and creates subdirectories in the writable data dir.
6324
RUN mkdir -p /sandbox/.openclaw/workspace /sandbox/.openclaw/extensions /sandbox/.openclaw/skills /sandbox/.openclaw/hooks/demo-hook \
64-
&& chmod 700 /sandbox/.openclaw \
6525
&& printf '%s\n' \
6626
'{' \
6727
' "wizard": {' \

0 commit comments

Comments
 (0)