Skip to content

Commit 33a770e

Browse files
prekshivyasclaude
andauthored
fix(install): bump OpenShell max version to 0.0.29 for Landlock enforcement (#2141)
## Summary Bumps the OpenShell version range from `0.0.26` → `0.0.29` so fresh NemoClaw installs pull a build that actually enforces the Landlock filesystem policy on the sandbox process. ## Root cause recap OpenShell 0.0.26's Landlock setup ran *after* `drop_privileges()`, so path-fd opens failed as the unprivileged sandbox user and the `best_effort` handler silently returned success. The sandbox then ran unconfined and `/sandbox` was writable on every platform, even though NemoClaw delivered the correct policy (`nemoclaw <name> status --json` showed `filesystem_policy.read_only: [/sandbox, /sandbox/.openclaw]`, `landlock.compatibility: best_effort`). Upstream investigation: [NVIDIA/OpenShell#803](NVIDIA/OpenShell#803). Upstream fix: [NVIDIA/OpenShell#810](NVIDIA/OpenShell#810) — two-phase Landlock that opens path fds before dropping privs. First release containing the fix: `openshell 0.0.29`. ### Known limitation: proxy-mode enrichment overrides include_workdir: false Testing on 0.0.29 confirmed Landlock **is enforced** — writes to `/dev/shm` and `/var/tmp` (both DAC 1777) are correctly blocked. However, `/sandbox` remains writable despite being in `read_only` with `include_workdir: false`. Root cause: `enrich_proto_baseline_paths()` in the `openshell-sandbox` binary hardcodes `/sandbox` in `PROXY_BASELINE_READ_WRITE`. This runs after the gateway delivers NemoClaw's strict policy but before `prepare()` builds the Landlock ruleset. Since Landlock grants the union of matching rules, `/sandbox` in both `read_only` and `read_write` = writable. Filed upstream as [NVIDIA/OpenShell#905](NVIDIA/OpenShell#905). No NemoClaw-side workaround exists — the enrichment happens inside the OpenShell binary. ## Changes - `scripts/install-openshell.sh`: `MIN_VERSION` and `MAX_VERSION` (and `PIN_VERSION` which follows `MAX`) pinned to `0.0.29`. Added a comment citing OpenShell#810. - `nemoclaw-blueprint/blueprint.yaml`: `max_openshell_version: "0.0.29"`. - `test/onboard.test.ts`: updated fixture + assertion in `getBlueprintMaxOpenshellVersion` test. ## Type of Change - [x] Code change for a new feature, bug fix, or refactor. ## Testing - [x] `npx vitest run test/onboard.test.ts` — 129 passed - [x] pre-commit hooks (prek) clean: shellcheck, commitlint, gitleaks, TS/JS lint, CLI test suite, YAML validator all pass on push ### Manual QA results (live sandbox, OpenShell 0.0.29) | Test | Expected | Actual | Verdict | |------|----------|--------|---------| | `touch /dev/shm/test` | `Permission denied` | `Permission denied` | ✅ Landlock enforced | | `touch /var/tmp/test` | `Permission denied` | `Permission denied` | ✅ Landlock enforced | | `touch /sandbox/testfile` | `Permission denied` | Write succeeded | ⚠️ Blocked by [OpenShell#905](NVIDIA/OpenShell#905) | | `touch /sandbox/.openclaw/test` | `Permission denied` | Write succeeded | ⚠️ Blocked by [OpenShell#905](NVIDIA/OpenShell#905) | | Gateway policy delivery | NemoClaw policy via gRPC | Confirmed (no disk fallback) | ✅ | | Enrichment log | — | `CONFIG:ENRICHED` ro:9 rw:5 (was rw:4) | ⚠️ One path added | ## Notes - `MIN_VERSION` is now `0.0.29` (raised from `0.0.24` to match `MAX_VERSION`). Operators on 0.0.24–0.0.28 will be flagged and advised to upgrade — those builds have the Landlock silent-pass bug this PR is closing. The blueprint-fallback path in `src/lib/onboard.ts` also defaults to `0.0.29` so a missing or unreadable blueprint does not silently re-allow the vulnerable versions. - No doc updates in this PR — no user-facing CLI behavior changes, just the pinned version range. - **This PR partially closes #1739**: Landlock enforcement is confirmed working for non-workdir paths. Full `/sandbox` read-only protection requires an upstream fix for [OpenShell#905](NVIDIA/OpenShell#905). Relates to #1739 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Pinned OpenShell compatibility to v0.0.29 across configuration, installer, preflight gating, and CI defaults. * Installer now more robustly detects installed OpenShell, persists the pinned version beside the installed binary, checks file modification times before trusting sidecar data, and falls back sensibly when version output is unparseable. * **Tests** * Added end-to-end tests validating version detection, sidecar handling, install/upgrade decisions, and various reported-version scenarios. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Prekshi Vyas <[email protected]> Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
1 parent d72876f commit 33a770e

6 files changed

Lines changed: 302 additions & 20 deletions

File tree

‎nemoclaw-blueprint/blueprint.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
version: "0.1.0"
5-
min_openshell_version: "0.0.24"
6-
max_openshell_version: "0.0.26"
5+
min_openshell_version: "0.0.29"
6+
max_openshell_version: "0.0.29"
77
min_openclaw_version: "2026.4.2"
88
# Mirrors the components.sandbox.image manifest digest below. Lets a
99
# downstream consumer (or release tooling) verify the blueprint declares

‎scripts/brev-launchable-ci-cpu.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# curl -fsSL https://raw.githubusercontent.com/NVIDIA/NemoClaw/<ref>/scripts/brev-launchable-ci-cpu.sh | bash
2929
#
3030
# Environment overrides:
31-
# OPENSHELL_VERSION — OpenShell CLI release tag (default: v0.0.20)
31+
# OPENSHELL_VERSION — OpenShell CLI release tag (default: v0.0.29)
3232
# NEMOCLAW_REF — NemoClaw git ref to clone (default: main)
3333
# NEMOCLAW_CLONE_DIR — Where to clone NemoClaw (default: ~/NemoClaw)
3434
# SKIP_DOCKER_PULL — Set to 1 to skip Docker image pre-pulls
@@ -40,7 +40,7 @@
4040
set -euo pipefail
4141

4242
# ── Configuration ────────────────────────────────────────────────────
43-
OPENSHELL_VERSION="${OPENSHELL_VERSION:-v0.0.24}"
43+
OPENSHELL_VERSION="${OPENSHELL_VERSION:-v0.0.29}"
4444
NEMOCLAW_REF="${NEMOCLAW_REF:-main}"
4545
TARGET_USER="${SUDO_USER:-$(id -un)}"
4646
TARGET_HOME="$(getent passwd "$TARGET_USER" | cut -d: -f6)"

‎scripts/install-openshell.sh‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ esac
3333

3434
info "Detected $OS_LABEL ($ARCH_LABEL)"
3535

36-
# Minimum version required for sandbox persistence across gateway restarts
37-
# (deterministic k3s node name + workspace PVC: NVIDIA/OpenShell#739, #488)
38-
MIN_VERSION="0.0.24"
36+
# Minimum version required for Landlock filesystem policy enforcement
37+
# (NVIDIA/OpenShell#810 fixes the drop_privileges/Landlock ordering bug
38+
# that caused /sandbox to remain writable on 0.0.26).
39+
MIN_VERSION="0.0.29"
3940
# Maximum version validated for this NemoClaw release. Newer OpenShell builds
4041
# may change sandbox semantics; upgrade NemoClaw before upgrading past this.
41-
MAX_VERSION="0.0.26"
42+
MAX_VERSION="0.0.29"
4243
# Pin fresh installs to this version instead of pulling "latest".
4344
PIN_VERSION="$MAX_VERSION"
4445

@@ -57,7 +58,14 @@ version_gte() {
5758
}
5859

5960
if command -v openshell >/dev/null 2>&1; then
60-
INSTALLED_VERSION="$(openshell --version 2>&1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || echo '0.0.0')"
61+
INSTALLED_VERSION="$(openshell --version 2>&1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true)"
62+
if [ -z "$INSTALLED_VERSION" ]; then
63+
# Fallback: read the sidecar written by a previous install for builds that
64+
# self-report an unparseable version string (e.g. openshell 0.0.29 → "m-dev").
65+
_SIDECAR="$(dirname "$(command -v openshell)")/.openshell-installed-version"
66+
INSTALLED_VERSION="$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+' "$_SIDECAR" 2>/dev/null | head -1 || true)"
67+
fi
68+
[ -n "$INSTALLED_VERSION" ] || INSTALLED_VERSION="0.0.0"
6169
if version_gte "$INSTALLED_VERSION" "$MIN_VERSION"; then
6270
if ! version_gte "$MAX_VERSION" "$INSTALLED_VERSION"; then
6371
fail "openshell $INSTALLED_VERSION is above the maximum ($MAX_VERSION) supported by this NemoClaw release. Upgrade NemoClaw first."
@@ -119,17 +127,26 @@ tar xzf "$tmpdir/$ASSET" -C "$tmpdir"
119127

120128
target_dir="/usr/local/bin"
121129

130+
# Record the pinned version so that binaries with unparseable --version output
131+
# (e.g. openshell 0.0.29 self-reports "m-dev") can still pass the version gate
132+
# on subsequent runs without triggering a redundant re-download. The sidecar
133+
# is written inside each install branch so that the sudo path writes it with
134+
# elevated privileges; under `set -e` any write failure aborts rather than
135+
# silently missing the sidecar.
122136
if [ -w "$target_dir" ]; then
123137
install -m 755 "$tmpdir/openshell" "$target_dir/openshell"
138+
printf '%s\n' "$PIN_VERSION" >"$target_dir/.openshell-installed-version"
124139
elif [ "${NEMOCLAW_NON_INTERACTIVE:-}" = "1" ] || [ ! -t 0 ]; then
125140
target_dir="${XDG_BIN_HOME:-$HOME/.local/bin}"
126141
mkdir -p "$target_dir"
127142
install -m 755 "$tmpdir/openshell" "$target_dir/openshell"
143+
printf '%s\n' "$PIN_VERSION" >"$target_dir/.openshell-installed-version"
128144
warn "Installed openshell to $target_dir/openshell (user-local path)"
129145
warn "For future shells, run: export PATH=\"$target_dir:\$PATH\""
130146
warn "Add that export to your shell profile, or open a new shell before using openshell directly."
131147
else
132148
sudo install -m 755 "$tmpdir/openshell" "$target_dir/openshell"
149+
printf '%s\n' "$PIN_VERSION" | sudo tee "$target_dir/.openshell-installed-version" >/dev/null
133150
fi
134151

135152
info "$("$target_dir/openshell" --version 2>&1 || echo openshell) installed"

‎src/lib/onboard.ts‎

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,31 @@ function getInstalledOpenshellVersion(versionOutput = null) {
489489
versionOutput ?? runCapture([openshellBin, "-V"], { ignoreError: true }),
490490
).trim();
491491
const match = output.match(/openshell\s+([0-9]+\.[0-9]+\.[0-9]+)/i);
492-
if (!match) return null;
493-
return match[1];
492+
if (match) return match[1];
493+
// Fallback: read the sidecar version file written by install-openshell.sh for
494+
// binaries that self-report an unparseable string (e.g. openshell 0.0.29 → "m-dev").
495+
// Also applies when versionOutput is provided but unparseable (e.g. passed from
496+
// runCaptureOpenshell at the blueprint version gate).
497+
if (openshellBin) {
498+
try {
499+
const sidecar = path.join(path.dirname(openshellBin), ".openshell-installed-version");
500+
// Invalidate the sidecar if the binary has been replaced since the sidecar
501+
// was written (manual `cp openshell /usr/local/bin/openshell` without
502+
// re-running install-openshell.sh). Stale sidecar + unsupported binary would
503+
// otherwise bypass the min/max version gate silently.
504+
const binaryMtime = fs.statSync(openshellBin).mtimeMs;
505+
const sidecarMtime = fs.statSync(sidecar).mtimeMs;
506+
if (binaryMtime > sidecarMtime) return null;
507+
const sidecarMatch = fs
508+
.readFileSync(sidecar, "utf-8")
509+
.trim()
510+
.match(/^([0-9]+\.[0-9]+\.[0-9]+)$/);
511+
if (sidecarMatch) return sidecarMatch[1];
512+
} catch {
513+
// sidecar absent or unreadable — fall through
514+
}
515+
}
516+
return null;
494517
}
495518

