Lockdown mode: scope RepoAccessCache per request#2571
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR scopes lockdown repository access caching so viewer identity is held per RepoAccessCache instance while keeping repository metadata in the shared cache table.
Changes:
- Replaces process-wide
lockdown.GetInstanceusage withNewRepoAccessCache. - Moves viewer login caching onto the cache instance and defers viewer lookup until needed.
- Updates lockdown and GitHub tests for per-instance viewer isolation and viewer-login retry behavior.
Show a summary per file
| File | Description |
|---|---|
pkg/lockdown/lockdown.go |
Refactors lockdown cache construction, viewer login handling, and shared cache entry contents. |
pkg/lockdown/lockdown_test.go |
Adds tests for viewer isolation, transient retry, and empty viewer login handling. |
pkg/github/issues_test.go |
Adjusts GraphQL mock responses for separate viewer/repository queries. |
pkg/github/dependencies.go |
Creates a new repo access cache from request dependencies. |
internal/ghmcp/server.go |
Uses the new cache constructor for stdio server setup. |
Copilot's findings
- Files reviewed: 5/5 changed files
- Comments generated: 3
SamMorrowDrums
approved these changes
May 29, 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.
Summary
Scope
RepoAccessCacheper request so viewer identity is no longer reused across callers via the process-shared cache table.Lockdown's trust model is unchanged.
Reported in GHSA-pjp5-fpmr-3349 by @hewei-gikaku and @matte1782.
Why
lockdown.GetInstancereturned a process-wide*RepoAccessCachewhose entries cached the viewer login of the first request to populate them. Under HTTP mode with multiple callers, subsequent requests could observe a viewer identity carried over from an earlier request, causingIsSafeContent's viewer-self check to evaluate against the wrong identity.What changed
lockdown.GetInstancewith per-requestlockdown.NewRepoAccessCacheinstances bound to the caller's GraphQL/REST clientscache2gotable process-shared since entries now hold only viewer-independent fields (isPrivate,knownUsers)*RepoAccessCachebehindsync.Mutex—viewerLoginForlazy-queries (rejecting empty responses),setViewerLoginpiggy-backs on the repo-metadata queryIsSafeContentuntil both private and push-access branches missSetLogger,RepoAccessInfo.ViewerLogin)Impact
isPrivate,knownUsers) don't leak across callersMCP impact
Security / limits
Tool renaming
deprecated_tool_aliases.goLint & tests
./script/lint./script/testDocs