Skip to content

Restrict MCP log cache permissions - #78187

Closed
pelikhan with github-agentic-autofix[bot] wants to merge 3 commits into
mainfrom
agentic-autofix/fix-code-scanning-alerts-again
Closed

pelikhan with github-agentic-autofix[bot] wants to merge 3 commits into
mainfrom
agentic-autofix/fix-code-scanning-alerts-again

Conversation

@github-agentic-autofix

@github-agentic-autofix github-agentic-autofix AI commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

MCP log reports contain private workflow and agent data but were stored with world-readable permissions. This change restricts the cache and its reports to the current user; existing shell safeguards cover the reported post-agent symlink risks.

  • MCP logs: Set cache directories to 0700 and report files to 0600, including when reusing cached reports.
  • Post-agent artifacts: Existing protections reject symlinked patch and summary inputs, stage usage copies before replacement, and isolate commit diagnostics in a private temporary directory.
os.Chmod(mcpLogsCacheDir, constants.DirPermOwnerOnly) // 0700
os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, constants.FilePermSensitive) // 0600

@github-agentic-autofix github-agentic-autofix AI changed the title [WIP] Fix code scanning alerts #1086, #1089, #1090, #1091, #1092, #1093, #1094 Restrict MCP log cache permissions Nov 16, 2026
GitHub Agentic Autofix finished work on behalf of pelikhan November 16, 2026 00:44
@github-agentic-autofix
github-agentic-autofix AI marked this pull request as ready for review November 16, 2026 00:44
@github-agentic-autofix
github-agentic-autofix AI requested review from pelikhan and an adaptive review from Copilot November 16, 2026 00:44

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

The new exact-mode assertions fail on Windows because os.Stat reports 0777/0666 rather than the expected 0700/0600, breaking unit-test portability.

1 open issue
What changed in this PR

This PR restricts access to gh-aw’s MCP log cache to protect private workflow and agent data.

Changes:

  • Set cache directories to 0700 and report files to 0600, including reused reports.
  • Update permission tests to assert exact owner-only modes.
File Description
pkg/​cli/​mcp_logs_guardrail.go Apply owner-only permissions when creating or reusing cached reports.
pkg/​cli/​mcp_logs_guardrail_test.go Rename the permission test and assert 0700 directory and 0600 file modes.

Review effort: Max (dynamic)

Comment thread pkg/cli/mcp_logs_guardrail_test.go Outdated
cachePerm := cacheInfo.Mode().Perm()
if cachePerm&0o005 != 0o005 {
t.Errorf("Cache directory should be accessible to other users (expected other r-x bits set), got mode %o", cachePerm)
if cachePerm != 0o700 {
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot the agent must be able to read the files in the logs folder. They should be stored in the temp folder accessible to the agent so that they also get deleted afterwards.

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

Copilot AI commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

@copilot the agent must be able to read the files in the logs folder. They should be stored in the temp folder accessible to the agent so that they also get deleted afterwards.

Restored agent-readable permissions for reports in the existing /tmp/gh-aw temporary cache, which is cleaned up with the agent environment. The focused tests and Windows cross-compile pass. Commit: 4c8887e.

t.Errorf("Cache file should be world-readable (expected other read bit set), got mode %o", filePerm)
if runtime.GOOS != "windows" {
cachePerm := cacheInfo.Mode().Perm()
if cachePerm&0o005 != 0o005 {
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (pkg/cli/mcp_logs_guardrail_test.go:72): address unresolved feedback - Review comment

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "4c8887ef2d75be9486274f0a87f0cf6b041dda7a",
  "kind": "requested",
  "schema_version": "1",
  "state": "49627475e82d4120ac672f81cf52fa1b75dd859d968273cfabff776f7337de15",
  "work": [
    "a46dcc3c45e5bd0704547891e7cf19fc8c185fbcf7643862f773eb19f8707273"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ⊞ 7K · ◷
Comment /souschef to run again

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.

6 participants