Skip to content

fix(security): redact token-shaped values from sandbox doctor --json output - #7356

Merged
apurvvkumaria merged 2 commits into
mainfrom
dongniy/7003-doctor-json-redact
Jul 23, 2026
Merged

fix(security): redact token-shaped values from sandbox doctor --json output#7356
apurvvkumaria merged 2 commits into
mainfrom
dongniy/7003-doctor-json-redact

Conversation

@Dongni-Yang

@Dongni-Yang Dongni-Yang commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

sandbox doctor --json resolved with the raw report, while sandbox status --json has redacted its machine-readable report since #4310. Both doctor JSON egress points now pass through the centralized redactForLog, so token-shaped values in check details no longer reach JSON consumers. Exit codes are still computed from the raw report before redaction.

Related Issue

Refs #4310 (the status --json redaction precedent this change mirrors). The asymmetry was found while verifying the redaction contract for the serving-process health design discussion on #7003 (refs only; this PR does not close either issue).

Changes

  • src/lib/actions/sandbox/doctor-report.ts: the renderDoctorReport JSON branch prints via console.log, which bypasses the oclif logJson redaction boundary (fix(security): harden low-risk code scanning findings #3657); the report is now routed through redactForLog before printing.
  • src/commands/sandbox/doctor.ts: the oclif --json path now returns redactForLog(report), so programmatic consumers of the resolved value — not just the logJson-printed stdout — never see raw token-shaped detail. process.exitCode is derived from the raw report first.
  • Tests: one render-level and one command-boundary redaction test. Each uniquely pins its egress point: the command test mocks runSandboxDoctor (so renderDoctorReport never runs on that path), and the render test calls renderDoctorReport directly (the oclif path bypasses it via quietJson). Both were red before the fix.

Review notes:

  • Pre-existing quirk (unchanged here, identical in status --json): redactFull's word-context patterns can consume a short word following a credential-shaped env-var name, e.g. …_API_KEY for NVIDIA managed health… renders as …_API_KEY <REDACTED> NVIDIA managed health…. A candidate follow-up is to give FULL_REDACT_PATTERNS the same {10,} minimum value length CONTEXT_PATTERNS already uses.
  • The renderDoctorReport JSON branch currently has no production caller (the oclif command always passes quietJson: true with --json); it is redacted anyway because that console.log egress has no other redaction layer for any future direct caller.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: doctor --json is documented only as "Emit the report as JSON" with no field-level or verbatim-detail contract (docs/reference/commands.mdx); this change enforces the existing CLI redaction contract in docs/security/best-practices.mdx.
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: cjagwani approved PR SHA 92aa402 after reviewing the redaction coverage, resolved automated feedback, required checks, and selected E2E.
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

DGX Station Hardware Evidence

  • Tested on DGX Station
  • Tested commit: Not applicable
  • Station profile/scenario: Not applicable
  • Result: Not applicable
  • Supporting evidence: Not applicable — this PR does not change scripts/prepare-dgx-station-host.sh.

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable — npm run check:diff passed (hooks skipped locally; commitlint reports one non-blocking footer-leading-blank warning)
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — npx vitest run --project cli src/lib/actions/sandbox/doctor-report.test.ts src/commands/sandbox/oclif-command-adapters.test.ts src/lib/actions/sandbox/doctor-flow.test.ts src/lib/actions/sandbox/doctor-inference.test.ts → 42/42 passed
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result: not applicable (targeted change)
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed

Signed-off-by: Dongni-Yang dongniy@nvidia.com

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Sandbox diagnostic reports in JSON mode now redact token-shaped values from returned and displayed details.
    • Preserved failure status reporting while preventing sensitive token values from appearing in machine-readable output.
  • Tests

    • Added coverage confirming redaction in both CLI results and printed JSON reports.

…output

`sandbox doctor --json` lacked the return-boundary redaction that
`sandbox status --json` has had since #4310: the oclif path resolved
with the raw report, so programmatic consumers of the resolved value
saw unredacted check details (only the logJson print boundary, #3657,
redacted the CLI stdout), and the lib-level renderDoctorReport JSON
branch printed via console.log with no redaction at all. Route both
egress points through the centralized redactForLog source of truth,
computed after exit codes are derived from the raw report.

Refs #4310

Signed-off-by: Dongni-Yang <dongniy@nvidia.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Sandbox doctor JSON reports are now passed through centralized redaction before logging or returning them. Tests verify token-shaped values are replaced, hints remain unchanged, and failure exit codes are preserved.

Changes

Sandbox doctor redaction

Layer / File(s) Summary
Redact rendered JSON reports
src/lib/actions/sandbox/doctor-report.ts, src/lib/actions/sandbox/doctor-report.test.ts
Machine-readable doctor reports are redacted before JSON logging, with tests covering token removal, preserved hints, and failure status.
Redact CLI JSON returns
src/commands/sandbox/doctor.ts, src/commands/sandbox/oclif-command-adapters.test.ts
The CLI returns a redacted JSON report while preserving failure exit behavior, with adapter coverage for bearer-token removal.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: area: security, area: cli, bug-fix

Suggested reviewers: harjothkhara

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: redacting token-shaped values from sandbox doctor JSON output.
✨ 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 dongniy/7003-doctor-json-redact

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

@github-code-quality

github-code-quality Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit 92aa402 in the dongniy/7003-doctor-... branch remains at 96%, unchanged from commit f992494 in the main branch.

TypeScript / code-coverage/cli

The overall coverage in commit 92aa402 in the dongniy/7003-doctor-... branch remains at 80%, unchanged from commit f992494 in the main branch.

Show a code coverage summary of the most impacted files.
File main f992494 dongniy/7003-doctor-... 92aa402 +/-
src/lib/state/m...-acquisition.ts 89% 84% -5%
src/lib/actions...octor-report.ts 95% 95% 0%
src/lib/agent/r...ime-manifest.ts 100% 100% 0%
src/lib/messagi...nnels/policy.ts 100% 100% 0%
src/lib/sandbox...rce-identity.ts 87% 87% 0%
src/lib/securit...ntial-filter.ts 93% 93% 0%
src/lib/state/m...ock-identity.ts 95% 95% 0%
src/lib/state/m...lock-storage.ts 97% 97% 0%
src/lib/trace.ts 94% 94% 0%
src/lib/platform.ts 84% 89% +5%

Updated July 22, 2026 14:56 UTC

@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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/actions/sandbox/doctor-report.test.ts`:
- Around line 37-56: Update the “redacts token-shaped values from the
machine-readable report” test to wrap its assertions and report rendering in a
try/finally block, calling logSpy.mockRestore() in the finally clause so the
console.log spy is always restored.
🪄 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: 56867ffb-9368-4380-b1ba-58948ae3f0a7

📥 Commits

Reviewing files that changed from the base of the PR and between 7be1bad and d52d3f1.

📒 Files selected for processing (4)
  • src/commands/sandbox/doctor.ts
  • src/commands/sandbox/oclif-command-adapters.test.ts
  • src/lib/actions/sandbox/doctor-report.test.ts
  • src/lib/actions/sandbox/doctor-report.ts

Comment thread src/lib/actions/sandbox/doctor-report.test.ts
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — Informational

Advisor assessment: Informational / high confidence
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions
Status: No actionable findings remain in the canonical review ledger.

Model lanes

  • GPT-5.6 Terra (primary): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Model comparison: normalized findings match; normalized E2E selections differ; severity counts match.

Nemotron output stays in workflow artifacts and does not change the assessment above.

E2E guidance

Advisory only. E2E / PR Gate selects and runs jobs independently.

Recommended E2E: onboard-repair, onboard-resume

1 optional E2E recommendation
  • credential-sanitization

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

@jyaunches jyaunches self-assigned this Jul 22, 2026
@jyaunches
jyaunches self-requested a review July 22, 2026 15:27

@cjagwani cjagwani 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 exact head 92aa402. The token redaction fix is covered, the only CodeRabbit thread is resolved/withdrawn, both review-advisor lanes report no actionable findings, and all required CI plus selected E2E passed. Approving; not merging.

@wscurran wscurran added area: cli Command line interface, flags, terminal UX, or output area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery area: security Security controls, permissions, secrets, or hardening bug-fix PR fixes a bug or regression labels Jul 23, 2026
@apurvvkumaria
apurvvkumaria merged commit c5b1880 into main Jul 23, 2026
76 checks passed
@apurvvkumaria
apurvvkumaria deleted the dongniy/7003-doctor-json-redact branch July 23, 2026 21:48
@prekshivyas prekshivyas mentioned this pull request Jul 24, 2026
23 tasks
prekshivyas added a commit that referenced this pull request Jul 24, 2026
<!-- markdownlint-disable MD041 -->
## Summary

This PR adds the canonical dated release entry for NemoClaw v0.0.94
before the tag is cut.
The entry reconciles all 26 commits since v0.0.93 and links each
user-visible change to its owning documentation.

## Changes

- Add `docs/changelog/2026-07-24.mdx` with the exact `## v0.0.94`
heading, parser-safe SPDX comment, release summary, and detailed
bullets.
- Record sandbox restore and update behavior, onboarding and inference
changes, network policy behavior, security evidence, Hermes build
performance, DGX Station guidance, and E2E validation changes.
- Preserve `docs/` as the source of truth without changing the AI-agent
documentation routing skill.
- Use [E2E run
30075443016](https://github.com/NVIDIA/NemoClaw/actions/runs/30075443016)
for release QA evidence at exact tested SHA
`04e6dfa883071dda9df429c66e73168e1a995cba`.

### Source summary

- [#7461](#7461) ->
`docs/changelog/2026-07-24.mdx`: Record the ownership-preserving Hermes
image layer reduction and hosted timing comparison.
- [#7460](#7460) ->
`docs/changelog/2026-07-24.mdx`: Record removal of candidate Hermes swap
setup from E2E validation.
- [#7458](#7458) ->
`docs/security/fern-5.80.1-dependency-review.md`,
`docs/changelog/2026-07-24.mdx`: Record the reviewed Fern CLI update.
- [#7457](#7457) ->
`docs/changelog/2026-07-24.mdx`: Record periodic runner-pressure
telemetry.
- [#7455](#7455) ->
`docs/changelog/2026-07-24.mdx`: Record non-blocking absent Fern
previews.
- [#7450](#7450) ->
`docs/changelog/2026-07-24.mdx`: Record stable cancellation handling for
live-test child processes.
- [#7449](#7449) ->
`docs/changelog/2026-07-24.mdx`: Record parallel plugin EXDEV coverage.
- [#7448](#7448) ->
`docs/changelog/2026-07-24.mdx`: Record isolated long-running E2E lanes.
- [#7444](#7444) ->
`docs/changelog/2026-07-24.mdx`: Record exact-head Hermes swap
validation.
- [#7437](#7437) ->
`docs/manage-sandboxes/backup-restore.mdx`,
`docs/changelog/2026-07-24.mdx`: Record gateway pairing and
authenticated verification after cross-sandbox restore.
- [#7436](#7436) ->
`docs/manage-sandboxes/backup-restore.mdx`,
`docs/reference/commands.mdx`, `docs/changelog/2026-07-24.mdx`: Record
selected stale-state cleanup and Hermes virtual-environment access
repair.
- [#7385](#7385) ->
`docs/network-policy/customize-network-policy.mdx`,
`docs/changelog/2026-07-24.mdx`: Record the read-only agent-variant
route check.
- [#7371](#7371) ->
`docs/changelog/2026-07-24.mdx`: Record host-artifact verification for
session exports.
- [#7359](#7359) ->
`docs/changelog/2026-07-24.mdx`: Record platform validation for managed
vLLM model overrides.
- [#7356](#7356) ->
`docs/changelog/2026-07-24.mdx`: Record token-shaped value redaction for
`sandbox doctor --json`.
- [#7354](#7354) ->
`docs/security/advisory-early-warning.md`,
`docs/changelog/2026-07-24.mdx`: Record advisory correlation and
retained audit provenance.
- [#7352](#7352) ->
`docs/network-policy/customize-network-policy.mdx`,
`docs/network-policy/integration-policy-examples.mdx`,
`docs/reference/commands.mdx`, `docs/changelog/2026-07-24.mdx`: Record
preset reapplication and bounded `tls: skip` guidance.
- [#7345](#7345) ->
`docs/security/openclaw-2026.6.10-dependency-review.md`,
`docs/security/openclaw-2026.7.1-dependency-review.md`,
`docs/changelog/2026-07-24.mdx`: Record reviewed npm audit exception
enforcement.
- [#7340](#7340) ->
`docs/network-policy/customize-network-policy.mdx`,
`docs/changelog/2026-07-24.mdx`: Record the repaired CLI-reference
route.
- [#7334](#7334) ->
`docs/get-started/dgx-station-preparation.mdx`,
`docs/changelog/2026-07-24.mdx`: Record the qualified OTA metadata
fallback and narrowed override wording.
- [#7322](#7322) ->
`docs/changelog/2026-07-24.mdx`: Reconcile the gateway source tag added
to plugin registration banners.
- [#7284](#7284) ->
`docs/manage-sandboxes/update-sandboxes.mdx`,
`docs/changelog/2026-07-24.mdx`: Record read-only `upgrade-sandboxes
--check` behavior and recorded-gateway selection.
- [#7277](#7277) ->
`docs/changelog/2026-07-24.mdx`: Reconcile deterministic gateway TCP
refusal coverage.
- [#7234](#7234) ->
`docs/reference/troubleshooting.mdx`, `docs/changelog/2026-07-24.mdx`:
Record preserved DGX Spark managed vLLM Express intent on resume.
- [#7185](#7185) ->
`docs/reference/troubleshooting.mdx`, `docs/changelog/2026-07-24.mdx`:
Record IPv4 fallback DNS selection and exact resolver probing.
- [#6820](#6820) ->
`docs/reference/commands.mdx`, `docs/changelog/2026-07-24.mdx`: Record
the versioned, redacted `--events=jsonl` onboarding stream.

## Type of Change

- [ ] Code change (feature, bug fix, or refactor)
- [ ] Code change with doc updates
- [x] Doc only (prose changes, no code sample modifications)
- [ ] Doc only (includes code sample changes)

## Quality Gates

- [ ] Tests added or updated for changed behavior
- [x] Existing tests cover changed behavior — justification: `npx vitest
run test/changelog-docs.test.ts` passed 6/6 tests.
- [ ] Tests not applicable — justification:
- [x] Docs updated for user-facing behavior changes
- [ ] Docs not applicable — justification:
- [ ] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging)
- [ ] Sensitive-path review completed or maintainer-approved waiver
recorded — reviewer/approval link/justification:
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## Documentation Writer Review

- [x] Documentation writer subagent reviewed the completed changes
- Result: `docs-updated`
- Evidence: `docs/changelog/2026-07-24.mdx`; the writing rules,
documentation style, exact release range, skip terms, published routes,
and product scope were reviewed; the changelog test passed 6/6; `npm run
docs` passed with route checking OK, zero errors, and two existing
warnings.
- Agent: Codex Desktop
<!-- docs-review-head-sha: 65368f9 -->
<!-- docs-review-agents-blob-sha: 9c9b36d -->

## DGX Station Hardware Evidence

- [ ] Tested on DGX Station
- Tested commit: Not applicable
- Station profile/scenario: Not applicable
- Result: Not applicable
- Supporting evidence: Not applicable. This PR does not change
`scripts/prepare-dgx-station-host.sh`.

## Verification

- [x] PR description includes a `Signed-off-by:` line and every commit
appears as `Verified` in GitHub
- [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or
`npm run check:diff` passed when hooks were skipped or unavailable
- [x] Targeted behavior tests pass for the current change set, or tests
are marked not applicable above — `npx vitest run
test/changelog-docs.test.ts` passed 6/6 tests.
- [ ] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — command/result: Not applicable to the
dated changelog entry.
- [x] Quality Gates section completed with required justifications or
waivers
- [x] No secrets, API keys, or credentials committed
- [ ] `npm run docs` builds without warnings (doc changes only). The
build passed with zero errors and two existing Fern warnings.
- [x] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages
only). Native dated changelog entries use the required parser-safe MDX
SPDX comment and no frontmatter.

---
Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>


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

## Summary by CodeRabbit

* **Documentation**
  * Added the v0.0.94 release changelog.
  * Documented improvements to sandbox snapshot and restore behavior.
* Added updates for gateway selection, policy comparisons, onboarding
event output, and DGX recovery workflows.
* Documented enhanced diagnostics redaction, npm audit provenance, image
assembly performance, and validation stability improvements.


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

Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>
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: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery 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.

6 participants