Skip to content

fix(policy): allow local inference host gateway - #2993

Merged
cv merged 2 commits into
mainfrom
fix/2199-local-inference-host-policy
May 5, 2026
Merged

fix(policy): allow local inference host gateway#2993
cv merged 2 commits into
mainfrom
fix/2199-local-inference-host-policy

Conversation

@ericksoa

@ericksoa ericksoa commented May 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • allowlist private RFC1918 host-gateway IP ranges on the local-inference preset endpoints for Ollama, the auth proxy, and vLLM
  • keep the existing host/port/binary restrictions in place for host.openshell.internal
  • add a regression test so the Ollama/proxy/vLLM endpoints cannot lose those allowed_ips entries silently

Root cause

PR #2295 added the missing binaries, but OpenShell v0.0.36 performs a second SSRF check after the policy endpoint/binary match. host.openshell.internal resolves to a Docker/Colima/WSL host-gateway address, which is private by design. Without allowed_ips, OpenShell still returns 403 ssrf_denied for host.openshell.internal:11434 and :11435 even when local-inference appears active.

Live OpenShell validation

Tested with OpenShell 0.0.36 on dedicated gateway issue2199test. Host services were reachable before sandbox testing:

  • host 127.0.0.1:11434/api/tags -> 200
  • host 127.0.0.1:11435/api/tags -> 200

Using the origin/main local-inference policy reproduced the reopened issue:

  • sandbox host.openshell.internal:11434/api/tags -> 403, {"error":"ssrf_denied"}
  • sandbox host.openshell.internal:11435/api/tags -> 403, {"error":"ssrf_denied"}

Using this PR's local-inference policy fixed the same calls:

  • sandbox host.openshell.internal:11434/api/tags -> 200
  • sandbox host.openshell.internal:11435/api/tags -> 200

Other validation

  • npm ci --ignore-scripts
  • npm run build:cli
  • npx vitest run test/policies.test.ts test/validate-blueprint.test.ts
  • git diff --check

Closes #2199

Summary by CodeRabbit

  • New Features

    • Enhanced local-inference network policy: added explicit allowlisting of RFC1918 private IP ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) for host endpoints on ports 11434, 11435, and 8000.
    • Included a note clarifying SSRF guard behavior for the 11434 endpoint.
  • Tests

    • Added tests validating the local-inference preset now enforces the expected IP allowlists for the specified endpoints.

@ericksoa ericksoa added bug NV QA Bugs found by the NVIDIA QA Team provider: ollama Ollama local model provider behavior labels May 4, 2026
@ericksoa ericksoa self-assigned this May 4, 2026
@copy-pr-bot

copy-pr-bot Bot commented May 4, 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 May 4, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The PR updates the local-inference network policy preset to add allowed_ips (RFC1918 CIDRs) for host.openshell.internal endpoints on ports 11434, 11435, and 8000, and adds a test that parses the preset YAML and asserts those allowed_ips entries exist for the three endpoints.

Changes

Network Policy & Validation

Layer / File(s) Summary
Policy Allowlist
nemoclaw-blueprint/policies/presets/local-inference.yaml
Adds an allowed_ips block to host.openshell.internal endpoints for ports 11434, 11435, and 8000, listing 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. A comment about SSRF guard behavior is included for port 11434. Existing GET/POST "/**" rules remain.
Test / Parsing
test/policies.test.ts
Imports YAML parser and adds a loadPreset("local-inference") test that loads and parses the preset, finds endpoints for host.openshell.internal on ports 11434, 11435, and 8000, and asserts each endpoint's allowed_ips equals the three RFC1918 CIDRs exactly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I tunneled through YAML, nibbling bits of rule,
Three cozy ports now welcome packets from the pool.
Private ranges hop in, no longer left outside,
Sandbox and Ollama now gossip side by side.
🥕✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding allowed IPs to the local-inference policy preset to fix host gateway access issues.
Linked Issues check ✅ Passed The PR successfully addresses all coding requirements from issue #2199: adds RFC1918 IP ranges to allowed_ips for ports 11434/11435/8000, retains existing restrictions, and includes regression tests.
Out of Scope Changes check ✅ Passed All changes are scoped to resolving issue #2199: updates to local-inference preset policy and corresponding test additions. No unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/2199-local-inference-host-policy

