fix(lockdown): harden pull_request_read get_commits handling - #3109
Merged
Conversation
pull_request_read's get_commits method previously returned commit messages without any lockdown check, unlike get_diff and get_files which restrict the whole result when the PR author lacks push access. Commit content is part of the same untrusted head branch as the diff and file list, so GetPullRequestCommits now reuses enforcePullRequestLockdown for consistent, fail-closed behavior without adding a per-commit permission lookup. Also updates the lockdown documentation in README.md and docs/server-configuration.md to: - list pull_request_read:get_diff, get_files, and get_commits among the tools that error when the PR author lacks push access (get_diff and get_files were already implemented this way but undocumented) - clarify that lockdown mode is a best-effort content filter to reduce prompt-injection risk, not an authorization boundary - document the existing intentional trusted-bot exception (github-actions[bot], copilot) accurately Fixes #3105 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Hardens pull_request_read:get_commits by applying existing lockdown protections to commit content.
Changes:
- Enforces PR-author trust checks before listing commits.
- Adds lockdown success, denial, bot-exception, and failure tests.
- Clarifies lockdown scope and limitations in documentation.
Show a summary per file
| File | Description |
|---|---|
README.md |
Documents lockdown behavior and affected PR methods. |
pkg/github/pullrequests.go |
Applies lockdown checks to commit retrieval. |
pkg/github/pullrequests_test.go |
Tests commit retrieval under lockdown scenarios. |
docs/server-configuration.md |
Clarifies lockdown’s security model and bot exceptions. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Balanced
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
pull_request_read'sget_commitsmethod returned commit messages without any lockdown check, unlikeget_diffandget_files, which already restrict the whole result when the PR author lacks push access. This meant commit content from an untrusted fork PR bypassed the lockdown model applied to comparable pull request content.Changes
GetPullRequestCommitsnow callsenforcePullRequestLockdown(the same helper used byGetPullRequestDiff/GetPullRequestFiles) before listing commits, so under lockdown mode it fails closed withaccess to pull request is restricted by lockdown modewhen the PR author lacks push access.README.mdanddocs/server-configuration.md:pull_request_read:get_diff,get_files, andget_commitsto the documented list of tools that error under lockdown (the first two were already implemented this way but previously undocumented).github-actions[bot],copilot) that was previously implemented inpkg/lockdown/lockdown.gobut never mentioned in the docs.Design tradeoff
Commits are structurally a list with per-item authorship info (
RepositoryCommit.Author), similar to reviews/comments, which are filtered per-item. However, I chose the PR-author whole-result check (same asget_diff/get_files) instead of per-commit filtering because:Testing
script/lint— cleanscript/test— all packages passscript/generate-docs— run; no tool-schema/description changes (only manual prose edits), diff unaffectedFixes #3105