Skip to content

fix(security): keep dependency trees out of the backup credential scan - #8807

Merged
apurvvkumaria merged 10 commits into
mainfrom
fix/backup-sanitizer-dependency-tree
Aug 13, 2026
Merged

apurvvkumaria merged 10 commits into
mainfrom
fix/backup-sanitizer-dependency-tree

Conversation

@hunglp6d

@hunglp6d hunglp6d commented Aug 11, 2026 •

Copy link
Copy Markdown
Collaborator

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 .env files inside dependency trees.

Related Issue

Fixes #8808

Changes

  • Preserve credential-free dependency lockfiles and installed package.json manifests so credential-shaped package names do not become redaction markers. Remove recognized lockfiles and installed manifests that contain credentials.
  • Return credential-free JSON documents byte for byte when sanitization makes no semantic change.
  • Keep sensitive-basename removal and credential sanitization active below node_modules for configuration and .env files.
  • Add regression coverage for lockfile and manifest integrity, agent configuration redaction, sensitive-file removal, dependency configuration redaction, and dependency .env redaction.
  • Document the exemption and the recovery procedure for an already-corrupted Hermes WhatsApp sandbox.

The shared isDependencyLockfile export 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

  • 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:
  • 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: The nine-category maintainer review found no remaining actionable security issue after narrowing the installed-manifest exemption and adding fail-closed regression coverage: fix(security): keep dependency trees out of the backup credential scan #8807 (comment)
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Documentation Writer Review

  • Documentation writer subagent reviewed the completed changes
  • Result: docs-updated
  • Evidence: docs/manage-sandboxes/backup-restore.mdx describes byte preservation for credential-free dependency artifacts, the installed-manifest fail-closed conditions, continued configuration and .env sanitization, and the Hermes recovery procedure. The generated OpenClaw, Hermes, and Deep Agents Code variants are current.
  • Agent: Codex Desktop

DGX Station Hardware Evidence

  • Tested on DGX Station
  • Tested commit: Not applicable; scripts/prepare-dgx-station-host.sh is unchanged.
  • Station profile/scenario: Not applicable.
  • Result: Not applicable.
  • Supporting evidence: Not applicable.

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 validate:pr passed after refreshing origin/main when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result: The contributor suite passed 259 tests across 10 files. The maintainer correction passed 53 focused tests, CLI type-checking, documentation validation, repository hooks, source/test budgets, and secret scanning.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result:
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only) — 0 errors and 2 pre-existing warnings.
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

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 cookie version, 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

  • Bug Fixes
    • Improved sandbox backup sanitization to preserve clean dependency lockfiles and installed package manifests byte for byte.
    • Removed lockfiles and malformed manifests containing credentials or other sensitive values.
    • Continued sanitizing configuration and environment files within dependency folders.
    • Preserved credential-shaped dependency names when they are not actual credentials.
  • Documentation
    • Added guidance for repairing sandboxes affected by a previous dependency-file corruption issue.

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]>
@copy-pr-bot

copy-pr-bot Bot commented Aug 11, 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 Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Review 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: c0d12469-709a-4343-8145-7be9d8459500

📥 Commits

Reviewing files that changed from the base of the PR and between 26c57ba and 8932ff9.

📒 Files selected for processing (2)
  • src/lib/security/snapshot-sanitizer.ts
  • src/lib/state/sandbox-backup-sanitization.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib/state/sandbox-backup-sanitization.test.ts

📝 Walkthrough

Walkthrough

Snapshot 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.

Changes

Sandbox backup sanitization

Layer / File(s) Summary
Sanitization contracts
src/lib/security/credential-filter.ts, src/lib/security/credential-filter.test.ts
Adds isDependencyLockfile, recognizes .package-lock.json, and preserves unchanged JSON bytes.
Dependency artifact scanning
src/lib/security/snapshot-sanitizer.ts
Detects credentials in dependency lockfiles and installed package manifests. Removes affected artifacts and preserves clean artifacts.
Regression coverage and recovery guidance
src/lib/state/sandbox-backup-sanitization.test.ts, docs/manage-sandboxes/backup-restore.mdx, ci/source-shape-test-budget.json
Tests dependency artifact preservation and existing sanitization behavior. Documents snapshot behavior and Hermes recovery steps. Adds security contract exceptions for the new tests.

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
Loading

Suggested reviewers: cv, apurvvkumaria

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. 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 clearly summarizes the primary security fix: excluding dependency trees from backup credential scanning.
Linked Issues check ✅ Passed The changes address issue #8808 by preserving clean dependency artifacts byte for byte and removing invalid or credential-bearing files.
Out of Scope Changes check ✅ Passed The source changes, regression tests, and recovery documentation directly support the requirements in issue #8808.
✨ 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 fix/backup-sanitizer-dependency-tree

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