496519
/**
@@ -2663,12 +2686,11 @@ async function preflight() {
26632686
process.exit(1);
26642687
}
26652688
} else {
2666-
const parts = currentVersion.split(".").map(Number);
2667-
const minParts = [0, 0, 24]; // must match MIN_VERSION in scripts/install-openshell.sh
2668-
const needsUpgrade =
2669-
parts[0] < minParts[0] ||
2670-
(parts[0] === minParts[0] && parts[1] < minParts[1]) ||
2671-
(parts[0] === minParts[0] && parts[1] === minParts[1] && parts[2] < minParts[2]);
2689+
// Source of truth: min_openshell_version in nemoclaw-blueprint/blueprint.yaml.
2690+
// Fall back to the Landlock-enforcement floor (also MIN_VERSION in
2691+
// scripts/install-openshell.sh) if the blueprint cannot be read.
2692+
const minOpenshellVersion = getBlueprintMinOpenshellVersion() ?? "0.0.29";
2693+
const needsUpgrade = !versionGte(currentVersion, minOpenshellVersion);
26722694
if (needsUpgrade) {
26732695
console.log(
26742696
` openshell ${currentVersion} is below minimum required version. Upgrading...`,
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
// @ts-nocheck
2+
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
import { describe, it, expect } from "vitest";
6+
import fs from "node:fs";
7+
import os from "node:os";
8+
import path from "node:path";
9+
import { spawnSync } from "node:child_process";
10+
11+
const SCRIPT = path.join(import.meta.dirname, "..", "scripts", "install-openshell.sh");
12+
13+
function writeExecutable(target: string, contents: string) {
14+
fs.writeFileSync(target, contents, { mode: 0o755 });
15+
}
16+
17+
/**
18+
* Run install-openshell.sh with a fake `openshell` binary that reports the
19+
* given version. The download/install code path is never reached because we
20+
* either exit early (version ok / too high) or hit the upgrade warn and then
21+
* the script tries to download — so we stub curl and gh to fail fast.
22+
*/
23+
function runWithInstalledVersion(version: string) {
24+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-openshell-ver-"));
25+
try {
26+
const fakeBin = path.join(tmp, "bin");
27+
fs.mkdirSync(fakeBin);
28+
29+
// Fake openshell that reports the given version
30+
writeExecutable(
31+
path.join(fakeBin, "openshell"),
32+
`#!/usr/bin/env bash
33+
if [ "\${1:-}" = "--version" ]; then echo "openshell ${version}"; exit 0; fi
34+
exit 99`,
35+
);
36+
37+
// Stub curl to fail so the install path exits without doing real network I/O
38+
writeExecutable(
39+
path.join(fakeBin, "curl"),
40+
`#!/usr/bin/env bash
41+
echo "curl stub: not available in test" >&2
42+
exit 1`,
43+
);
44+
45+
// Stub gh CLI similarly
46+
writeExecutable(
47+
path.join(fakeBin, "gh"),
48+
`#!/usr/bin/env bash
49+
exit 1`,
50+
);
51+
52+
return spawnSync("bash", [SCRIPT], {
53+
env: { ...process.env, PATH: `${fakeBin}:/usr/bin:/bin` },
54+
encoding: "utf8",
55+
});
56+
} finally {
57+
fs.rmSync(tmp, { recursive: true, force: true });
58+
}
59+
}
60+
61+
describe("install-openshell.sh version check", () => {
62+
it("exits cleanly when openshell 0.0.29 is already installed", () => {
63+
const result = runWithInstalledVersion("0.0.29");
64+
expect(result.status).toBe(0);
65+
expect(result.stdout).toMatch(/already installed.*0\.0\.29/);
66+
});
67+
68+
it("triggers upgrade when openshell 0.0.28 is installed (below MIN_VERSION)", () => {
69+
const result = runWithInstalledVersion("0.0.28");
70+
// Script should warn about upgrade then fail at the download step (curl stub fails)
71+
expect(result.status).not.toBe(0);
72+
expect(result.stdout).toMatch(/below minimum.*upgrading/);
73+
});
74+
75+
it("triggers upgrade when openshell 0.0.26 is installed (Landlock-vulnerable version)", () => {
76+
const result = runWithInstalledVersion("0.0.26");
77+
expect(result.status).not.toBe(0);
78+
expect(result.stdout).toMatch(/below minimum.*upgrading/);
79+
});
80+
81+
it("triggers upgrade when openshell 0.0.24 is installed (old minimum)", () => {
82+
const result = runWithInstalledVersion("0.0.24");
83+
expect(result.status).not.toBe(0);
84+
expect(result.stdout).toMatch(/below minimum.*upgrading/);
85+
});
86+
87+
it("fails with a clear error when openshell is above MAX_VERSION", () => {
88+
const result = runWithInstalledVersion("0.0.30");
89+
expect(result.status).toBe(1);
90+
expect(result.stdout).toMatch(/above the maximum/);
91+
});
92+
93+
it("fails with a clear error when openshell is at a much newer version", () => {
94+
const result = runWithInstalledVersion("0.1.0");
95+
expect(result.status).toBe(1);
96+
expect(result.stdout).toMatch(/above the maximum/);
97+
});
98+
99+
it("exits cleanly when openshell reports m-dev but sidecar records 0.0.29", () => {
100+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-openshell-mdev-"));
101+
try {
102+
const fakeBin = path.join(tmp, "bin");
103+
fs.mkdirSync(fakeBin);
104+
105+
// Fake openshell that reports "m-dev" (as openshell 0.0.29 does in practice)
106+
writeExecutable(
107+
path.join(fakeBin, "openshell"),
108+
`#!/usr/bin/env bash
109+
if [ "\${1:-}" = "--version" ]; then echo "openshell m-dev"; exit 0; fi
110+
exit 99`,
111+
);
112+
113+
// Sidecar file written by a previous install
114+
fs.writeFileSync(path.join(fakeBin, ".openshell-installed-version"), "0.0.29\n");
115+
116+
writeExecutable(path.join(fakeBin, "curl"), `#!/usr/bin/env bash\nexit 1`);
117+
writeExecutable(path.join(fakeBin, "gh"), `#!/usr/bin/env bash\nexit 1`);
118+
119+
const result = spawnSync("bash", [SCRIPT], {
120+
env: { ...process.env, PATH: `${fakeBin}:/usr/bin:/bin` },
121+
encoding: "utf8",
122+
});
123+
expect(result.status).toBe(0);
124+
expect(result.stdout).toMatch(/already installed.*0\.0\.29/);
125+
} finally {
126+
fs.rmSync(tmp, { recursive: true, force: true });
127+
}
128+
});
129+
130+
it("triggers upgrade when openshell reports m-dev and sidecar records 0.0.26", () => {
131+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-openshell-mdev-old-"));
132+
try {
133+
const fakeBin = path.join(tmp, "bin");
134+
fs.mkdirSync(fakeBin);
135+
136+
writeExecutable(
137+
path.join(fakeBin, "openshell"),
138+
`#!/usr/bin/env bash
139+
if [ "\${1:-}" = "--version" ]; then echo "openshell m-dev"; exit 0; fi
140+
exit 99`,
141+
);
142+
143+
// Sidecar from an older install that pre-dates the Landlock fix
144+
fs.writeFileSync(path.join(fakeBin, ".openshell-installed-version"), "0.0.26\n");
145+
146+
writeExecutable(
147+
path.join(fakeBin, "curl"),
148+
`#!/usr/bin/env bash\necho "curl stub" >&2\nexit 1`,
149+
);
150+
writeExecutable(path.join(fakeBin, "gh"), `#!/usr/bin/env bash\nexit 1`);
151+
152+
const result = spawnSync("bash", [SCRIPT], {
153+
env: { ...process.env, PATH: `${fakeBin}:/usr/bin:/bin` },
154+
encoding: "utf8",
155+
});
156+
expect(result.status).not.toBe(0);
157+
expect(result.stdout).toMatch(/below minimum.*upgrading/);
158+
} finally {
159+
fs.rmSync(tmp, { recursive: true, force: true });
160+
}
161+
});
162+
163+
it("proceeds to install when openshell is not present", () => {
164+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-openshell-noop-"));
165+
try {
166+
const fakeBin = path.join(tmp, "bin");
167+
fs.mkdirSync(fakeBin);
168+
169+
// No openshell binary — just stub curl/gh to fail fast
170+
writeExecutable(
171+
path.join(fakeBin, "curl"),
172+
`#!/usr/bin/env bash
173+
echo "curl stub: not available in test" >&2
174+
exit 1`,
175+
);
176+
writeExecutable(
177+
path.join(fakeBin, "gh"),
178+
`#!/usr/bin/env bash
179+
exit 1`,
180+
);
181+
182+
const result = spawnSync("bash", [SCRIPT], {
183+
env: { ...process.env, PATH: `${fakeBin}:/usr/bin:/bin` },
184+
encoding: "utf8",
185+
});
186+
187+
// Should attempt install (not exit 0 early) and fail at the download step
188+
expect(result.stdout).toMatch(/Installing openshell CLI/);
189+
expect(result.status).not.toBe(0);
190+
} finally {
191+
fs.rmSync(tmp, { recursive: true, force: true });
192+
}
193+
});
194+
});

0 commit comments

Comments
 (0)