Skip to content

fix(policy): reject untrusted private hosts - #10659

Merged
prekshivyas merged 3 commits into
mainfrom
security/reject-special-use-policy-hosts
Sep 2, 2026
Merged

prekshivyas merged 3 commits into
mainfrom
security/reject-special-use-policy-hosts

Conversation

@laitingsheng

@laitingsheng laitingsheng commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Outcome

Custom policy presets now reject untrusted private, local, and special-use endpoint hosts before dry-run or policy mutation.
Explicit RFC1918, CGNAT, and IPv6 unique local trust remains capability-pinned, while the reviewed host.openshell.internal bridge remains supported.

Reason

Custom preset preparation returned before shared destination classification when no private-host trust declaration was supplied.
That allowed a link-local cloud metadata endpoint to pass NemoClaw validation even though the documented policy contract requires it to fail closed.

Related issues

Fixes #10653

Changes

  • Classify custom policy endpoint hosts even when no private-host declarations are present, before preview or application.
  • Preserve matching explicit trust for routed RFC1918, CGNAT, and IPv6 unique local destinations, plus the existing OpenShell host-bridge exception.
  • Revalidate in-memory custom preset application so callers cannot bypass command preparation without a provenance-checked pin capability.
  • Cover link-local metadata, loopback, reserved names, IPv6 link-local, explicit private pinning, host-bridge preservation, sibling endpoint isolation, dry-run rejection, and direct application rejection.

Verification

  • node_modules/.bin/vitest run --project cli src/lib/policy/trusted-private-endpoints.test.ts src/lib/policy/preset-allowed-ips.test.ts src/lib/actions/sandbox/policy-channel-refresh.test.ts — 3 files and 58 tests passed.
  • node_modules/.bin/vitest run --project cli src/lib/policy src/lib/actions/sandbox/policy-channel src/lib/security/trusted-private-endpoint.test.ts src/commands/sandbox/policy/mutate.test.ts — 30 files and 449 tests passed.
  • node_modules/.bin/tsc -p tsconfig.cli.json — passed.
  • npm run build:cli — passed.
  • Targeted Oxlint over all five changed files — passed.
  • npm run format:check — passed.
  • npm run checks:repository — passed.
  • git diff --check — passed.
  • Normal commit and pre-push hooks — passed, including repository checks, source-shape and growth gates, private-key detection, gitleaks, commitlint, and CLI typechecking.
  • Commit f084839e59221a3fef50a27b6707042c285c3f6e is signed, DCO-compliant, and GitHub-verified with reason valid.
  • The diff contains no secrets, API keys, or credentials.

Review notes

Sensitive-path review covered no-declaration preparation, explicit private-host capability issuance, the OpenShell bridge exception, in-memory application revalidation, and sibling endpoint authority isolation.
One documentation review completed and corrected the rejection diagnostic to state that explicit trust applies only to RFC1918, CGNAT, and IPv6 unique local destinations.
Existing documentation already states the intended rejection contract, so no documentation change is required.
No live-sandbox E2E was run; the command-action dry-run test proves rejection before policy mutation, while existing OpenShell link-local enforcement remains unchanged.


Signed-off-by: Tinson Lai [email protected]

Summary by CodeRabbit

  • Bug Fixes
    • Strengthened policy validation to reject untrusted private and special-use endpoint hosts, including loopback and metadata endpoints.
    • Added clearer validation errors identifying blocked hosts and permitted trust categories.
    • Ensured invalid policies are rejected before any sandbox policy changes are applied.
    • Preserved support for explicitly trusted private endpoints, public endpoints, and approved sandbox bridge endpoints.

Custom presets without a trust declaration skipped destination
classification, so link-local and other special-use hosts could pass
dry-run and reach policy application.

Enforce the shared private-host classifier before preview and recheck
in-memory application while preserving capability-pinned private hosts.

Signed-off-by: Tinson Lai <[email protected]>
@github-code-quality

github-code-quality Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall line coverage in commit ddb70ed in the security/reject-spec... branch remains at 96%, unchanged from commit 95c0a60 in the main branch.

TypeScript / code-coverage/cli

The overall line coverage in commit ddb70ed in the security/reject-spec... branch remains at 84%, unchanged from commit 95c0a60 in the main branch.

Show a line coverage summary of the most impacted files.
File main 95c0a60 security/reject-spec... ddb70ed +/-
src/lib/state/o...oint-migrate.ts 94% 89% -5%
src/lib/onboard...on-bootstrap.ts 85% 83% -2%
src/lib/onboard...al-inference.ts 90% 90% 0%
src/lib/policy/index.ts 71% 71% 0%
src/lib/actions...licy-channel.ts 78% 78% 0%
src/lib/onboard...uild-context.ts 74% 75% +1%
src/lib/policy/...te-endpoints.ts 86% 89% +3%
src/lib/inferen...anaged-state.ts 73% 77% +4%
src/lib/onboard...esume-intent.ts 85% 94% +9%
src/lib/onboard...y-checkpoint.ts 83% 96% +13%

Updated September 02, 2026 00:57 UTC

@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d72d60ef-854e-4c87-8b4d-daaf20c8d306

📥 Commits

Reviewing files that changed from the base of the PR and between 887efa8 and ca523d6.

