fix(migrate): harden importer path resolution and memory copy safety#109314
Merged
Conversation
Contributor
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
An adversarial deep review (four independent passes) of the memory-migration importers surfaced confirmed path-resolution and copy-safety bugs, two of them privacy/security issues that leak files outside the intended source tree into indexed agent memory:
autoMemoryDirectory: "~"imported the entire home directory. Validation exempted bare~, which expands toos.homedir(); every Markdown file under home (up to scan caps) was copied into indexed memory. Claude Code's own contract only permits absolute or~/-prefixed values.~/.ssh/id_rsa) was copied verbatim into memory.HERMES_HOMEset to the root ignored the active profile, importing the default profile's memory instead of the selected one.CODEX_HOME(andCLAUDE_CONFIG_DIR) were trimmed, resolving a different directory than the tools themselves use for space-bearing paths.Why This Change Was Made
Each fix mirrors the upstream tool's own contract, verified against source:
~for Claude auto-memory; require absolute or~/.copyMemoryMigrationFileItem) now reads the source through an fs-safe root withhardlinks: "reject"+symlinks: "reject", matching the destination guard.HERMES_HOMEnames the root, and trusts it verbatim only when it already namesprofiles/<name>— exactly Hermes's own heuristic (hermes_cli/main.py:461-473, issue fix(errors): distinguish process termination from billing errors #22502), including theHERMES_S6_SUPERVISED_CHILDdefault-slot exception.CODEX_HOMEandCLAUDE_CONFIG_DIRare preserved verbatim (only empty = unset), matching upstream (codex-rs/utils/home-dir/src/lib.rs:14-49).lstat; non-regular targets surface as conflicts during planning across Codex, Claude, and Hermes.CLAUDE_CONFIG_DIR; explicit--fromclassification stays on unambiguous signals (.claudebasename / configured default) to avoid misreading ordinary repos.User Impact
Importing your own memory behaves the same on the happy path (proven live below); malformed or hostile source layouts now fail closed instead of copying unintended files into indexed memory, and Hermes/Codex users on named profiles or relocated homes import the correct source.
Evidence
node scripts/run-vitest.mjs extensions/migrate-claude extensions/migrate-hermes extensions/codex/src/migration src/plugin-sdk/migration-runtime.test.ts src/gateway/server-methods/migrations.test.ts(incl. new regression tests per fix; ~230 tests).autoMemoryDirectory: "~"made Claude detection fail closed with no home-tree scan. Ground-truth grep of the workspace: no leaked bytes.../codex/codex-rs/utils/home-dir/src/lib.rs,../hermes-agent/hermes_cli/main.py.