[Fix] Block memory extra path symlink traversal#80331
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 15ec97d415
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: yes. source-reproducible: current main lexically authorizes extraPaths directory reads and only checks the final path, so an intermediate directory symlink can redirect the later stat/read path. I did not run tests because this review is read-only. Real behavior proof Next step before merge Security Review detailsBest possible solution: Land the focused extraPaths static symlink traversal fix after real behavior proof is supplied and the overlap with the broader memory_get symlink PR is reconciled. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main lexically authorizes extraPaths directory reads and only checks the final path, so an intermediate directory symlink can redirect the later stat/read path. I did not run tests because this review is read-only. Is this the best way to solve the issue? Yes for the code direction: the latest patch puts the guard at the extraPaths authorization seam and uses the pinned fs-safe symlink and realpath helpers. It is not merge-ready until the external real behavior proof gate is satisfied. Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 94b43127d0c0. |
15ec97d to
112dfdf
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
## Considered and deferred - packages/memory-host-sdk/src/host/read-file.ts:77 [BOT-SCOPE]: Fully race-proof parent traversal would need a lower-level pinned/openat-style primitive; this diff fixes static symlink traversal and rejects symlink components before read.
Signed-off-by: samzong <samzong.lu@gmail.com>
588b688 to
6a9c3e2
Compare
|
Landed via rebase onto main. Proof:
Landed commits: Thanks @samzong! |
Summary
Describe the problem and fix in 2–5 bullets:
If this PR fixes a plugin beta-release blocker, title it
fix(<plugin-id>): beta blocker - <summary>and link the matchingBeta blocker: <plugin-name> - <summary>issue labeledbeta-blocker. Contributors cannot label PRs, so the title is the PR-side signal for maintainers and automation.memory_getauthorizedextraPathsdirectory reads with lexical containment, so symlinked intermediate components could redirect reads outside the configured memory corpus.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Real behavior proof (required for external PRs)
External contributors must show after-fix evidence from a real OpenClaw setup. Unit tests, mocks, lint, typechecks, snapshots, and CI are supplemental only. Screenshots are encouraged even for CLI, console, text, or log changes; terminal screenshots and copied live output count. Be mindful of private information like IP addresses, API keys, phone numbers, non-public endpoints, or other private details when providing evidence.
readMemoryFile/memory_getextra path reads through symlinked directory components.pnpm test packages/memory-host-sdk/src/host/read-file.test.ts extensions/memory-core/src/memory/manager.read-file.test.ts -- --reporter=verbose.read-file.test.tstests passing and 13/13manager.read-file.test.tstests passing..mdreturns empty text, symlinked directory component reads reject withpath required.extra/link/private.md.Root Cause (if applicable)
For bug fixes or regressions, explain why this happened, not just what changed. Otherwise write
N/A. If the cause is unclear, writeUnknown.extraPathsdirectory branch used lexicalisPathInside(additionalPath, absPath)and onlylstated the leaf path, so an intermediate symlink could escape the configured root.readRegularFileprotects regular-file identity and leaf symlinks, but it does not authorize the whole path against the configured memory corpus root.Regression Test Plan (if applicable)
For bug fixes or regressions, name the smallest reliable test coverage that should catch this. Otherwise write
N/A.packages/memory-host-sdk/src/host/read-file.test.ts.readMemoryFile, the authorization seam used bymemory_get.extensions/memory-core/src/memory/manager.read-file.test.tscovered leaf symlink rejection and general read behavior.User-visible / Behavior Changes
memory_getrejects extra path requests that traverse symlinked directory components instead of reading through them.Diagram (if applicable)
For UI changes or non-trivial logic flows, include a small ASCII diagram reviewers can scan quickly. Otherwise write
N/A.Security Impact (required)
Yes/No): NoYes/No): NoYes/No): NoYes/No): NoYes/No): YesYes, explain risk + mitigation: data access is narrowed for configured memory extra paths by rejecting symlink traversal through directory components.Repro + Verification
Environment
pnpmextraPathsconfigured to a temporary directory in testsSteps
inside.md.extra/linkas a directory symlink.readMemoryFilefor normal, missing, and symlinked paths.Expected
.mdunder a valid extra root returns empty text.path required.Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
EPERM/EACCES; format, lint, and package test typecheck.Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes/No): YesYes/No): NoYes/No): NoRisks and Mitigations
Considered and deferred