📒 Files selected for processing (5)
  • src/lib/actions/sandbox/policy-channel-refresh.test.ts
  • src/lib/policy/index.ts
  • src/lib/policy/preset-allowed-ips.test.ts
  • src/lib/policy/trusted-private-endpoints.test.ts
  • src/lib/policy/trusted-private-endpoints.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/lib/policy/index.ts
  • src/lib/actions/sandbox/policy-channel-refresh.test.ts
  • src/lib/policy/trusted-private-endpoints.ts
  • src/lib/policy/preset-allowed-ips.test.ts
  • src/lib/policy/trusted-private-endpoints.test.ts

Included review availability: Your plan provides up to 12 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Custom policy presets now reject untrusted private and special-use endpoint hosts before policy application. Trusted endpoints and the OpenShell bridge remain supported. Tests cover validation, side-effect prevention, and dry-run policy refresh behavior.

Changes

Policy endpoint validation

Layer / File(s) Summary
Trusted endpoint preflight
src/lib/policy/trusted-private-endpoints.ts, src/lib/policy/trusted-private-endpoints.test.ts
Detects untrusted private hosts. Tests cover private, loopback, link-local, metadata, public, bridge, and explicitly trusted endpoints.
Custom preset validation integration
src/lib/policy/index.ts, src/lib/policy/preset-allowed-ips.test.ts
Validates custom preset endpoint hosts before existing checks. Tests verify rejection without side effects.
Policy refresh command validation
src/lib/actions/sandbox/policy-channel-refresh.test.ts
Verifies that dry-run validation rejects a link-local metadata endpoint without applying the policy or refreshing the sandbox context.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to ca523

This localized policy change rejects untrusted private and special-use hosts while preserving explicitly trusted destinations and the reviewed host bridge; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title, "fix(policy): reject untrusted private hosts," clearly and concisely describes the primary change: rejecting unsafe private endpoint hosts in policy presets.
Linked Issues check ✅ Passed The changes satisfy issue #10653. Custom presets now reject untrusted link-local metadata, loopback, private, reserved, and special-use endpoint hosts before policy application, while supported truste…
Out of Scope Changes check ✅ Passed All changes are within scope. The implementation adds private-host validation and the tests cover the linked issue and related SSRF-boundary cases. No unrelated code changes are identified.
Full details: Linked Issues check

Explanation

The changes satisfy issue #10653. Custom presets now reject untrusted link-local metadata, loopback, private, reserved, and special-use endpoint hosts before policy application, while supported trusted endpoints remain allowed. Tests verify rejection, non-mutation, dry-run behavior, and the expected validation error.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch security/reject-special-use-policy-hosts

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

@laitingsheng laitingsheng added area: networking DNS, proxy, TLS, ports, host aliases, or connectivity area: policy Network policy, egress rules, presets, or sandbox policy bug-fix PR fixes a bug or regression labels Aug 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Review Advisor finished for commit f084839. Include the Advisor findings in the complete PR feedback collection. Verify and group valid findings before repair.

All previous runs

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@prekshivyas prekshivyas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the effective policy diff and focused regression coverage. The authoritative gate reports all 50 current checks green, no conflicts, no unresolved major/critical CodeRabbit findings, risky files covered by tests, and all commits DCO/GitHub Verified. The complete prior nine-specialist Advisor review found no required changes; the current OpenAI-route specialist failures are an unrelated post-merge Advisor model-routing infrastructure regression and produced no findings.

@prekshivyas
prekshivyas merged commit 482714a into main Sep 2, 2026
91 of 109 checks passed
@prekshivyas
prekshivyas deleted the security/reject-special-use-policy-hosts branch September 2, 2026 01:01
cv added a commit that referenced this pull request Sep 2, 2026
## Outcome

Improve PR Review Advisor specialist investigation quality using
independently selected prompt variants from three model-backed
historical-PR A/B rounds.

## Reason

The clean benchmark showed that broad prompts could attribute inherited
defects to a PR, miss incomplete immutable-pin migrations, and conflate
producer or rejection tests with positive consumer proof.

## Changes

- Require changed-file, parent-state, consumer, and contract causality.
- Narrow architecture ownership and add migration-completion and
reduction-simplification specialists.
- Adopt independently selected delivery, documentation, and verification
prompts.
- Preserve tracked internal symlinks in local snapshots while removing
escaping links; direct patching could not preserve this security
boundary and valid transitions together.
- Protect snapshot behavior with internal-link and escaping-to-internal
retarget regression coverage.

## Verification

- CLI and plugin builds — passed.
- `npm run typecheck:cli` — passed.
- `npm run checks:repository` — passed.
- Focused integration tests — 47/47 passed.
- Diff whitespace check — passed.
- Independent documentation review — PASS.
- Three A/B rounds on #10659, #10536, and #10618 with
`azure/openai/gpt-5.6-terra` — completed.
- No secrets, API keys, or credentials are present in the diff.

## Review notes

This draft is stacked on #10813. Output length and finding count were
not selection criteria; prompts were selected independently for
factuality, recall, causality, calibration, and remedies.

---
Signed-off-by: Carlos Villela <[email protected]>

Signed-off-by: Carlos Villela <[email protected]>
@wscurran wscurran added the area: security Security controls, permissions, secrets, or hardening label Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: networking DNS, proxy, TLS, ports, host aliases, or connectivity area: policy Network policy, egress rules, presets, or sandbox policy area: security Security controls, permissions, secrets, or hardening bug-fix PR fixes a bug or regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Linux][Policy&Network] policy add accepts link-local metadata endpoint in custom preset

3 participants