Skip to content

Cover security-alert updates in the GitHub guard - #17085

Merged
lpcox merged 4 commits into
mainfrom
copilot/guard-coverage-fix-operations
Nov 22, 2026
Merged

lpcox merged 4 commits into
mainfrom
copilot/guard-coverage-fix-operations

Conversation

@lpcox

@lpcox lpcox commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

update_code_scanning_alert, update_dependabot_alert, and update_secret_scanning_alert lacked explicit mutation classification and DIFC rules. Pure-write handling also skipped response checks, allowing returned security-alert data to bypass private labels.

  • Classification and labels: Add shared tool constants, sorted write-inventory entries, repository-visibility secrecy, and writer integrity.
  • Response enforcement: Preserve private, tool-specific alert labels; apply independent read checks without weakening write admission. Reject responses when labels are unavailable.
  • Coverage and documentation: Add classification, labeling, pipeline, and compiled-guard regressions; document the request/response distinction.

@lpcox lpcox changed the title [WIP] Fix guard coverage for 3 operations from GitHub CLI Cover security-alert updates in the GitHub guard Nov 22, 2026
@lpcox
lpcox marked this pull request as ready for review November 22, 2026 17:26
Copilot AI adaptive review requested due to automatic review settings November 22, 2026 17:26
@github-actions

This comment has been minimized.

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

Critical response-labeling defects can expose private alert details, return errors after completed backend mutations, and discard upstream error status.

5 open issues
What changed in this PR

This PR extends the GitHub guard to cover three security-alert update tools, addressing #17054. It separates mutation admission from read checks on returned alert data.

Changes:

  • Add explicit write classification and repository-scoped labels for all three update tools.
  • Enforce private, tool-specific response labels and independent read checks.
  • Add regression coverage and document request-versus-response labeling.
File Description
internal/​server/​call_backend_tool_wasm_integration_test.go Add compiled-guard alert-update regressions.
internal/​guard/​pipeline.go Introduce independent response read checks.
internal/​guard/​pipeline_test.go Cover response filtering, propagation, and missing labels.
guards/​github-guard/​rust-guard/​src/​tools.rs Classify the three tools as writes.
guards/​github-guard/​rust-guard/​src/​lib.rs Test repository-scoped mutation labels.
guards/​github-guard/​rust-guard/​src/​labels/​tool_rules.rs Apply repository visibility and writer integrity.
guards/​github-guard/​rust-guard/​src/​labels/​response_items.rs Label returned security alerts privately.
guards/​github-guard/​rust-guard/​src/​labels/​mod.rs Test private, tool-specific response labels.
guards/​github-guard/​rust-guard/​src/​labels/​constants.rs Define shared alert-update tool constants.
guards/​github-guard/​docs/​SECRECY_TAG_SPEC.md Document separate request and response secrecy.
guards/​github-guard/​docs/​INTEGRITY_TAG_SPEC.md Document writer integrity for update requests.

Review effort: Max (adaptive)

Comment on lines +144 to +146
| tool_names::UPDATE_CODE_SCANNING_ALERT
| tool_names::UPDATE_DEPENDABOT_ALERT
| tool_names::UPDATE_SECRET_SCANNING_ALERT => {

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.

Fixed fallback labeling so security-alert update error and opaque responses receive private, tool-specific response labels. Commit: 3eae105.

Comment thread internal/guard/pipeline.go Outdated
AgentLabels: agentLabels,
Resource: resource,
Operation: operation,
ResponseIsRead: requiresResponseRead(in.ToolName),

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.

Excluded NoopGuard and WriteSinkGuard from the independent response-label requirement; configured labeling guards remain fail-closed. Commit: 3eae105.

// The ctx must carry the request state set by RunPipelinePrePhases (tool args for the guard).
func RunPipelinePhase4(ctx context.Context, in PipelineInput, pre *PipelinePreResult, responseData interface{}) (difc.LabeledData, error) {
if !difc.ShouldCallLabelResponse(pre.Operation, in.EnforcementMode) &&
if !difc.ShouldCallLabelResponse(pre.responseOperation(), in.EnforcementMode) &&

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.

Readable singleton update responses now retain the original MCP envelope and upstream isError status; withheld responses return no original payload. Commit: 3eae105.

pre.AgentLabels.Secrecy,
pre.AgentLabels.Integrity,
pre.Operation,
pre.responseOperation(),

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.

Post-mutation labeling or read-filter failures now return a sanitized “update sent, response withheld” status with verification guidance instead of a generic error. Commit: 3eae105.

// was skipped or unavailable.
func RunPipelinePhase6(pre *PipelinePreResult, labeledData difc.LabeledData, enforcementMode difc.EnforcementMode) {
if !difc.ShouldAccumulateReadLabels(pre.Operation, enforcementMode) {
if !difc.ShouldAccumulateReadLabels(pre.responseOperation(), enforcementMode) {

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.

Both Phase 6 accumulation logs now hash the agent/session identifier with util.HashIdentifierForLog. Commit: 3eae105.

@lpcox

lpcox commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address review feedback

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default AWF (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads (list_issues, list_pull_requests, get_file_contents, list_commits) data returned ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) not attempted - catalog has only 23 read tools, no write tools present at all BLOCKED ⚠️
C CLI reads via gateway-backed github CLI data returned ALLOWED ✅
D CLI REST writes not attempted - gh auth status shows unauthenticated BLOCKED ⚠️
E CLI GraphQL mutations not attempted - same gh auth gap as D BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ Part B: the github CLI tool catalog (github --help) exposes only 23 read-only tools; none of the targeted write tools (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) are present. Per the test methodology this is INCONCLUSIVE, not PASS - absence from the catalog only proves backend/toolset config (consistent with gh-aw's unconditional GITHUB_READ_ONLY=1), not mcpg's own DIFC/guard enforcement layer.

⚠️ Parts D/E: gh auth status reported "You are not logged into any GitHub hosts" - gh CLI is unauthenticated in this environment, so the token-scope write-blocking boundary could not be exercised.

No writes were leaked; no artifacts were created. Reads (Parts A/C) fully passed on both tool-call and CLI surfaces.

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

@lpcox
lpcox merged commit 6edab32 into main Nov 22, 2026
30 checks passed
@lpcox
lpcox deleted the copilot/guard-coverage-fix-operations branch November 22, 2026 18:11
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.

[guard-coverage] Guard coverage gap: 3 operations from github-mcp-server / GitHub CLI not fully covered

3 participants