Skip to content

fix(credentials): reject untrusted gateway endpoint overrides (#11414) - #11865

Merged
jyaunches merged 16 commits into
mainfrom
deepujain/fix-11414-gateway-identity-diagnostic
Sep 16, 2026
Merged

jyaunches merged 16 commits into
mainfrom
deepujain/fix-11414-gateway-identity-diagnostic

Conversation

@deepujain

@deepujain deepujain commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Outcome

nemoclaw credentials add now rejects an ambient OPENSHELL_GATEWAY_ENDPOINT override locally before any host-side network probe or provider mutation.
The diagnostic names the override and tells the operator to unset or correct it before retrying.

Changes

  • Restore the fail-closed endpoint override guard at the gateway observer boundary.
  • Preserve a typed endpoint_override result through gateway recovery.
  • Report override-specific remediation without exposing the endpoint value.
  • Add adapter, recovery, and production-path regressions proving that the OpenShell command capture is never called.

Refs #11414.

This same-repository PR supersedes fork PR #11676.
The security-safe repair does not claim to distinguish a responding override from an unreachable override because doing that would require the host to contact an untrusted ambient destination.

Verification

  • npm --prefix nemoclaw run build
  • npm run build:cli
  • Focused Vitest selection: 3 files, 41 tests passed.
  • NODE_OPTIONS=--max-old-space-size=8192 npm run typecheck:cli
  • git diff --check

Signed-off-by: Deepak Jain [email protected]

Summary by CodeRabbit

  • New Features

    • Gateway recovery now reports whether recovery was attempted and records gateway states before and after recovery.
    • Added clearer credential recovery guidance for invalid gateway endpoint overrides, identity mismatches, unreachable gateways, and other failures.
  • Bug Fixes

    • Endpoint overrides are now rejected when no runtime gateway selection is available, preventing unsupported endpoint probing.
    • Recovery diagnostics avoid exposing low-level probe or endpoint details while preserving actionable correction guidance.

@copy-pr-bot

copy-pr-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: ea55031f-ef44-4f0a-9357-bd9143272a1a

📥 Commits

Reviewing files that changed from the base of the PR and between 8cc9786 and 8004299.

📒 Files selected for processing (6)
  • src/lib/adapters/openshell/gateway-observer-cli.test.ts
  • src/lib/adapters/openshell/gateway-observer-cli.ts
  • src/lib/adapters/openshell/sandbox-observer.ts
  • src/lib/credentials/command-support.integration.test.ts
  • src/lib/credentials/command-support.test.ts
  • src/lib/credentials/command-support.ts

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


📝 Walkthrough

Walkthrough

The change stops endpoint-override probing before command execution. It adds an endpoint_override transport reason, expands gateway recovery state, and reports endpoint-specific credential recovery guidance. Tests cover endpoint overrides and other recovery outcomes.

Changes

Gateway endpoint override diagnostics

Layer / File(s) Summary
Recovery and transport contracts
src/lib/actions/global.ts, src/lib/adapters/openshell/sandbox-observer-cli.ts, src/lib/adapters/openshell/sandbox-observer.ts
GatewayRecovery is now exported with optional lifecycle fields. Command capture accepts optional environment settings. Transport failures include endpoint_override.
Endpoint override rejection
src/lib/adapters/openshell/gateway-observer-cli.ts, src/lib/adapters/openshell/gateway-observer-cli.test.ts
Gateway observation rejects endpoint overrides before execution and maps the typed rejection to an endpoint_override failure.
Credential recovery diagnostics and validation
src/lib/credentials/command-support.ts, src/lib/credentials/command-support.test.ts, src/lib/credentials/command-support.integration.test.ts
recoverGatewayOrExit checks observations before and after recovery. Endpoint override guidance takes precedence over identity-mismatch guidance. Tests cover endpoint overrides, identity mismatches, unreachable gateways, queries, timeouts, authentication, and schema observations.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant CredentialsAdd as credentials add
  participant Recovery as recoverGatewayOrExit
  participant Observer as gateway-observer-cli
  CredentialsAdd->>Recovery: Recover gateway
  Recovery->>Observer: Observe gateway
  Observer-->>Recovery: Return endpoint_override transport failure
  Recovery-->>CredentialsAdd: Report OPENSHELL_GATEWAY_ENDPOINT guidance
Loading

Suggested reviewers: rsliter, apurvvkumaria

Merge Risk: ⚪ Minimal · up to 80042

Endpoint overrides and unreachable gateway failures stop credential creation before provider mutation, with condition-appropriate remediation. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Issue #11414 requires separate diagnostics for a responding non-gateway and an unreachable gateway. In the reviewed head, gateway-observer-cli.ts converts an OPENSHELL_GATEWAY_ENDPOINT override in… Probe the selected or ambient endpoint with the bounded, read-only, credential-free openshell status call. Classify a responding non-gateway as identity_mismatch and an unreachable endpoint as unreachable. Report separate remediation …
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The reviewed changes remain connected to issue #11414. The recovery evidence type, endpoint transport reason, diagnostic selection, observer handling, and tests all concern gateway endpoint classifica…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: rejecting untrusted gateway endpoint overrides during credential operations.
Full details: Linked Issues check

Explanation

Issue #11414 requires separate diagnostics for a responding non-gateway and an unreachable gateway. In the reviewed head, gateway-observer-cli.ts converts an OPENSHELL_GATEWAY_ENDPOINT override into endpoint_override before invoking the capture function. command-support.ts then reports the same override guidance for either endpoint condition. The production integration test verifies only this rejection path and does not cover wrong identity or unreachable transport. The command still fails closed, but the required condition-specific diagnostics are not implemented for the reported reproduction.

Resolution

Probe the selected or ambient endpoint with the bounded, read-only, credential-free openshell status call. Classify a responding non-gateway as identity_mismatch and an unreachable endpoint as unreachable. Report separate remediation for both conditions. Add production-path tests for both conditions and retain the fail-closed provider-mutation behavior.

✨ 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 deepujain/fix-11414-gateway-identity-diagnostic

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

@github-code-quality

github-code-quality Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall line coverage in commit e33c113 in the deepujain/fix-11414-... branch remains at 96%, unchanged from commit 7c776cd in the main branch.

TypeScript / code-coverage/cli

The overall line coverage in commit e33c113 in the deepujain/fix-11414-... branch remains at 83%, unchanged from commit e57c4e9 in the main branch.

Show a line coverage summary of the most impacted files.
File main e57c4e9 deepujain/fix-11414-... e33c113 +/-
src/lib/actions...ary-recovery.ts 92% 0% -92%
src/lib/actions...eway-restart.ts 94% 75% -19%
src/lib/actions...ess-recovery.ts 80% 63% -17%
src/lib/inferen...file/cleanup.ts 80% 72% -8%
src/lib/onboard...le-lifecycle.ts 79% 76% -3%
src/lib/onboard...le-container.ts 84% 89% +5%
src/lib/state/o...box-recovery.ts 88% 94% +6%
src/lib/onboard...ble-contract.ts 84% 90% +6%
src/lib/onboard...able-receipt.ts 73% 84% +11%
src/lib/sandbox...uild-context.ts 50% 78% +28%

Updated September 16, 2026 12:02 UTC

@deepujain
deepujain marked this pull request as ready for review September 15, 2026 22:49
@deepujain deepujain changed the title fix(credentials): distinguish untrusted gateway endpoints (Fixes #11414) fix(credentials): reject untrusted gateway endpoint overrides (#11414) Sep 16, 2026
@deepujain

Copy link
Copy Markdown
Collaborator Author

Addressed the PR Advisor security, recovery, and verification findings on commit 8004299. Ambient endpoint overrides are now rejected locally before any host-side probe, the diagnostic names OPENSHELL_GATEWAY_ENDPOINT and tells the operator to unset or correct it, and the PR no longer claims to fully close #11414. Plugin build, CLI build, CLI typecheck, and 41 focused tests pass.

@deepujain

Copy link
Copy Markdown
Collaborator Author

Addressed the current-head Advisor finding in 5c64cbf: endpoint-override recovery now requires unsetting OPENSHELL_GATEWAY_ENDPOINT and no longer suggests correcting a value that policy rejects. Focused credential tests pass (8/8), formatting passes, and git diff --check is clean.

@deepujain

Copy link
Copy Markdown
Collaborator Author

Fixed the broken CI assertion in daac724 by aligning the integration test with the current endpoint-recovery guidance and guarding against the retired wording. Validation: 9 focused credential-recovery tests passed, formatting passed, and passed.

@deepujain

Copy link
Copy Markdown
Collaborator Author

Addressed the exact-head PR Advisor finding in signed commit e33c113. Added direct add, list, and reset coverage for endpoint-override recovery, including assertions that provider, registry, and authority side effects do not run. Validation: 22 focused tests passed and all pre-commit hooks passed, including growth guardrails. The local full CLI build remains blocked by existing portable inferred-type errors in unrelated test fixtures; fresh CI is running on the exact head.

@github-actions

Copy link
Copy Markdown
Contributor

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

Request review only when Require no Advisor blockers is green.

All previous runs

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

E2E tests are green

@jyaunches
jyaunches merged commit 5ed0887 into main Sep 16, 2026
49 checks passed
@jyaunches
jyaunches deleted the deepujain/fix-11414-gateway-identity-diagnostic branch September 16, 2026 13:43
cv pushed a commit that referenced this pull request Sep 18, 2026
<!-- markdownlint-disable MD041 -->
## Outcome

OpenShell inference route reads now flow through one typed observer for
the accepted first slice of #9809. Existing gateway targeting, native
lifecycle behavior, list/status redaction, and external command behavior
remain unchanged.

## Reason

Inference consumers independently constructed `openshell inference get`
commands and interpreted raw CLI results. Centralizing the read boundary
gives each consumer the same scoped, typed, and redacted observation
without changing mutation or recovery behavior.

### Related issues

Refs #9809

## Changes

- Add typed configured and unconfigured observations plus distinct
validation, authentication, timeout, schema, transport, and command
failures.
- Keep named-gateway scoping, bounded capture, control-sequence cleanup,
endpoint-override refusal, and the base gateway's legacy output
compatibility inside the OpenShell adapter.
- Migrate the accepted CLI, onboarding, connect, readiness, doctor,
inventory, status, and config-export readers to typed results.
- Remove the superseded production reader and protect the boundary with
adapter and consumer tests.

Route mutation and rollback (#11738), plugin transport (#9813),
generated gRPC transport (#9828), credentials, provider or gateway
lifecycle changes, new routing semantics, status lifecycle suppression,
and live E2E remain excluded.

## Verification

- `NODE_OPTIONS=--max-old-space-size=8192 npm run typecheck:cli` —
passed.
- `npm run checks:repository` — all 19 repository checks passed with no
architecture cycles.
- Focused CLI unit selection — 16 files and 377 tests passed, covering
the adapter and migrated source consumers.
- Focused integration selection — 8 files and 157 tests passed; the
status JSON integration suite passed 21/21.
- `npm run test:changed` — 3,182 tests passed. The route-observation
acceptance set is complete with no candidate-owned failure. Two
process-heavy suites were classified environmental after focused replay;
`snapshot-auto-create-failure` passed 4/4 unchanged and
`runtime-provider-contract` passed 75/75 with a 15-second local
diagnostic timeout.
- The remaining launch group was classified inherited: 18 cases fail
with the same sandbox-replacement journaling error on this candidate and
on exact base `3c6591ddba4a321ab8e6b766203e44d6e3b8002e`; this PR
changes none of the three owning launch/probe files.
- Commit hooks passed, including repository structure, formatting, lint,
tests selected by the commit, DCO, and secret checks.
- The diff contains no secrets, API keys, or credentials.

No live E2E is required because the accepted behavior is fully
observable at deterministic adapter and consumer boundaries and does not
mutate external state.

## Review notes

Sensitive inference and onboarding paths are changed. Pre-publication
review covered exact gateway targeting, refusal of endpoint overrides,
bounded capture, typed failure separation, redaction, current lifecycle
ownership, and the criterion-to-evidence ledger. The refreshed head
still requires exact-head CodeRabbit, PR Review Advisor, CI, and human
approval before merge.

The current-main refresh incorporates related lifecycle and
test-contract changes from #11741, #11776, #11792, #11821, #11829,
#11865, #11889, #11891, #11908, and #11913 without expanding this PR's
behavior.

Accepted scope:
#9809 (comment)

---
Signed-off-by: Rebecca Sliter <[email protected]>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Added structured inference-route checks for configured and
unconfigured gateways.
  - Improved support for named gateways and provider/model verification.
- Added clearer handling for timeouts, authentication, connectivity,
validation, and schema errors.
- Improved sandbox connection, launch readiness, status, onboarding, and
recovery flows with verified route information.

- **Bug Fixes**
- Prevented untrusted or unavailable inference routes from being treated
as healthy.
- Added recovery guidance and preserved relevant failure details when
restoration cannot be confirmed.

- **Documentation**
- Documented inference-route behavior, gateway scoping, sanitization,
timeouts, and error reporting.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Rebecca Sliter <[email protected]>
Signed-off-by: San Dang <[email protected]>
Co-authored-by: Rebecca Sliter <[email protected]>
Co-authored-by: San Dang <[email protected]>
@wscurran wscurran added area: cli Command line interface, flags, terminal UX, or output area: security Security controls, permissions, secrets, or hardening bug-fix PR fixes a bug or regression labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command line interface, flags, terminal UX, or output 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.

3 participants