fix(security): validate snapshot base64 linearly - #8081
Conversation
Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
📝 WalkthroughWalkthroughThe snapshot sanitizer now shares size limits across TypeScript and Python, validates Base64 length, syntax, canonical form, decoded size, and UTF-8 boundaries, and tests replacement rejection. ChangesSnapshot sanitizer validation
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Code Coverage OverviewLanguages: TypeScript TypeScript / code-coverage/pluginThe overall coverage in commit 1513342 in the Show a code coverage summary of the most impacted files.
TypeScript / code-coverage/cliThe overall coverage in commit 1513342 in the Show a code coverage summary of the most impacted files.
Updated |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@nemoclaw/src/security/snapshot-sanitizer-failure.test.ts`:
- Around line 208-218: Add "AAB=" to the rejected inputs in the test case's
rejection set, preserving the existing cases, so single-padding Base64 with
altered unused bits is verified as rejected alongside the existing "AB=="
coverage.
In `@nemoclaw/src/shared/snapshot-sanitizer-boundary.cts`:
- Line 128: Update the snapshot sanitizer helper boundary around
MAX_SNAPSHOT_FILE_BYTES to validate Base64 canonically: enforce the shared
encoded-length limit before decoding, then re-encode decoded input and reject
values such as AB== and AAB= when the encoding differs from the original. Add
apply-path tests covering both rejected values.
🪄 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: 2e8b4ee9-1f60-4e72-93a4-10b79f2ae241
📒 Files selected for processing (2)
nemoclaw/src/security/snapshot-sanitizer-failure.test.tsnemoclaw/src/shared/snapshot-sanitizer-boundary.cts
PR Review Advisor — No blocking findings reportedAdvisor assessment: No blocking advisor findings reported Model lanes
1 additional E2E selection from the second opinionAdvisory only. The primary lane did not select these E2E jobs or targets.
Second-opinion terminology and E2E selections are advisory. They do not change the primary assessment or E2E / PR Gate. 2 semantic terminology decisionsTerminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.
E2E guidanceAdvisory only. E2E / PR Gate selects and runs jobs independently. Recommended E2E: This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge. |
Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
<!-- markdownlint-disable MD041 --> ## Summary Adds the inert, provider-neutral contract for handing a managed snapshot clone to a replacement workload. The plan binds exact source snapshot authority, destination identity, startup profile, inference routes, messaging state, and provider receipt before any later slice may mutate or publish the clone. This slice intentionally exposes no snapshot-action dependency or production caller. It does not activate clone handling, buildless onboarding, Podman, or any partial runtime support. ## Related Issue Part of #7744 ## Changes - Define immutable clone source, destination, provider receipt, and managed-profile handoff contracts. - Bind clone authority to exact provider, runtime snapshot, source/destination agent, platform, profile, and registry revision. - Add all-agent startup rebind planning for OpenClaw, Hermes, and LangChain Deep Agents Code. - Normalize inference-route and messaging credential/host-forward rebinding without runtime-specific central switches. - Reject stale, mutable, mismatched, cross-agent, malformed, or hostile-provider receipts. - Freeze provider receipts before provider acceptance so callbacks cannot mutate reviewed authority. - Prove the contract remains dormant through the public snapshot action: managed cross-sandbox restore exits before destination deletion, provider creation, clone creation, or state restore. - Document that clone handoff remains deferred to later transactional integration. - Apply the five still-valid CodeRabbit cleanup findings: canonical sandbox-template resolution, cast-free agent narrowing, shared OpenClaw/Hermes config selection, isolated environment stubbing, and a fully typed messaging-plan fixture. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [x] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Quality Gates - [x] Tests added or updated for changed behavior - [ ] Existing tests cover changed behavior — justification: - [ ] Tests not applicable — justification: - [x] Docs updated for user-facing behavior changes - [ ] Docs not applicable — justification: - [x] Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) - [x] Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: Exact-head audit covers immutable provider receipts, source/destination authority, credential and inference rebinding, hostile callback mutation, and dormant production boundaries. - [ ] 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: Reviewed the lifecycle-contract update and exact production-boundary diff at head/base `6b6605b76e60197b2407897fd9a31bfa4134b7e0` / `56b26f173a4a3fbed6af77e01f6f3ddda84b237f`. The append-only restack preserves the managed-clone review thesis while incorporating the merged #8081 sanitizer correction from `main`. The four-file CodeRabbit cleanup uses existing canonical contracts and completes the test fixture's discriminated types; it changes no user-visible support claim. The internal documentation correctly keeps managed clone handoff deferred and dormant, and behavioral public-restore coverage proves managed clone attempts fail closed before destination deletion, provider creation, clone creation, or state restore. No user-visible buildless or Podman support is activated or advertised, so public support documentation remains intentionally unchanged. - Agent: Codex Desktop <!-- docs-review-head-sha: 6b6605b --> <!-- docs-review-agents-blob-sha: 3dd7c24 --> ## DGX Station Hardware Evidence - [ ] Tested on DGX Station - Tested commit: - Station profile/scenario: - Result: - Supporting evidence: ## Verification - Exact validated head/base: `6b6605b76e60197b2407897fd9a31bfa4134b7e0` / `56b26f173a4a3fbed6af77e01f6f3ddda84b237f`. - Review budget: 22 files, `+2,101/-17`. - Stable patch ID: `ca7a91e9d6c5ce1241c0d00d8070113d66916a00`. - [x] All three appended cleanup/restack commits are signed-DCO and GitHub Verified; the exact-head DCO check passes. - [x] The exact-head tree passes 51 focused clone-contract, messaging-parser, channel-state, and public-boundary tests across five files. - [x] The exact-head tree passes all 15 snapshot-sanitizer failure tests, including the maximum-size canonical payload and oversized/malformed no-overflow cases from merged #8081. - [x] `npm run build:cli`, `npm run typecheck:cli`, `npm run checks:repository`, normal pre-push TypeScript/version gates, commitlint, Biome, and `git diff --check` pass. - [x] Behavioral dormancy coverage proves public managed clone restore exits before every destination effect. - [x] Hostile-provider coverage proves receipt mutation after callback entry cannot change reviewed authority. - [x] The exact-head clone-authority test adds zero `if` statements and its 12 cases pass after linearization. - [x] No production clone caller, runtime selection change, Podman switch, or public activation exists. - [x] Applicable broad gate passed — exact-head CI [run 30770174361](https://github.com/NVIDIA/NemoClaw/actions/runs/30770174361), advisor [run 30770173371](https://github.com/NVIDIA/NemoClaw/actions/runs/30770173371) attempt 2 (`merge_as_is`, 0 blockers/warnings/suggestions), CodeRabbit `SUCCESS` with zero unresolved threads, and protected E2E [child run 30770630425](https://github.com/NVIDIA/NemoClaw/actions/runs/30770630425) attempt 1 plus [coordination run 30770608520](https://github.com/NVIDIA/NemoClaw/actions/runs/30770608520) and [observer run 30770187080](https://github.com/NVIDIA/NemoClaw/actions/runs/30770187080) all passed. - Exact-head protected-E2E evidence: [child run 30770630425](https://github.com/NVIDIA/NemoClaw/actions/runs/30770630425) passed all 15 jobs on attempt 1. [Coordination run 30770608520](https://github.com/NVIDIA/NemoClaw/actions/runs/30770608520) verified the evidence, and coordination check `91555901383` bound PR/head/base `8032:6b6605b76e60197b2407897fd9a31bfa4134b7e0:56b26f173a4a3fbed6af77e01f6f3ddda84b237f`; [observer run 30770187080](https://github.com/NVIDIA/NemoClaw/actions/runs/30770187080) passed. - Maintainer disposition: CodeRabbit's generic 8.33% docstring-coverage warning is waived for this slice. TypeScript contracts, focused behavioral tests, and lifecycle documentation carry the behavior; boilerplate docstrings are out of scope. This does not claim that warning passed. ## Risk Plan - Primary risk: treating mutable or mismatched clone authority as valid and rebinding secrets/routes/state to the wrong destination. - Containment: exact immutable authority plus agent, provider, platform, source/destination, registry, profile, inference, and messaging checks fail closed. - Regression risk: accidental eager imports can alter existing snapshot test mocks before activation. A dedicated dormancy assertion and the previously failing snapshot suites prove the seam is absent here. - Rollback: one inert contract slice; no production action imports it. ## Stack - Base: merged PR3.8 #8031 plus merged sanitizer correction #8081; current `main` exact head `56b26f173a4a3fbed6af77e01f6f3ddda84b237f`. - This slice: PR3.9A #8032, branch `feat/managed-clone-handoff-contract`, exact head `6b6605b76e60197b2407897fd9a31bfa4134b7e0`. - Next: PR3.9B #8034 adds the provider transaction/dependency surface while remaining dormant; PR3.9C adds the Hermes-specific broker boundary. - Buildless and Podman support remain disabled until the full all-agent, multiarch, GPU/local-inference, recovery, installer, and protected-E2E gates in #7744 pass. Signed-off-by: Aaron Erickson <aerickson@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added managed workload and startup profile cloning with validation, destination-specific rebinding, and immutable handoff data. * Added messaging-plan rebinding that removes source credentials and adapts provider identities. * Added clone authorization across runtime providers. * Added environment-aware restoration, inference-route resolution, and provider-name validation. * Added Hermes destination inference tracking. * **Bug Fixes** * Prevented unsafe restoration and clone handoffs when validation or authorization fails. * Rejected inconsistent messaging channel disablement settings. * **Tests** * Expanded coverage for cloning, credential isolation, provider rebinding, immutability, and failure scenarios. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Aaron Erickson <aerickson@nvidia.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
<!-- markdownlint-disable MD041 --> ## Summary Adds the canonical dated `v0.0.101` changelog entry that was missing when the release tag was cut. This post-release recovery records the shipped behavior on current `main` without changing or replacing the existing tag. ## Changes - Add `docs/changelog/2026-08-03.mdx` with the exact `## v0.0.101` heading, release summary, detailed behavior changes, support boundaries, and links to durable documentation. - [#7317](#7317) -> `docs/changelog/2026-08-03.mdx`: Records experimental OpenClaw Google Chat support and its restricted credential and webhook boundary. - [#7715](#7715) -> `docs/changelog/2026-08-03.mdx`: Records strict onboarding recovery state and authoritative resume identity. - [#7749](#7749) -> `docs/changelog/2026-08-03.mdx`: Records the provider-neutral policy seam and unchanged runtime support boundary. - [#7817](#7817) -> `docs/changelog/2026-08-03.mdx`: Records preserved Hermes home-channel assignments across rebuilds. - [#7820](#7820) -> `docs/changelog/2026-08-03.mdx`: Records the SSH-session status field correction. - [#7847](#7847) -> `docs/changelog/2026-08-03.mdx`: Records fail-closed credential filtering for migration and rebuild backups. - [#7870](#7870) -> `docs/changelog/2026-08-03.mdx`: Records sandbox-qualified in-sandbox host command hints. - [#7875](#7875) -> `docs/changelog/2026-08-03.mdx`: Records Microsoft Teams stop and start E2E coverage. - [#7885](#7885) -> `docs/changelog/2026-08-03.mdx`: Records Hermes managed gateway detection in status. - [#7889](#7889) -> `docs/changelog/2026-08-03.mdx`: Records policy-authenticated HTTPS Pin Runtime route revocation. - [#7891](#7891) -> `docs/changelog/2026-08-03.mdx`: Records default fallback for negative timeout and polling overrides. - [#7993](#7993) -> `docs/changelog/2026-08-03.mdx`: Records correct sibling detection during uninstall. - [#7995](#7995) -> `docs/changelog/2026-08-03.mdx`: Records absent configuration-hash handling before shields lock. - [#8001](#8001) -> `docs/changelog/2026-08-03.mdx`: Records the dormant atomic managed workload replacement foundation. - [#8029](#8029) -> `docs/changelog/2026-08-03.mdx`: Records repository terminology review in PR Review Advisor. - [#8031](#8031) -> `docs/changelog/2026-08-03.mdx`: Records provider-neutral managed snapshot authority. - [#8032](#8032) -> `docs/changelog/2026-08-03.mdx`: Records immutable managed clone handoff contracts. - [#8034](#8034) -> `docs/changelog/2026-08-03.mdx`: Records the dormant provider-owned clone transaction surface. - [#8035](#8035) -> `docs/changelog/2026-08-03.mdx`: Records the dormant Hermes managed clone broker boundary. - [#8036](#8036) -> `docs/changelog/2026-08-03.mdx`: Records the dormant transactional managed bootstrap boundary. - [#8037](#8037) -> `docs/changelog/2026-08-03.mdx`: Records dormant Docker bootstrap primitives and the unchanged provider support boundary. - [#8070](#8070) -> `docs/changelog/2026-08-03.mdx`: Records consolidated sandbox resource-limit E2E coverage. - [#8071](#8071) -> `docs/changelog/2026-08-03.mdx`: Records escaped and bounded CLI validation diagnostics. - [#8081](#8081) -> `docs/changelog/2026-08-03.mdx`: Records bounded linear snapshot Base64 validation. - [#8085](#8085) -> `docs/changelog/2026-08-03.mdx`: Records commit-bound workflow approval for eligible same-repository maintainers. - [#8088](#8088) -> `docs/changelog/2026-08-03.mdx`: Records Hermes managed-policy E2E selection. - [#8090](#8090) -> `docs/changelog/2026-08-03.mdx`: Records pinned CI search-tool provisioning. - [#8106](#8106) -> `docs/changelog/2026-08-03.mdx`: Records fallback from failed managed OpenShell gateway startup. - [#8107](#8107) -> `docs/changelog/2026-08-03.mdx`: Records Hermes adapter lifecycle E2E selection. - [#8128](#8128) -> `docs/changelog/2026-08-03.mdx`: Records the dormant transactional Docker bootstrap adapter and rollback authority. - [#8140](#8140) -> `docs/changelog/2026-08-03.mdx`: Records Slack conflict scope across independent OpenShell gateways. - [#8147](#8147) -> `docs/changelog/2026-08-03.mdx`: Records completion of durable v0.0.100 documentation audit follow-ups. ## 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 - [ ] Existing tests cover changed behavior — justification: - [x] Tests not applicable — justification: This documentation-only recovery does not change executable behavior. - [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: Independently reviewed `docs/changelog/2026-08-03.mdx` at commit `0bebe1f568e3dc85cf410aac1dfb8f8830070b85`. Its blob is `82887920f9720eafd75db6b2271c35f7477edb9b`. The entry follows the writing guide, controlled terminology, changelog structure, MDX SPDX format, literal CLI-name rule, and root-absolute route requirements. It accurately records the `v0.0.100...v0.0.101` release range, Announcement #8162, accepted scope boundaries, and shipped security behavior. There are no code samples. Focused changelog tests and the documentation build pass for this commit. - Agent: Codex Desktop independent documentation writer <!-- docs-review-head-sha: 0bebe1f --> <!-- docs-review-agents-blob-sha: 3dd7c24 --> ## Security Review - Result: `PASS` - Reviewed commit: `0bebe1f568e3dc85cf410aac1dfb8f8830070b85` - Base commit: `643a4ab8b5f583d8555192a37927268b26022c51` - Findings: None. - Secrets and credentials: `PASS`. No credential values or secret files are present. - Input validation and data sanitization: `PASS`. No executable input path changes. - Authentication and authorization: `PASS`. No identity or permission logic changes. - Dependencies and third-party libraries: `PASS`. No dependency changes. - Error handling and logging: `PASS`. No runtime path changes; diagnostic-security claims are precise. - Cryptography and data protection: `PASS`. No implementation changes. - Configuration and security controls: `PASS`. No configuration, container, port, or HTTP changes. - Security testing: `PASS`. No coverage is removed; the entry records shipped test and security behavior. - System security: `PASS`. No runtime control changes; dormant and non-activation boundaries are explicit. - Agent: Codex Desktop independent security reviewer ## Verification - [ ] PR description includes a `Signed-off-by:` line and every commit appears as `Verified` in GitHub — verification is pending after commit `0bebe1f568e3dc85cf410aac1dfb8f8830070b85` is pushed. - [ ] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or `npm run validate:pr` passed after refreshing `origin/main` when hooks were skipped or unavailable — commit hooks passed; pre-push is pending. - [x] Targeted behavior tests pass for the current change set, or tests are marked not applicable above — tests are not applicable to this documentation-only recovery. - [x] Applicable broad gate passed — not applicable to this documentation-only recovery. - [x] Quality Gates section completed with required justifications or waivers - [x] No secrets, API keys, credentials, or private keys are added by this diff. - [ ] `npm run docs` builds without warnings (doc changes only) — GitHub documentation checks are pending. - [x] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) — independent documentation review passed. - [x] New doc pages include SPDX header and frontmatter (new pages only) — the native changelog entry uses the required parser-safe MDX SPDX comment and intentionally has no frontmatter. GitHub CI is authoritative. Focused changelog tests and `npm run docs` passed after the merge refresh. --- Signed-off-by: Apurv Kumaria <akumaria@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added experimental Google Chat support. * Improved runtime and session status visibility. * Added onboarding recovery and persistence safeguards. * Added snapshot validation and dormant managed-workload support. * **Bug Fixes** * Improved backup sanitization, route handling, and gateway reliability. * **Documentation** * Added the v0.0.101 changelog and related updates. * **Tests** * Expanded end-to-end coverage and strengthened trusted CI validation. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Apurv Kumaria <akumaria@nvidia.com> Signed-off-by: Carlos Villela <cvillela@nvidia.com> Co-authored-by: Carlos Villela <cvillela@nvidia.com> Co-authored-by: Senthil Ravichandran <senthilr@nvidia.com>
Summary
Replace the snapshot helper payload regex with a bounded linear validator. Maximum-size canonical payloads now decode without a JavaScript stack overflow, while malformed, oversized, non-canonical, and invalid UTF-8 payloads continue to fail closed.
Related Issue
Relates #7744.
Changes
Type of Change
Quality Gates
19cfe1a7626c; CodeRabbit and both exact-head advisors report no blockers after the successful Nemotron rerun, and the consolidated advisor result remainsmerge_as_is: fix(security): validate snapshot base64 linearly #8081 (comment)Documentation Writer Review
no-docs-needed19cfe1a7626c(stable patch IDbd5b516ceb88ee3dd01c4df6da694af4f90c2e89), touches only the snapshot-sanitizer test and isolated apply-boundary implementation, and preserves the reviewedAGENTS.mdblob. No user-facing interface or documented behavior changes.DGX Station Hardware Evidence
Verification
Signed-off-by:line and every commit appears asVerifiedin GitHubpre-commit,commit-msg, andpre-pushhooks passed, ornpm run validate:prpassed after refreshingorigin/mainwhen hooks were skipped or unavailable1513342a9d75preserves the reviewed parent-relative patch byte-for-byte.rebuild-openclawandstate-backup-restorein child run https://github.com/NVIDIA/NemoClaw/actions/runs/30765186285.npm run docsbuilds without warnings (doc changes only)Signed-off-by: Aaron Erickson aerickson@nvidia.com
Summary by CodeRabbit
Bug Fixes
Tests