Repository navigation
fix(security): keep dependency trees out of the backup credential scan - #8807
Conversation
The rebuild backup sanitizer scans every copied JSON, YAML, and .env file, including the lockfile and installed tree of the Hermes WhatsApp bridge, which ships under a state directory. Two results follow, and together they stop the bridge from starting again. Package names are object keys in a lockfile and in an installed package manifest, so the credential key matcher reads `cookie`, `js-tokens`, and `path-key` as secrets and replaces the versions they resolve to. Separately, `sanitizeConfigFileContent` re-emitted every parsed document through `JSON.stringify`, so a credential-free file changed bytes anyway. On the bridge manifest the only difference was the trailing newline, 451 bytes to 450, with no redaction marker in the file. Hermes hashes that manifest to decide whether its dependencies are current, so the hash stopped matching and it ran `npm install` against the lockfile the same pass had rewritten. The install fails with EINVALIDTAGNAME, the adapter never spawns the bridge, and state carries the broken lockfile into every later restore. Skip dependency lockfiles and any path under `node_modules`, after the existing sensitive-basename removal so a credential file inside a dependency tree is still deleted. Reuse the lockfile set that `shouldScanSnapshotFileForCredentials` already excludes for this reason. Return a credential-free document byte for byte, comparing against the document as parsed so dropping the `gateway` section still counts as a change. Two of the new tests assert that an agent configuration still loses a credential header and that a sensitive basename inside a dependency tree is still removed, so the exclusion cannot widen into a disabled scan. Both byte-identity cases carry a source-shape contract exception. The defect is a byte change in a document the scan did not redact, and the consumer hashes those exact bytes, so unmodified content is the behavior under test rather than a stand-in for one. Document the exemption on the backup page, and tell an operator whose sandbox was rebuilt on an affected release to destroy and onboard again, since a rebuild restores the tree it backed up. Signed-off-by: Hung Le <[email protected]>
|
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. |
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughSnapshot sanitization now preserves clean dependency lockfiles and installed package manifests byte for byte. It removes dependency artifacts that contain credentials while continuing to sanitize configuration and environment files. Tests and documentation cover the behavior and Hermes recovery. ChangesSandbox backup sanitization
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant SnapshotScanner
participant actionForScannedFile
participant DependencyDetectors
SnapshotScanner->>actionForScannedFile: Scan dependency artifact
actionForScannedFile->>DependencyDetectors: Inspect lockfile or package manifest
DependencyDetectors-->>actionForScannedFile: Return credential status
actionForScannedFile-->>SnapshotScanner: Remove sensitive artifact or preserve clean artifact
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Code Coverage OverviewLanguages: TypeScript TypeScript / code-coverage/pluginThe overall coverage in commit 8932ff9 in the TypeScript / code-coverage/cliThe overall coverage in commit 8932ff9 in the Show a code coverage summary of the most impacted files.
Updated |
PR Review Advisor — No blocking findings reportedAdvisor assessment: No blocking advisor findings reported Model lanes
4 terminology differences from the second opinionAdvisory only. These are normalized differences from the primary terminology receipt.
4 additional E2E selections from the second opinionAdvisory only. The primary lane did not select these E2E jobs or targets.
Second-opinion terminology and E2E selections are advisory. Live E2E does not run automatically for pull requests. 3 semantic terminology decisionsTerminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.
E2E guidanceAdvisory only. A maintainer can dispatch the default E2E suite for the commit under review. Recommended E2E: None Manual-only E2E: 1 optional E2E recommendation
1 warning · 0 suggestionsWarningsWarnings do not block.
|
Signed-off-by: Apurv Kumaria <[email protected]>
|
Security review completed for the latest PR commit ( The reported credential-leak path is resolved:
The nine-category review found no remaining actionable issue in the changed scope. Descriptor-relative path handling, race detection, sensitive-basename removal, fail-closed behavior, credential placeholder handling, network behavior, dependency inputs, logging, and authorization boundaries remain unchanged. The change adds no dependency, privilege, network route, secret source, or fallback. Validation passed:
The PR remains draft while its stated live WhatsApp rebuild E2E evidence is still absent. This review does not waive that remaining gate. |
prekshivyas
left a comment
There was a problem hiding this comment.
Draft review found two blocking issues on latest PR commit d3f910a29.
isDependencyLockfileomits npm's installednode_modules/.package-lock.json, so backup sanitization can still rewrite credential-shaped dependency metadata in that file.- The filename-only lockfile exemption returns before credential sanitization. A recognized lockfile containing an actual token, credential field, or credential-bearing URL is copied into the snapshot unchanged.
Please preserve benign dependency metadata without exempting real credentials. Add byte-preservation coverage for benign .package-lock.json and fail-closed coverage for credentials in recognized lockfiles. The current failing CLI/check suite also has to be cleared before this draft can become reviewable for approval.
Signed-off-by: Apurv Kumaria <[email protected]>
Signed-off-by: Apurv Kumaria <[email protected]>
Signed-off-by: Apurv Kumaria <[email protected]>
|
Security review update for revision 8a633d8: pass, with no remaining actionable findings. I reviewed authentication and authorization, credential handling, input and serialization boundaries, command execution, network and SSRF exposure, filesystem and race behavior, dependencies and supply chain, logging and privacy, and fail-closed defaults. The repair preserves benign recognized dependency lockfiles byte for byte, but removes lockfiles that contain credential fields, provider-shaped secrets outside dependency URLs, URL user information, or credential-bearing query parameters. Only installed node_modules package manifests bypass ordinary configuration sanitization; sensitive basenames are checked first, while configuration and environment files remain sanitized. Evidence: 48 focused tests, CLI type-checking, repository hooks, source and test budgets, secret scanning, and the documentation build passed. The documentation build reported 0 errors and 2 existing warnings. All three new commits are signed, DCO-compliant, and Verified on GitHub. This draft still needs its fresh CI wave to pass and repository-routed review before it is ready. |
prekshivyas
left a comment
There was a problem hiding this comment.
Blocking credential-boundary finding on latest PR commit 8a633d8b0.
In src/lib/security/snapshot-sanitizer.ts:132-134, every installed node_modules/**/package.json returns before config sanitization. That fixes false positives from dependency-name keys, but it also preserves real credential fields and values in the same untrusted manifest—for example token, _auth, a credential-bearing registry URL, or a token-shaped value. Package manifests are third-party JSON and may also be modified at runtime, so the backup credential boundary cannot exempt the whole file. The current tests cover benign dependency names but not a credential-bearing installed manifest.
Please use manifest-aware traversal that exempts dependency-map keys while still detecting/removing actual credential fields, values, and credential-bearing URLs, and add that regression case. The narrower lockfile inspection in this change is a useful model.
Security rubric: 1 FAIL (real credentials can remain in a snapshot); 2 FAIL (the file-level exemption is broader than the validated field); 3 PASS (no auth change); 4 PASS (no dependency added); 5 PASS (other sanitizer failures remain fail closed); 6 PASS (no cryptography change); 7 PASS (no deployed config change); 8 FAIL (missing credential-bearing manifest regression); 9 FAIL (the early return bypasses the authoritative sanitizer). Files reviewed: the complete 6-file diff.
Signed-off-by: Apurv Kumaria <[email protected]>
|
Security follow-up for revision The installed package-manifest exemption is now dependency-aware. Dependency-map names remain unchanged, while credential fields, npm authentication fields, credential-bearing URLs, provider-shaped secrets, and invalid JSON cause the manifest to be omitted from the snapshot. Validation passed:
Nine-category review disposition: credentials PASS; input validation PASS; authentication and authorization PASS; dependency handling PASS; availability and fail-closed behavior PASS; cryptography PASS; secure defaults PASS; test coverage PASS; control-flow integrity PASS. No actionable security finding remains in the reviewed change. Fresh repository checks are running, and the existing requested-changes decision remains for reviewer resolution. |
The latest PR commit preserves dependency-map names while removing credential-bearing manifests and invalid JSON. Dismissing this resolved review before a full current-commit review.
|
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. |
There was a problem hiding this comment.
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 `@docs/manage-sandboxes/backup-restore.mdx`:
- Around line 52-57: Update the omission sentence in the lockfile sanitization
documentation to include invalid lockfiles as an additional omission condition,
alongside the existing unsafe-value conditions. Preserve the current wording and
list structure while explicitly documenting that dependency lockfiles with
invalid content are removed.
🪄 Autofix
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: 92a702ea-b0c3-4170-b9fc-728ec259dc79
📒 Files selected for processing (6)
ci/source-shape-test-budget.jsondocs/manage-sandboxes/backup-restore.mdxsrc/lib/security/credential-filter.test.tssrc/lib/security/credential-filter.tssrc/lib/security/snapshot-sanitizer.tssrc/lib/state/sandbox-backup-sanitization.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- src/lib/security/credential-filter.test.ts
- ci/source-shape-test-budget.json
- src/lib/security/credential-filter.ts
- src/lib/state/sandbox-backup-sanitization.test.ts
- src/lib/security/snapshot-sanitizer.ts
cv
left a comment
There was a problem hiding this comment.
src/lib/security/snapshot-sanitizer.ts:87-96 and :139-142: when both JSON and YAML parsing fail, dependencyLockfileContainsCredential returns false, so actionForScannedFile preserves the recognized lockfile as credential-free. A malformed lockfile can therefore retain an opaque credential in a completed snapshot and restore it into a sandbox. Return a fail-closed removal result when neither parser can inspect the lockfile, document that invalid recognized lockfiles are omitted, and add a regression in src/lib/state/sandbox-backup-sanitization.test.ts. The current cases at lines 116-134 cover only parseable credential-bearing lockfiles. A read-only probe with malformed {"token":"123456789" confirmed that both parsers reject the input while the coarse secret patterns do not detect it.
Signed-off-by: Apurv Kumaria <[email protected]>
|
Addressed the current malformed-lockfile security change request.
Validation:
Fresh checks and human re-review are pending. Reviewer routing was not changed. |
Signed-off-by: Apurv Kumaria <[email protected]>
|
Addressed the automated review warning about parser fallback: JSON lockfiles are now inspected only as JSON, while YAML lockfiles retain YAML parsing. A malformed JSON lockfile can no longer be preserved merely because a YAML parser accepts its syntax. Added regression coverage for rejecting a trailing-comma package lock and preserving a credential-free pnpm lockfile byte for byte. The focused security and backup suites pass (56 tests), CLI type-checking and repository hooks pass, and the documentation follow-up confirmed the existing invalid-lockfile guidance remains accurate. Security review found no new concerns; this tightens the existing fail-closed behavior. |
|
CI classification: shard 3 failed in unchanged container-layout coverage while a cold runner was still pulling the pinned sandbox image. The PR-related security suites, static checks, CodeQL, both self-hosted image builds, and all four self-hosted E2E jobs passed. I classified this as infrastructure-related and used the single permitted transient retry for the failed shard. No code change was made for this signal. |
|
Change-request disposition The requested fail-closed behavior is present in the current branch revision:
Focused validation passed 56 sanitizer and credential-filter tests. The two follow-up commits are signed off and shown as Verified by GitHub, and all current hosted checks pass. The security delta remains fail closed and does not expand the snapshot trust boundary. Repository-owned maintainer re-review remains required; I did not change reviewer routing. |
There was a problem hiding this comment.
Security review: PASS. I reviewed authentication and authorization boundaries, input validation and injection, secrets handling, sandbox and isolation boundaries, network exposure and SSRF, supply-chain changes, filesystem safety, resource limits and denial of service, and logging and information disclosure. The reviewed commit fails closed for malformed dependency artifacts, limits dependency exemptions to dependency maps, uses descriptor-safe mutation, removes incomplete backups on sanitization failure, and sanitizes before publication. No blocking findings remain. The malformed-YAML coverage suggestion is nonblocking because invalid lockfile parsing already exercises the fail-closed branch.
Summary
Rebuild backups previously rewrote package names and versions in the Hermes WhatsApp bridge, then changed credential-free manifest bytes. That combination caused a later dependency install to fail. The sanitizer now preserves credential-free dependency lockfiles and installed package manifests while continuing to sanitize configuration and
.envfiles inside dependency trees.Related Issue
Fixes #8808
Changes
node_modulesfor configuration and.envfiles..envredaction.The shared
isDependencyLockfileexport keeps the sanitizer and snapshot leak checks on one lockfile list. The change adds no configuration, dependency, privilege, network route, secret source, fallback, or compatibility path.Type of Change
Quality Gates
Documentation Writer Review
docs-updateddocs/manage-sandboxes/backup-restore.mdxdescribes byte preservation for credential-free dependency artifacts, the installed-manifest fail-closed conditions, continued configuration and.envsanitization, and the Hermes recovery procedure. The generated OpenClaw, Hermes, and Deep Agents Code variants are current.DGX Station Hardware Evidence
scripts/prepare-dgx-station-host.shis unchanged.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 unavailablenpm testfor broad runtime/test-harness changes;npm run checkfor repo-wide validation/coverage changes — command/result:npm run docsbuilds without warnings (doc changes only) — 0 errors and 2 pre-existing warnings.Contributor evidence
On a clean Hermes WhatsApp sandbox, the contributor's rebuild probe showed that the fix preserved the 451-byte bridge manifest, kept the lockfile's
cookieversion, and added no redaction marker to dependency artifacts. Reverting the fix changed the manifest to 450 bytes and rewrote 13 dependency JSON or YAML artifacts. Restoring the fix did not repair the already-corrupted tree, which is why the documentation directs affected operators to destroy the sandbox and onboard again.Live evidence disposition
The contributor’s clean-sandbox rebuild probe exercised the affected WhatsApp dependency tree and confirmed manifest and lockfile byte preservation. The focused tests cover the credential-bearing and malformed-manifest paths, and this correction adds no runtime, privilege, or network behavior. This evidence satisfies the release gate without another live test.
Change size
This is a substantial change: 6 files, 350 additions, and 3 deletions. The increase is flagged because it expands credential-boundary tests and documentation.
Signed-off-by: Hung Le [email protected]
Signed-off-by: Apurv Kumaria [email protected]
Summary by CodeRabbit