@github-code-quality

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

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit 8932ff9 in the fix/backup-sanitizer... branch remains at 96%, unchanged from commit 7c721ae in the main branch.

TypeScript / code-coverage/cli

The overall coverage in commit 8932ff9 in the fix/backup-sanitizer... branch remains at 82%, unchanged from commit 7c721ae in the main branch.

Show a code coverage summary of the most impacted files.
File main 7c721ae fix/backup-sanitizer... 8932ff9 +/-
src/lib/inferen...ollama/proxy.ts 36% 33% -3%
src/lib/securit...ot-sanitizer.ts 97% 94% -3%
src/lib/securit...ntial-filter.ts 91% 89% -2%
src/lib/adapter...ateway-drift.ts 61% 60% -1%
src/lib/credentials/store.ts 57% 57% 0%
src/lib/onboard...eway-process.ts 90% 90% 0%
src/lib/state/config-io.ts 93% 95% +2%
src/lib/messagi...annel-config.ts 95% 99% +4%
src/lib/actions...ence-gateway.ts 82% 91% +9%
src/lib/actions...ocker-health.ts 61% 78% +17%

Updated August 12, 2026 21:28 UTC

@github-actions

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings reported

Advisor assessment: No blocking advisor findings reported
Next action: Review the warnings below.
Findings: 0 blockers · 1 warning · 0 suggestions

Model lanes

  • GPT-5.6 Terra (primary): Completed · high confidence · 0 blockers · 1 warning · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Model comparison: normalized findings differ; normalized terminology decisions differ; normalized E2E selections differ; Nemotron reported the same number of blockers, 1 fewer warning, the same number of suggestions.
4 terminology differences from the second opinion

Advisory only. These are normalized differences from the primary terminology receipt.

  • dependency lockfile at docs/manage-sandboxes/backup-restore.mdx:50: primary classified it as established; the second opinion classified it as justified.
  • installed package manifest at docs/manage-sandboxes/backup-restore.mdx:61: primary classified it as established; the second opinion classified it as justified.
  • byte for byte at docs/manage-sandboxes/backup-restore.mdx:50: selected only by the second-opinion lane as established.
  • dependency-tree at docs/manage-sandboxes/backup-restore.mdx:62: selected only by the second-opinion lane as established.
4 additional E2E selections from the second opinion

Advisory only. The primary lane did not select these E2E jobs or targets.

  • rebuild-hermes-stale-base: The completed second-opinion lane identified E2E coverage that the primary lane omitted.
  • snapshot-commands: The completed second-opinion lane identified E2E coverage that the primary lane omitted.
  • onboard-repair: The completed second-opinion lane identified E2E coverage that the primary lane omitted.
  • whatsapp-qr-compact: The completed second-opinion lane identified E2E coverage that the primary lane omitted.

Second-opinion terminology and E2E selections are advisory. Live E2E does not run automatically for pull requests.

3 semantic terminology decisions

Terminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.

  • established — credential-free at docs/manage-sandboxes/backup-restore.mdx:60: Keep `credential-free` for inspected dependency artifacts that contain no credential material.
  • established — dependency lockfile at docs/manage-sandboxes/backup-restore.mdx:50: Keep `dependency lockfile` for the recognized dependency metadata files.
  • established — installed package manifest at docs/manage-sandboxes/backup-restore.mdx:61: Keep `installed package manifest` for `package.json` files in installed dependency trees.

E2E guidance

Advisory only. A maintainer can dispatch the default E2E suite for the commit under review.

Recommended E2E: None

Manual-only E2E: cloud-inference, security-posture, rebuild-openclaw, state-backup-restore
The manual PR workflow does not run these selectors for the commit under review. Run them from reviewed code on main.

1 optional E2E recommendation
  • rebuild-hermes
1 warning · 0 suggestions

Warnings

Warnings do not block.

PRA-1 Warning — Add malformed YAML lockfile coverage

  • Location: src/lib/state/sandbox-backup-sanitization.test.ts:156
  • Category: tests
  • Problem: The changed tests preserve a valid `pnpm-lock.yaml` but do not cover the fail-closed path for malformed YAML lockfiles.
  • Impact: A future parser or classifier change can preserve malformed YAML lockfile content in a snapshot without a focused regression test.
  • Recommendation: Add a backup-sanitization test that writes malformed YAML to `pnpm-lock.yaml` and verifies that the sanitizer removes the file.
  • Verification: Inspect the new test with `dependencyLockfileContainsCredential` to confirm malformed YAML reaches the parser-failure removal branch.
  • Test coverage: A `pnpm-lock.yaml` fixture with malformed YAML is removed by `sanitizeBackupDirectory`.
  • Evidence: `src/lib/security/snapshot-sanitizer.ts:91-103` treats a parser failure as a credential condition and removes the recognized lockfile. `src/lib/state/sandbox-backup-sanitization.test.ts:143-153` covers JSON syntax that YAML accepts. `src/lib/state/sandbox-backup-sanitization.test.ts:156-166` covers only a valid `pnpm-lock.yaml`.

