Skip to content

fix(mcpx): cache — traversal rejection, Put self-eviction, eviction lease re-check (#2566) - #2838

Merged
dezren39 merged 1 commit into
mainfrom
queue/3817-2566-mcpx-cache
Oct 30, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/3817-2566-mcpx-cache

Conversation

@dezren39

@dezren39 dezren39 commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Fixes #2566 — the three verified Codex P2 findings on merged PR #2555 (mcpx internal/cache, #1908 Approach C), each with a regression test:

  1. Path traversal in cache remove — Cache.Path/Dir now reject kind/key segments that are empty, dot components, or contain a path separator (returning ""), and every operation validates up front: Put/Remove/List return an error, Get reports a miss. Remove additionally verifies the resolved target is exactly one entry directly inside the kind directory before its os.RemoveAll. Test: TestTraversalNamesRejected (a ../ attempt against a sentinel directory outside the root fails and the sentinel survives).
  2. Put self-eviction — Put now evicts with keep set to the entry it just stored. An entry larger than MaxBytes is kept (the bound is exceeded by that entry alone) instead of being deleted by its own Put while Put reported success; older entries are evicted first. Test: TestPutNeverEvictsItsOwnEntry (the 2-byte payload / MaxBytes: 1 repro).
  3. Eviction/lease TOCTOU — removeAll (shared by Evict and Prune) re-checks Leased() immediately before each removal, so an entry leased after the victim scan is skipped. Test: TestRemoveAllRechecksLeaseAfterSelection (deterministic scan → lease → evict case in cache_internal_test.go).

The three Codex threads on PR #2555 were already replied to from queue task 3148 with the #2566 link; this PR is the fix those replies promised.

Tests: go test ./internal/cache/ passes on the laptop (full package, including the three new regression tests); full pkgs/mcpx suite runs in CI on this PR.

Queue task 3817 (repo-health-code-pilot).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner October 30, 2026 21:42
@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 10 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1fe6e747-dc8b-48b6-9412-3a33dca34431
Commits

Reviewing files that changed from the base of the PR and between a8ea41a and 85d85af.

Files selected for processing: 3
  • pkgs/mcpx/internal/cache/cache.go
  • pkgs/mcpx/internal/cache/cache_internal_test.go
  • pkgs/mcpx/internal/cache/cache_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T21:44:09.100084Z 85d85af PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcpx cache: three Codex findings on merged PR #2555 — path traversal in cache remove, Put self-eviction, eviction/lease TOCTOU

1 participant