Review rate limit: 8/10 reviews remaining, refill in 10 minutes and 2 seconds.

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

@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.

🧹 Nitpick comments (1)
nemoclaw-blueprint/policies/presets/local-inference.yaml (1)

8-53: Run targeted network-policy e2e before merge.

Since this directly changes sandbox egress/SSRF behavior, running the focused network-policy E2E job is a good safety check for runtime environments.

As per coding guidelines: "E2E test recommendation: network-policy-e2e — deny-by-default, whitelist, hot-reload, SSRF".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nemoclaw-blueprint/policies/presets/local-inference.yaml` around lines 8 -
53, Run the targeted network-policy e2e job for the
network_policies.local_inference changes before merging; execute the
"network-policy-e2e" suite and validate deny-by-default behavior, whitelist
enforcement for allowed_ips on each endpoints entry (host.openshell.internal
ports 11434, 11435, 8000), SSRF protections (resolved address allowlisting), and
policy hot-reload behavior after applying this preset; report any failing checks
and fix policy rules in the local_inference block if egress, SSRF allowlisting,
or hot-reload tests fail.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@nemoclaw-blueprint/policies/presets/local-inference.yaml`:
- Around line 8-53: Run the targeted network-policy e2e job for the
network_policies.local_inference changes before merging; execute the
"network-policy-e2e" suite and validate deny-by-default behavior, whitelist
enforcement for allowed_ips on each endpoints entry (host.openshell.internal
ports 11434, 11435, 8000), SSRF protections (resolved address allowlisting), and
policy hot-reload behavior after applying this preset; report any failing checks
and fix policy rules in the local_inference block if egress, SSRF allowlisting,
or hot-reload tests fail.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: be127d6f-b232-4910-95a4-35a1f9c10491

📥 Commits

Reviewing files that changed from the base of the PR and between eb31d2b and f0a108c.

📒 Files selected for processing (2)
  • nemoclaw-blueprint/policies/presets/local-inference.yaml
  • test/policies.test.ts

@ericksoa
ericksoa force-pushed the fix/2199-local-inference-host-policy branch from f0a108c to 478cbad Compare May 4, 2026 17:27
Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
@ericksoa
ericksoa force-pushed the fix/2199-local-inference-host-policy branch from 478cbad to e0b1523 Compare May 4, 2026 17:29

@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 the current code and only fix it if needed.

Inline comments:
In `@test/policies.test.ts`:
- Line 17: Replace the CommonJS-style require used to load YAML with an ESM
import: remove the requireForTest("yaml") call that assigns to the YAML variable
and instead import the package using ESM syntax (e.g., import YAML from 'yaml')
at the top of the test file so the test uses the package's native ESM export;
update any references to the YAML symbol unchanged.
🪄 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: 38f54001-a66a-4509-a3a5-5585e6a80668

📥 Commits

Reviewing files that changed from the base of the PR and between 478cbad and e0b1523.

📒 Files selected for processing (2)
  • nemoclaw-blueprint/policies/presets/local-inference.yaml
  • test/policies.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • nemoclaw-blueprint/policies/presets/local-inference.yaml

Comment thread test/policies.test.ts

const requireForTest = createRequire(import.meta.url);
const readline = requireForTest("node:readline") as typeof import("node:readline");
const YAML = requireForTest("yaml");

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Does the yamlnpm package support ESM usage asimport YAML from "yaml"withYAML.parse(...) in TypeScript projects?

💡 Result:

Yes. The yaml npm package supports ESM-style default import in TypeScript projects, e.g. import YAML from 'yaml', and then calling YAML.parse(...). Evidence: the package’s official docs show import YAML from 'yaml' followed by YAML.parse('3.14159') (and similar examples).

Citations:


🏁 Script executed:

# Check the actual content of test/policies.test.ts, focusing on imports and the yaml usage
head -30 test/policies.test.ts | cat -n

Repository: NVIDIA/NemoClaw

Length of output: 1933


🏁 Script executed:

# Check if there are other uses of yaml in the file
rg "yaml|YAML" test/policies.test.ts -n

Repository: NVIDIA/NemoClaw

Length of output: 1933


🏁 Script executed:

# Check the full import section to understand the file structure
grep -n "^import\|^const\|^require\|requireForTest" test/policies.test.ts | head -20

Repository: NVIDIA/NemoClaw

Length of output: 1207


Use an ESM import for the yaml package in this test file.

Line 17 introduces requireForTest("yaml"), which conflicts with the test ESM-import requirement. The yaml npm package natively supports ESM import syntax.

Suggested change
 import { spawnSync } from "node:child_process";
+import YAML from "yaml";
 import policies from "../dist/lib/policies";
 import { execTimeout } from "./helpers/timeouts";
@@
-const YAML = requireForTest("yaml");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const YAML = requireForTest("yaml");
import { spawnSync } from "node:child_process";
import YAML from "yaml";
import policies from "../dist/lib/policies";
import { execTimeout } from "./helpers/timeouts";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/policies.test.ts` at line 17, Replace the CommonJS-style require used to
load YAML with an ESM import: remove the requireForTest("yaml") call that
assigns to the YAML variable and instead import the package using ESM syntax
(e.g., import YAML from 'yaml') at the top of the test file so the test uses the
package's native ESM export; update any references to the YAML symbol unchanged.

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

Selective E2E Results — ✅ All requested jobs passed

Run: 25334892463
Branch: fix/2199-local-inference-host-policy
Requested jobs: gpu-e2e
Summary: 0 passed, 0 failed, 22 skipped

Job Result
cloud-e2e ⏭️ skipped
cloud-inference-e2e ⏭️ skipped
cloud-onboard-e2e ⏭️ skipped
deployment-services-e2e ⏭️ skipped
diagnostics-e2e ⏭️ skipped
docs-validation-e2e ⏭️ skipped
gpu-e2e ⏭️ skipped
hermes-e2e ⏭️ skipped
inference-routing-e2e ⏭️ skipped
messaging-compatible-endpoint-e2e ⏭️ skipped
messaging-providers-e2e ⏭️ skipped
network-policy-e2e ⏭️ skipped
overlayfs-autofix-e2e ⏭️ skipped
rebuild-hermes-e2e ⏭️ skipped
rebuild-openclaw-e2e ⏭️ skipped
sandbox-operations-e2e ⏭️ skipped
sandbox-survival-e2e ⏭️ skipped
shields-config-e2e ⏭️ skipped
skill-agent-e2e ⏭️ skipped
snapshot-commands-e2e ⏭️ skipped
token-rotation-e2e ⏭️ skipped
upgrade-stale-sandbox-e2e ⏭️ skipped

@ericksoa
ericksoa requested a review from cv May 5, 2026 00:14
@cv
cv merged commit 432c0f2 into main May 5, 2026
16 checks passed
@wscurran wscurran added area: local-models Local model providers, downloads, launch, or connectivity area: providers Inference provider integrations and provider behavior bug-fix PR fixes a bug or regression and removed Local Models labels Jun 3, 2026
@cv
cv deleted the fix/2199-local-inference-host-policy branch June 28, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: local-models Local model providers, downloads, launch, or connectivity area: providers Inference provider integrations and provider behavior bug-fix PR fixes a bug or regression NV QA Bugs found by the NVIDIA QA Team provider: ollama Ollama local model provider behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[All Platforms] local-inference policy preset missing Ollama ports 11434/11435 (403 from sandbox)

3 participants