Skip to content

Commit 855924f

Browse files
fix(policy): restrict baseline npm_registry to openclaw binary only (#1700)
## Problem With 'none' policy selected during onboard, `npm install` still succeeded because the baseline policy (`openclaw-sandbox.yaml`) included `/usr/local/bin/npm` and `/usr/local/bin/node` in the `npm_registry` binaries list. This bypassed the user's intent of no external network access. The baseline `npm_registry` entry exists solely for `openclaw plugins install` — not for agent-driven npm usage. Any sandbox with 'none' preset should block npm from the agent. ## Fix Removed `/usr/local/bin/npm` and `/usr/local/bin/node` from the baseline `npm_registry` binaries list. Only `/usr/local/bin/openclaw` retains access to `registry.npmjs.org` by default. Users who need npm/node network access in the sandbox should add the `npm` preset during onboard or afterwards via `nemoclaw policy`. ## Testing - `nemoclaw onboard` with no policy presets → `npm install` should now be blocked (403 Forbidden from proxy) - `openclaw plugins install <plugin>` should still work (uses the openclaw binary) - `nemoclaw onboard` with npm preset → `npm install` still works as expected Fixes #1458 Signed-off-by: Benedikt Schackenberg <6381261+BenediktSchackenberg@users.noreply.github.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added network policy entries to enable controlled Telegram and Discord messaging access. * **Chores** * Restricted registry access so only the plugin installer retains direct registry rights; npm/node are no longer allowed by default and require a separate preset. * **Documentation** * Updated network policy docs to reflect stricter allowed binaries and GET-only registry requests. * **Tests** * Added a regression test to enforce the registry access whitelist. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Benedikt Schackenberg <6381261+BenediktSchackenberg@users.noreply.github.com> Co-authored-by: Carlos Villela <cvillela@nvidia.com>
1 parent 27dda53 commit 855924f

4 files changed

Lines changed: 64 additions & 5 deletions

File tree

.agents/skills/nemoclaw-user-reference/references/network-policies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ The following endpoint groups are allowed by default:
6060

6161
* - `npm_registry`
6262
- `registry.npmjs.org:443`
63-
- `/usr/local/bin/openclaw`, `/usr/local/bin/npm`, `/usr/local/bin/node`
63+
- `/usr/local/bin/openclaw` only (openclaw plugins install)
6464
- GET only
6565

6666
:::

docs/reference/network-policies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ The following endpoint groups are allowed by default:
8080

8181
* - `npm_registry`
8282
- `registry.npmjs.org:443`
83-
- `/usr/local/bin/openclaw`, `/usr/local/bin/npm`, `/usr/local/bin/node`
83+
- `/usr/local/bin/openclaw` only (openclaw plugins install)
8484
- GET only
8585

8686
:::

nemoclaw-blueprint/policies/openclaw-sandbox.yaml

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,10 @@ network_policies:
196196
binaries:
197197
- { path: /usr/local/bin/openclaw }
198198

199-
# npm registry — needed for `openclaw plugins install` and `npm install`.
200-
# Read-only: agents only fetch packages, never publish.
199+
# npm registry — needed for `openclaw plugins install` only.
200+
# Restricted to the openclaw binary so agents cannot use npm directly.
201+
# Users who need npm/node access should add the npm policy preset during onboard.
202+
# Ref: https://github.com/NVIDIA/NemoClaw/issues/1458
201203
npm_registry:
202204
name: npm_registry
203205
endpoints:
@@ -210,5 +212,49 @@ network_policies:
210212
- allow: { method: GET, path: "/**" }
211213
binaries:
212214
- { path: /usr/local/bin/openclaw }
213-
- { path: /usr/local/bin/npm }
215+
216+
# ── Messaging — pre-allowed for OpenClaw agent notifications ────
217+
# Restricted to node processes to prevent arbitrary data exfiltration
218+
# via curl, wget, python, etc. (See: #272)
219+
telegram:
220+
name: telegram
221+
endpoints:
222+
- host: api.telegram.org
223+
port: 443
224+
protocol: rest
225+
enforcement: enforce
226+
tls: terminate
227+
rules:
228+
- allow: { method: GET, path: "/bot*/**" }
229+
- allow: { method: POST, path: "/bot*/**" }
230+
- allow: { method: GET, path: "/file/bot*/**" }
231+
binaries:
232+
- { path: /usr/local/bin/node }
233+
234+
discord:
235+
name: discord
236+
endpoints:
237+
- host: discord.com
238+
port: 443
239+
protocol: rest
240+
enforcement: enforce
241+
tls: terminate
242+
rules:
243+
- allow: { method: GET, path: "/**" }
244+
- allow: { method: POST, path: "/**" }
245+
# WebSocket gateway — must use access: full (CONNECT tunnel) instead
246+
# of protocol: rest. The proxy's HTTP idle timeout (~2 min) kills
247+
# long-lived WebSocket connections; a CONNECT tunnel avoids
248+
# HTTP-level timeouts entirely. Matches presets/discord.yaml. See #409.
249+
- host: gateway.discord.gg
250+
port: 443
251+
access: full
252+
- host: cdn.discordapp.com
253+
port: 443
254+
protocol: rest
255+
enforcement: enforce
256+
tls: terminate
257+
rules:
258+
- allow: { method: GET, path: "/**" }
259+
binaries:
214260
- { path: /usr/local/bin/node }

test/validate-blueprint.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,19 @@ describe("base sandbox policy", () => {
253253
);
254254
expect(githubHosts).toEqual([]);
255255
});
256+
257+
it("regression #1458: baseline npm_registry must not include npm or node binaries", () => {
258+
const np = policy.network_policies as Record<string, Record<string, unknown>>;
259+
const npmRegistry = np.npm_registry;
260+
expect(npmRegistry).toBeDefined();
261+
const binaries = npmRegistry.binaries as Array<{ path: string }> | undefined;
262+
expect(Array.isArray(binaries)).toBe(true);
263+
const paths = (binaries ?? []).map((b) => b.path).sort();
264+
// Only openclaw CLI should reach the npm registry by default.
265+
// npm/node being in this list lets the agent bypass 'none' policy preset.
266+
// Exact allowlist — adding any binary here requires a deliberate review.
267+
expect(paths).toEqual(["/usr/local/bin/openclaw"]);
268+
});
256269
});
257270

258271
describe("github preset", () => {

0 commit comments

Comments
 (0)