Skip to content

Sanitize and lockdown-gate issue_read get_parent title#2780

Open
zwick wants to merge 2 commits into
mainfrom
zwick-lockdown-get-parent
Open

Sanitize and lockdown-gate issue_read get_parent title#2780
zwick wants to merge 2 commits into
mainfrom
zwick-lockdown-get-parent

Conversation

@zwick

@zwick zwick commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes a pre-existing gap where issue_read get_parent returned the parent issue's title raw — unsanitized and not gated by lockdown mode at all.

Why

Found while reviewing #2764 (which adds parent-issue hierarchy to issue_read get and gates the parent reference under lockdown). The sibling get_parent handler (GetIssueParent) had no such protection, so an agent could read an unverified, possibly cross-repo parent title even with lockdown enabled. This is on main today, independent of #2764, so it's intentionally a separate, minimal PR rather than folded into #2764.

What changed

  • Always sanitize.Sanitize the parent title (the parent may be cross-repo).
  • Under lockdown mode, only return the parent when its author has push access to the parent repository (cache.IsSafeContent), mirroring GetIssue; otherwise omit it ({"parent": null}), failing closed.
  • Added the parent author login to the GraphQL query and threaded ToolDependencies into GetIssueParent.
  • Added unit tests covering lockdown ON (push access → returned; read-only → omitted) and lockdown OFF regression.

MCP impact

  • Tool schema or behavior changed — get_parent parent title is now sanitized and gated under lockdown mode. No schema/description change (toolsnap unchanged).

Prompts tested (tool changes only)

Security / limits

  • Data exposure, filtering, or token/size limits considered — prevents exposure of unverified, possibly cross-repo parent titles under lockdown; sanitizes title content.

Tool renaming

  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Not needed

GetIssueParent returned the parent issue title raw and ungated by
lockdown mode, so an agent could read an unverified, possibly cross-repo
parent title even with lockdown enabled. Always sanitize the parent
title and, under lockdown mode, only return the parent when its author
has push access to the parent repository, failing closed otherwise.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@zwick zwick requested a review from a team as a code owner June 26, 2026 14:53
Copilot AI review requested due to automatic review settings June 26, 2026 14:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR closes a security/lockdown gap in issue_read’s get_parent method by ensuring the parent issue title is sanitized and (when lockdown mode is enabled) only returned if the parent author’s content can be verified as safe via push-access checks.

Changes:

  • Thread ToolDependencies into GetIssueParent and gate parent emission under lockdown using RepoAccessCache.IsSafeContent.
  • Sanitize the returned parent issue title unconditionally (parent may be cross-repo).
  • Expand the GraphQL selection to include the parent author login and add unit tests for lockdown ON/OFF behavior.
Show a summary per file
File Description
pkg/github/issues.go Adds sanitization + lockdown safe-content gating to GetIssueParent and threads deps into the handler.
pkg/github/issues_test.go Updates mocked GraphQL shape and adds lockdown-mode test coverage for get_parent.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Low

Comment thread pkg/github/issues_test.go Outdated
Comment thread pkg/github/issues_test.go Outdated
@zwick zwick marked this pull request as draft June 26, 2026 15:12
@zwick zwick self-assigned this Jun 26, 2026
Embed a U+202E BiDi control char in the mocked parent title so the
happy-path assertion fails if Sanitize is removed, and tighten the
GetIssueParent comments.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@zwick zwick marked this pull request as ready for review June 26, 2026 16:00
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.

2 participants