Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 7 additions & 43 deletions nemoclaw-blueprint/policies/openclaw-sandbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,46 +172,10 @@ network_policies:
binaries:
- { path: /usr/local/bin/openclaw }

# ── Messaging — pre-allowed for OpenClaw agent notifications ────
# Restricted to node processes to prevent arbitrary data exfiltration
# via curl, wget, python, etc. (See: #272)
telegram:
name: telegram
endpoints:
- host: api.telegram.org
port: 443
protocol: rest
enforcement: enforce
rules:
- allow: { method: GET, path: "/bot*/**" }
- allow: { method: POST, path: "/bot*/**" }
- allow: { method: GET, path: "/file/bot*/**" }
binaries:
- { path: /usr/local/bin/node }

discord:
name: discord
endpoints:
- host: discord.com
port: 443
protocol: rest
enforcement: enforce
rules:
- allow: { method: GET, path: "/**" }
- allow: { method: POST, path: "/**" }
# WebSocket gateway — pure L4 CONNECT tunnel. OpenShell v0.0.15+
# auto-terminates TLS unconditionally (NVIDIA/OpenShell#544), which
# also applies to WSS. tls: skip restores the pre-v0.0.15 pass-
# through behaviour needed here. Matches presets/discord.yaml.
- host: gateway.discord.gg
port: 443
access: full
tls: skip
- host: cdn.discordapp.com
port: 443
protocol: rest
enforcement: enforce
rules:
- allow: { method: GET, path: "/**" }
binaries:
- { path: /usr/local/bin/node }
# Messaging endpoints (telegram, discord, slack) are intentionally NOT in
# the baseline — #1705 removed them so every sandbox does not silently
# egress to third-party IM platforms without user opt-in. The messaging
# presets (presets/{telegram,discord,slack}.yaml) are the opt-in path:
# users enable a channel in step [5/8] of onboard and the matching preset
# is applied on top of this baseline. Keep this comment so the entries
# are not casually re-added during a merge-conflict resolution. See #2180.
53 changes: 53 additions & 0 deletions test/validate-blueprint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,59 @@ describe("base sandbox policy", () => {
expect(serialized).not.toContain("/usr/local/bin/claude");
});

it("regression #2180: base policy does not silently grant Telegram access", () => {
// Until #1705 (later regressed by #1700 and re-surfaced in #2180),
// `api.telegram.org` plus a /usr/local/bin/node binary lived in the
// base network_policies, so every sandbox could call the Telegram
// Bot API regardless of whether the user selected the telegram
// messaging channel or policy preset. The fix keeps Telegram access
// inside `presets/telegram.yaml`. This assertion blocks a regression
// where someone re-adds a telegram entry to the base policy and
// silently re-grants every sandbox unscoped Telegram access.
const np = policy.network_policies as Record<string, unknown> | undefined;
expect(np && typeof np === "object" && "telegram" in np).toBe(false);

const telegramHosts = findEndpoints((h) => h === "api.telegram.org");
expect(telegramHosts).toEqual([]);
});

it("regression #2180: base policy does not silently grant Discord access", () => {
// Parallel to the Telegram regression above. Discord (discord.com,
// gateway.discord.gg, cdn.discordapp.com, media.discordapp.net) is
// the opt-in preset path, not baseline. Re-adding these endpoints
// to the base policy lets any sandbox reach Discord without the
// user having selected the discord messaging channel or preset.
const np = policy.network_policies as Record<string, unknown> | undefined;
expect(np && typeof np === "object" && "discord" in np).toBe(false);

const discordHosts = findEndpoints(
(h) =>
h === "discord.com" ||
h === "gateway.discord.gg" ||
h === "cdn.discordapp.com" ||
h === "media.discordapp.net",
);
expect(discordHosts).toEqual([]);
});

it("regression #2180: base policy does not silently grant Slack access", () => {
// Slack was never in the baseline, but guard against it being added
// in the same merge-conflict-resolution pattern that re-added
// Telegram and Discord after #1705. Slack access is in
// presets/slack.yaml only.
const np = policy.network_policies as Record<string, unknown> | undefined;
expect(np && typeof np === "object" && "slack" in np).toBe(false);

const slackHosts = findEndpoints(
(h) =>
h === "slack.com" ||
h.endsWith(".slack.com") ||
h === "wss-primary.slack.com" ||
h === "wss-backup.slack.com",
);
expect(slackHosts).toEqual([]);
});

it("regression #1458: baseline npm_registry must not include npm or node binaries", () => {
const np = policy.network_policies ?? {};
const npmRegistry = np.npm_registry;
Expand Down
Loading