Skip to content

memories-mcp: reject symlink traversal in local backend#21010

Merged
jif-oai merged 1 commit into
mainfrom
jif/do-not-follow-symlink
May 4, 2026
Merged

memories-mcp: reject symlink traversal in local backend#21010
jif-oai merged 1 commit into
mainfrom
jif/do-not-follow-symlink

Conversation

@jif-oai
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai commented May 4, 2026

Why

The local memories MCP backend only rejected symlinks after resolving the final path. That left room for scoped requests like skills/secret.md to walk through a symlinked ancestor directory and escape the configured memories root.

This change also makes missing scoped paths fail explicitly instead of looking like an empty list / search result or a NotFile read error.

What Changed

  • walk each scoped path component in LocalMemoriesBackend::resolve_scoped_path and reject symlinked ancestors before accessing the target
  • reject scoped paths that traverse through a non-directory intermediate component
  • add a NotFound backend error for missing read, list, and search paths and map it through the MCP server error conversion
  • add coverage for missing paths and symlinked ancestor directories in codex-rs/memories/mcp/src/local_tests.rs

Testing

  • added unit coverage in codex-rs/memories/mcp/src/local_tests.rs for missing paths and symlinked ancestor directories across read, list, and search

@jif-oai jif-oai changed the title feat: protect against symlinks memories-mcp: reject symlink traversal in local backend May 4, 2026
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 4, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Bravo.

ℹ️ 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".

@jif-oai jif-oai merged commit 4fd7dfe into main May 4, 2026
26 checks passed
@jif-oai jif-oai deleted the jif/do-not-follow-symlink branch May 4, 2026 16:40
@github-actions github-actions Bot locked and limited conversation to collaborators May 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant