Skip to content

Commit f7929d6

Browse files
fix security comment
1 parent c0e2333 commit f7929d6

5 files changed

Lines changed: 52 additions & 20 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ The `issues` toolset supports planning statuses. `issue_read` returns the
623623
current status, `search_issues` documents the `status:` qualifier, and issue
624624
creation accepts Backlog, Todo, In progress, or In review. The
625625
`update_issue_status` tool also accepts Done, Not planned, and Duplicate;
626+
these closing statuses require `confirm_close: true` after the user confirms.
626627
Duplicate requires the canonical issue number in `duplicate_of`. The
627628
`issue_write` MCP App creation form can set an initial status or use the
628629
default, Backlog.
@@ -1163,6 +1164,7 @@ For negotiated supported protocol versions `2026-07-28` or newer, the consolidat
11631164

11641165
- **update_issue_status** - Update Issue Status
11651166
- **OAuth Challenge Scopes**: `repo`
1167+
- `confirm_close`: Must be true for Done, Not planned or Duplicate. Set only after the user confirms closing the issue. (boolean, optional)
11661168
- `duplicate_of`: The canonical issue number. Required only for Duplicate. (number, optional)
11671169
- `issue_number`: The issue number to update (number, required)
11681170
- `owner`: Repository owner (username or organization) (string, required)

‎pkg/github/__toolsnaps__/update_issue_status.snap‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"readOnlyHint": false,
77
"title": "Update Issue Status"
88
},
9-
"description": "Update an issue's planning status. Done, Not planned and Duplicate close the issue; the other statuses keep it open or reopen it. Duplicate requires duplicate_of, the canonical issue number in the same repository. A status cannot be removed.",
9+
"description": "Update an issue's planning status. Done, Not planned and Duplicate close the issue; the other statuses keep it open or reopen it. Closing statuses require confirm_close: true, set only after the user confirms closing the issue. Duplicate requires duplicate_of, the canonical issue number in the same repository. A status cannot be removed.",
1010
"icons": [
1111
{
1212
"mimeType": "image/png",
@@ -21,6 +21,10 @@
2121
],
2222
"inputSchema": {
2323
"properties": {
24+
"confirm_close": {
25+
"description": "Must be true for Done, Not planned or Duplicate. Set only after the user confirms closing the issue.",
26+
"type": "boolean"
27+
},
2428
"duplicate_of": {
2529
"description": "The canonical issue number. Required only for Duplicate.",
2630
"minimum": 1,

‎pkg/github/granular_tools_test.go‎

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"maps"
88
"net/http"
9+
"slices"
910
"strings"
1011
"testing"
1112

@@ -1184,19 +1185,23 @@ func TestUpdateIssueStatus(t *testing.T) {
11841185
duplicateCode int
11851186
updateCode int
11861187
wantError string
1188+
unconfirmed bool
11871189
}{
1188-
{"Backlog", "backlog", 0, http.StatusOK, ""},
1189-
{"Todo", "planned", 0, http.StatusOK, ""},
1190-
{"In progress", "started", 0, http.StatusOK, ""},
1191-
{"In review", "started", 0, http.StatusOK, ""},
1192-
{"Done", "completed", 0, http.StatusOK, ""},
1193-
{"Not planned", "not_planned", 0, http.StatusOK, ""},
1194-
{"Duplicate", "duplicate", http.StatusOK, http.StatusOK, ""},
1195-
{"Duplicate", "duplicate", http.StatusNotFound, 0, "failed to get duplicate issue"},
1196-
{"Todo", "planned", 0, http.StatusForbidden, "failed to update issue"},
1190+
{"Backlog", "backlog", 0, http.StatusOK, "", false},
1191+
{"Todo", "planned", 0, http.StatusOK, "", false},
1192+
{"In progress", "started", 0, http.StatusOK, "", false},
1193+
{"In review", "started", 0, http.StatusOK, "", false},
1194+
{"Done", "completed", 0, http.StatusOK, "", false},
1195+
{"Not planned", "not_planned", 0, http.StatusOK, "", false},
1196+
{"Duplicate", "duplicate", http.StatusOK, http.StatusOK, "", false},
1197+
{"Duplicate", "duplicate", http.StatusNotFound, 0, "failed to get duplicate issue", false},
1198+
{"Todo", "planned", 0, http.StatusForbidden, "failed to update issue", false},
1199+
{"Done", "completed", 0, 0, "confirm_close must be true", true},
1200+
{"Not planned", "not_planned", 0, 0, "confirm_close must be true", true},
1201+
{"Duplicate", "duplicate", 0, 0, "confirm_close must be true", true},
11971202
}
11981203
for _, tc := range cases {
1199-
t.Run(fmt.Sprintf("%s/%d/%d", tc.status, tc.duplicateCode, tc.updateCode), func(t *testing.T) {
1204+
t.Run(fmt.Sprintf("%s/%d/%d/unconfirmed=%t", tc.status, tc.duplicateCode, tc.updateCode, tc.unconfirmed), func(t *testing.T) {
12001205
gets, patches := 0, 0
12011206
rest := &http.Client{Transport: recorderTransport{handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
12021207
w.Header().Set("Content-Type", "application/json")
@@ -1225,6 +1230,9 @@ func TestUpdateIssueStatus(t *testing.T) {
12251230
if tc.status == "Duplicate" {
12261231
args["duplicate_of"] = "7"
12271232
}
1233+
if slices.Contains(issueClosingStatusNames, tc.status) && !tc.unconfirmed {
1234+
args["confirm_close"] = true
1235+
}
12281236
result, err := session.CallTool(context.Background(), &mcp.CallToolParams{Name: "update_issue_status", Arguments: args})
12291237
require.NoError(t, err)
12301238
if tc.wantError != "" {
@@ -1235,13 +1243,13 @@ func TestUpdateIssueStatus(t *testing.T) {
12351243
assert.JSONEq(t, fmt.Sprintf(`{"id":"123","url":"https://github.com/owner/repo/issues/42","status":{"id":4,"name":%q,"category":%q}}`, tc.status, tc.category), getTextResult(t, result).Text)
12361244
assert.JSONEq(t, mustMarshalJSON(t, result.StructuredContent), getTextResult(t, result).Text)
12371245
}
1238-
if tc.status == "Duplicate" {
1246+
if tc.status == "Duplicate" && !tc.unconfirmed {
12391247
assert.Equal(t, 1, gets)
12401248
} else {
12411249
assert.Zero(t, gets)
12421250
}
12431251
if tc.updateCode == 0 {
1244-
assert.Zero(t, patches, "failed duplicate lookup must prevent the mutation")
1252+
assert.Zero(t, patches, "failed duplicate lookup or missing confirmation must prevent the mutation")
12451253
} else {
12461254
assert.Equal(t, 1, patches)
12471255
}
@@ -1262,6 +1270,9 @@ func TestIssuePlanningStatusInvalidInput(t *testing.T) {
12621270
{UpdateIssueStatus(translate), map[string]any{"status": "unknown"}, "status must be one of"},
12631271
{UpdateIssueStatus(translate), map[string]any{"status": nil}, "status"},
12641272
{UpdateIssueStatus(translate), map[string]any{"status": "Todo", "issue_number": -1}, "issue_number must be positive"},
1273+
{UpdateIssueStatus(translate), map[string]any{"status": "Done"}, "confirm_close must be true"},
1274+
{UpdateIssueStatus(translate), map[string]any{"status": "Not planned", "confirm_close": false}, "confirm_close must be true"},
1275+
{UpdateIssueStatus(translate), map[string]any{"status": "Done", "confirm_close": "true"}, "confirm_close"},
12651276
{GranularCreateIssue(translate), map[string]any{"status": "Done"}, "status must be one of: Backlog, Todo, In progress, In review"},
12661277
{IssueWrite(translate), map[string]any{"method": "update", "status": "Todo"}, "status is only supported with the create method"},
12671278
{IssueWrite(translate), map[string]any{"status": "Todo", "state": "closed"}, "status cannot be combined with state"},
@@ -1271,7 +1282,7 @@ func TestIssuePlanningStatusInvalidInput(t *testing.T) {
12711282
args := map[string]any{"owner": "owner", "repo": "repo", "issue_number": 42, "title": "Subject", "method": "create"}
12721283
maps.Copy(args, tc.args)
12731284
req := createMCPRequest(args)
1274-
result, err := tc.tool.Handler(BaseDeps{})(context.Background(), &req)
1285+
result, err := tc.tool.Handler(BaseDeps{})(ContextWithDeps(context.Background(), BaseDeps{}), &req)
12751286
require.NoError(t, err)
12761287
require.True(t, result.IsError)
12771288
assert.Contains(t, getTextResult(t, result).Text, tc.want)

‎pkg/github/issue_status.go‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var (
2525
// Issues can only be created with an open status.
2626
issueCreationStatusNames = issueStatusNames[:4:4]
2727
issueStatusCategories = []string{"backlog", "planned", "started", "completed", "not_planned", "duplicate"}
28+
issueClosingStatusNames = issueStatusNames[4:]
2829
)
2930

3031
type IssuePlanningStatus struct {
@@ -68,11 +69,12 @@ type IssueStatusUpdateOutput struct {
6869
}
6970

7071
type IssueStatusInput struct {
71-
Owner string `json:"owner"`
72-
Repo string `json:"repo"`
73-
IssueNumber int `json:"issue_number"`
74-
Status string `json:"status"`
75-
DuplicateOf int `json:"duplicate_of,omitempty"`
72+
Owner string `json:"owner"`
73+
Repo string `json:"repo"`
74+
IssueNumber int `json:"issue_number"`
75+
Status string `json:"status"`
76+
DuplicateOf int `json:"duplicate_of,omitempty"`
77+
ConfirmClose bool `json:"confirm_close,omitempty"`
7678
}
7779

7880
func issuePlanningStatusSchema() *jsonschema.Schema {
@@ -171,6 +173,9 @@ func normalizeIssueStatusArguments(raw json.RawMessage) (json.RawMessage, error)
171173
if status == "Duplicate" && duplicate == 0 {
172174
return nil, fmt.Errorf("duplicate_of is required when status is 'Duplicate'")
173175
}
176+
if _, err := OptionalParam[bool](args, "confirm_close"); err != nil {
177+
return nil, err
178+
}
174179
args["issue_number"], args["status"] = number, status
175180
return json.Marshal(args)
176181
}
@@ -183,6 +188,7 @@ func UpdateIssueStatus(t translations.TranslationHelperFunc) inventory.ServerToo
183188
Name: "update_issue_status",
184189
Description: t("TOOL_UPDATE_ISSUE_STATUS_DESCRIPTION", "Update an issue's planning status. "+
185190
"Done, Not planned and Duplicate close the issue; the other statuses keep it open or reopen it. "+
191+
"Closing statuses require confirm_close: true, set only after the user confirms closing the issue. "+
186192
"Duplicate requires duplicate_of, the canonical issue number in the same repository. A status cannot be removed."),
187193
InputSchema: &jsonschema.Schema{
188194
Type: "object",
@@ -192,6 +198,10 @@ func UpdateIssueStatus(t translations.TranslationHelperFunc) inventory.ServerToo
192198
"issue_number": {Type: "number", Minimum: new(1.0), Description: "The issue number to update"},
193199
"status": {Type: "string", Enum: enumValues(issueStatusNames), Description: "The planning status to assign."},
194200
"duplicate_of": {Type: "number", Minimum: new(1.0), Description: "The canonical issue number. Required only for Duplicate."},
201+
"confirm_close": {
202+
Type: "boolean",
203+
Description: "Must be true for Done, Not planned or Duplicate. Set only after the user confirms closing the issue.",
204+
},
195205
},
196206
Required: []string{"owner", "repo", "issue_number", "status"},
197207
},
@@ -205,6 +215,10 @@ func UpdateIssueStatus(t translations.TranslationHelperFunc) inventory.ServerToo
205215
},
206216
scopes.RequireAll(scopes.Repo),
207217
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args IssueStatusInput) (*mcp.CallToolResult, *IssueStatusUpdateOutput, error) {
218+
// This is a caller-supplied confirmation policy, not proof that a trusted UI prompted the user.
219+
if slices.Contains(issueClosingStatusNames, args.Status) && !args.ConfirmClose {
220+
return utils.NewToolResultError("confirm_close must be true to use a status that closes the issue"), nil, nil
221+
}
208222
client, err := deps.GetClient(ctx)
209223
if err != nil {
210224
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil

‎pkg/skills/catalog/skills/issue-backlog-triage/SKILL.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ important one in the backlog; judge on content, not on dates alone.
6565
- `issue_read` with `method: get` returns `status` as an ID, name and category,
6666
or null. Filter `search_issues` with `status:"In progress"` or another fixed status.
6767
Use `update_issue_status` for Backlog, Todo, In progress, In review, Done,
68-
Not planned or Duplicate. Done, Not planned and Duplicate close the issue;
68+
Not planned or Duplicate. Done, Not planned and Duplicate close the issue
69+
and require `confirm_close: true`, set only after the user confirms closing;
6970
the others keep it open or reopen it. Duplicate requires `duplicate_of`,
7071
the canonical issue number in the same repository. Status cannot be removed.
7172
- `type` — only valid if `list_issue_types` returned it. Guessing a type fails the

0 commit comments

Comments
 (0)