Skip to content

Fail closed on unrecognized read-only and lockdown boolean values - #3944

Open
HankGrimm wants to merge 3 commits into
github:mainfrom
HankGrimm:fix/read-only-bool-parsing
Open

HankGrimm wants to merge 3 commits into
github:mainfrom
HankGrimm:fix/read-only-bool-parsing

Conversation

@HankGrimm

Copy link
Copy Markdown

Summary

Fail closed on unrecognized read-only / lockdown-mode boolean values so a misspelled env var can't silently leave write tools exposed.

Why

GITHUB_READ_ONLY and GITHUB_LOCKDOWN_MODE only turned their mode on for strconv.ParseBool spellings (1/true/TRUE/t). Common spellings such as yes, on, and enabled — and typos such as tru — were silently parsed as false, so the server started with every write tool exposed.

Fixes #3747

What changed

  • Add parseBoolFlag, which accepts the common truthy/falsy spellings and returns an error for anything unrecognized (matching the --read-only flag's fail-closed behavior).
  • Use it for read-only and lockdown-mode in the stdio and HTTP commands and in list_scopes.
  • Add TestParseBoolFlag.

MCP impact

  • No tool or API changes

Prompts tested (tool changes only)

  • N/A — config parsing only.

Security / limits

  • Auth / permissions considered — this makes the read-only/lockdown safety switches fail closed instead of silently turning off.

Tool renaming

  • I am not renaming tools as part of this PR

Both tools replace the current values and remove any not in the provided
list, but they were annotated destructiveHint: false, so a host keying
confirmation on destructiveHint may not prompt before labels/assignees are
removed.

Set destructiveHint to true for the two replace-semantics tools.

Fixes github#3760
…signees

The wire snapshots still carried destructiveHint: false; regenerate them to
reflect the annotation change.

Fixes github#3760
GITHUB_READ_ONLY and GITHUB_LOCKDOWN_MODE only turned their mode on for
strconv.ParseBool spellings (1/true/TRUE/t). Common spellings such as yes,
on, and enabled — and typos such as tru — were silently parsed as false, so
the server started with write tools exposed.

Parse these switches with a stricter helper that accepts the common spellings
and returns an error for anything unrecognized, matching the --read-only flag.

Fixes github#3747
@HankGrimm
HankGrimm requested a review from a team as a code owner November 25, 2026 06:39
Copilot AI adaptive review requested due to automatic review settings November 25, 2026 06:39

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.

🟡 Changes recommended

Stray carriage returns will break label and assignee snapshot comparisons, while whitespace-only read-only and lockdown settings fail open instead of being rejected.

2 open issues
What changed in this PR

This PR hardens the GitHub MCP Server’s safety-switch configuration parsing, addressing #3747 by rejecting unrecognized values instead of silently disabling protection. It also updates client-visible destructive-operation hints for two issue tools.

Changes:

  • Add strict boolean parsing for stdio, HTTP, and read-only scope reporting.
  • Test supported boolean spellings and invalid values.
  • Mark issue-assignee and label replacements as destructive, with matching tests and snapshots.
File Description
pkg/​github/​issues_granular.go Marks assignee and label replacement tools as destructive.
pkg/​github/​granular_tools_test.go Tests destructive annotations for both tools.
pkg/​github/​__toolsnaps__/​update_issue_labels.snap Updates the labels tool’s annotation snapshot.
pkg/​github/​__toolsnaps__/​update_issue_assignees.snap Updates the assignees tool’s annotation snapshot.
cmd/​github-mcp-server/​main.go Adds strict boolean parsing to stdio and HTTP configuration.
cmd/​github-mcp-server/​main_test.go Adds table-driven boolean parser tests.
cmd/​github-mcp-server/​list_scopes.go Validates read-only configuration before reporting scopes.

Review effort: Max (adaptive)

{
"mimeType": "image/png",
"src": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAC2UlEQVRIicWVMUyTaRjHf/+vVUpOJOdilOYoUvVreq2CDmLOwdlAS5xMbrrhBifjYG7QjYuJw108nZx1huLgYlw0QshxChUK2koxHHcuCmgsFfieG0or3kGPSoz/8X3f5/97nvfN8z7wmaVqm9FodFfR/EnMugy5giCAwYwgI9Ff9Hl9L9Lp1zUBgsGO+rqGwnlhF4CdwBSyAUwvS1G220zHBSFgHtmVxYWvfp2ZGSj8LyAcjgfZphTQZtAr7OdsZvSP9RIJR+LtQhcNusF+d1aUfPp05M8NAavmg8AOk3cmN56+s1Hpa7U/cviUYbcw3jgex9ZCKoBgsKM+0PDuAdBq2He5zOiTzZiXtc+NxRw598GeLRcWTuTz+UUAp3ygrqFwHmgzeWdqNQd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eWdqNQd4PpFOy/gedNQfaDz3UQXRaHRX0fNPGdzNZUZO12q+VuHIoV7g5Hu/1/IinX7tABTNnwR2SvRsxRzAzOsBGuuWfAkoX5FZFzCVHR95tFVAbiI9DEwj6wLwl5YVMTRYLTDsxjuRrgGYYz/kxkbvbXRWMOBB24cKYI9ks1X8hXQDaAaa5XG9WjImZgV71wI+m8qAv8y0t1pSmP0ITANTmHO2qqvRZDALlTdgHKyjWkx2YvQ2cHtTacMxYBhWK5DoF4TCkXj7Jg02VKsbOwI0Y+qvALZrOQXMC13cKkDSJWBuJUCqAhgbG3uF7IpBcn/k8KlPNQ+78U5QQuhy/vHjuQoAYPndwi9gw4bd2ufGYrWatxz8No50ExhaKsz9Vl6vAPL5/KKzoiTGG0fOg1oqCbvxTp/juw/M+zynu/yTwjoD58CBQ02ez/pAR4E+M69ntf3/o1Y3dqR050oAQz7P6Z6cfPRRw647MkOhUMAfaDyH+AloBKYNPRT292rQHoMOSp09J3TZlt5ezWazxX97VR3638RiX9ct+RImSyBcrDT0ETMyMp4ptRIgVX7QL6J/ALSUEwJ5rdg2AAAAAElFTkSuQmCC\r",
Comment on lines +401 to +402
switch strings.ToLower(strings.TrimSpace(raw)) {
case "", "0", "f", "false", "no", "n", "off", "disabled":
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.

GITHUB_READ_ONLY=yes (or on) silently leaves read-only mode off

2 participants