Workflow run details

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

@apurvvkumaria

Copy link
Copy Markdown
Collaborator

Security review completed for the latest PR commit (a9b7282803).

The reported credential-leak path is resolved:

  • Snapshot sanitization no longer exempts every file below node_modules.
  • Only dependency lockfiles and installed package.json manifests bypass credential rewriting, which preserves package names and versions needed for restore.
  • JSON configuration and .env files inside dependency trees continue through credential sanitization. New tests cover both cases and verify redaction plus restrictive file modes.

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:

  • 259 focused tests across 10 files
  • CLI build and typecheck
  • source-shape and test-size budgets
  • documentation build with 0 errors and 2 pre-existing warnings
  • formatting, lint, repository checks, and secret scanning

The PR remains draft while its stated live WhatsApp rebuild E2E evidence is still absent. This review does not waive that remaining gate.

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

Draft review found two blocking issues on latest PR commit d3f910a29.

  1. isDependencyLockfile omits npm's installed node_modules/.package-lock.json, so backup sanitization can still rewrite credential-shaped dependency metadata in that file.
  2. 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.

@apurvvkumaria

Copy link
Copy Markdown
Collaborator

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.

@wscurran wscurran added 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 integration: hermes Hermes integration behavior labels Aug 12, 2026
@hunglp6d
hunglp6d marked this pull request as ready for review August 12, 2026 02:45

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

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.

@apurvvkumaria

Copy link
Copy Markdown
Collaborator

Security follow-up for revision 8f563e302:

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:

  • 53 focused sanitizer and credential-filter tests.
  • CLI type-checking.
  • Documentation build with 0 errors and the 2 existing Fern notices.
  • Applicable repository hooks, source/test budgets, and secret scanning.

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.

@cv
cv dismissed prekshivyas’s stale review August 12, 2026 17:39

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.

@coderabbitai

coderabbitai Bot commented Aug 12, 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.

@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 `@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

📥 Commits

Reviewing files that changed from the base of the PR and between f712516 and 417ffad.

📒 Files selected for processing (6)
  • ci/source-shape-test-budget.json
  • docs/manage-sandboxes/backup-restore.mdx
  • src/lib/security/credential-filter.test.ts
  • src/lib/security/credential-filter.ts
  • src/lib/security/snapshot-sanitizer.ts
  • src/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 cv 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.

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.

@apurvvkumaria

Copy link
Copy Markdown
Collaborator

Addressed the current malformed-lockfile security change request.

  • A recognized dependency lockfile that cannot be parsed as JSON or YAML now fails closed and is removed from the snapshot.
  • Added a regression for an opaque credential in malformed package-lock.json content.
  • Updated snapshot documentation to state that invalid recognized lockfiles are omitted.

Validation:

  • focused credential-boundary suites: 54 tests passed
  • documentation and repository hooks passed
  • documentation validation: 0 errors; two notices report Fern upgrade availability
  • documentation writer review: documentation updated, no remaining documentation blocker
  • security review of the remediation passes the credential-boundary, fail-closed, test-coverage, and centralized-sanitizer requirements
  • latest pushed commit is Verified and retains its DCO sign-off

Fresh checks and human re-review are pending. Reviewer routing was not changed.

@apurvvkumaria

Copy link
Copy Markdown
Collaborator

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.

@apurvvkumaria

Copy link
Copy Markdown
Collaborator

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.

@apurvvkumaria

Copy link
Copy Markdown
Collaborator

Change-request disposition

The requested fail-closed behavior is present in the current branch revision:

  • A recognized lockfile is removed when its format-specific parser rejects the content.
  • JSON lockfiles are inspected only as JSON, so invalid JSON is not accepted through the YAML parser.
  • Regression coverage removes both an opaque malformed lockfile and JSON syntax that YAML would otherwise accept, while preserving a valid credential-free YAML lockfile byte for byte.
  • The backup and restore guide states that invalid recognized lockfiles are omitted.

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.

@apurvvkumaria
apurvvkumaria enabled auto-merge (squash) August 13, 2026 03:48

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

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.

@apurvvkumaria
apurvvkumaria merged commit b4b34c5 into main Aug 13, 2026
88 of 94 checks passed
@apurvvkumaria
apurvvkumaria deleted the fix/backup-sanitizer-dependency-tree branch August 13, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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 integration: hermes Hermes integration behavior

Projects

None yet

5 participants