Skip to content

fix(mcp): scope decision-pack cache to auth token - #314

Merged
JSONbored merged 2 commits into
mainfrom
codex/propose-fix-for-contributor-authorization-bypass
Jun 2, 2026
Merged

fix(mcp): scope decision-pack cache to auth token#314
JSONbored merged 2 commits into
mainfrom
codex/propose-fix-for-contributor-authorization-bypass

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • The decision-pack stale-fallback cache was keyed only by API URL/API version/login and could return a cached private pack to a different local session when the live request hit a 429 or network/server error, leaking private contributor data.
  • The intent is to ensure cached decision packs are only reused by the same authenticated local actor and not by other local sessions sharing the same cache directory.

Description

  • Add a SHA-256 based auth cache key derived from the active API/session token via decisionPackAuthCacheKey() and import createHash from node:crypto.
  • Include the authCacheKey in the cache filename key and stored cache metadata and require it during readDecisionPackCache() and isCompatibleDecisionPackCacheEntry() checks so entries are bound to the current token.
  • Skip reading/writing decision-pack cache when no local token is configured and avoid storing the raw token (only the token hash is stored as authCacheKey).
  • Extend unit tests in test/unit/mcp-cli.test.ts to assert cached entries contain authCacheKey and add a regression test that verifies a different local token will not reuse an existing cache on a 429 fallback.

Testing

  • Ran git diff --check && npm run typecheck and the typecheck completed successfully.
  • Ran the focused unit tests with npx vitest run test/unit/mcp-cli.test.ts -t "decision-pack cache" and the updated decision-pack cache tests passed.
  • Executed npx vitest run test/unit/mcp-cli.test.ts -t "ignores incompatible" and the related cache/clear tests passed after adjusting test timeouts/expectations.
  • A broader npm run test:unit invocation was previously interrupted by an unrelated long-running agent process, but the targeted cache test runs and typecheck above succeeded.

Codex Task

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 2, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
gittensory-ui ed9c7bc Commit Preview URL

Branch Preview URL
Jun 02 2026, 05:24 PM

@github-actions github-actions Bot added the bug label Jun 2, 2026
@JSONbored JSONbored self-assigned this Jun 2, 2026
@JSONbored
JSONbored merged commit e9a5cf1 into main Jun 2, 2026
8 checks passed
@JSONbored
JSONbored deleted the codex/propose-fix-for-contributor-authorization-bypass branch June 2, 2026 17:25
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jun 2, 2026
@github-actions github-actions Bot mentioned this pull request Jun 2, 2026
12 tasks
@JSONbored JSONbored added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant