Skip to content

[Repo Assist] fix(logger): sanitize secrets in file/server log lines - #10774

Merged
lpcox merged 1 commit into
mainfrom
repo-assist/fix-sanitize-file-loggers-10763-b416a59cbf779f2e
Aug 6, 2026
Merged

[Repo Assist] fix(logger): sanitize secrets in file/server log lines#10774
lpcox merged 1 commit into
mainfrom
repo-assist/fix-sanitize-file-loggers-10763-b416a59cbf779f2e

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist, an AI assistant.

Closes #10763

Root cause

MarkdownLogger.Log() already calls sanitize.SanitizeString() on every message before writing to gateway.md, redacting tokens/keys/secrets. However, FileLogger.Log() (writes the unified mcp-gateway.log) and ServerFileLogger.Log() (writes per-server <serverID>.log files) both build their log line via the shared formatLogLine() helper, which did not sanitize the formatted message. This meant secrets logged via logger.LogInfo, logger.LogWarn, logger.LogError, logger.LogDebug, logger.LogInfoToServer, etc. could leak into mcp-gateway.log and per-server log files even though the markdown log correctly redacted them.

Fix

Centralized the fix in formatLogLine() (shared by both FileLogger and ServerFileLogger) so the fully-formatted message is passed through sanitize.SanitizeString() before being returned, mirroring the existing MarkdownLogger.Log() behavior. This ensures secrets are redacted consistently across all three file-based log sinks (unified log, per-server logs, markdown log).

Trade-offs

  • Adds one extra pass of the 10 compiled sanitize regex patterns per log line for FileLogger/ServerFileLogger (previously only MarkdownLogger paid this cost). This is consistent with existing behavior elsewhere in the codebase (e.g. RPC message logging already sanitizes once and shares the result across sinks) and is a worthwhile trade-off for closing a secret-leakage gap.
  • No API changes; formatLogLine signature and callers are unchanged.

Test Status

  • Added a regression test (TestFormatLogLine/secrets_in_the_formatted_message_are_redacted) asserting that a GitHub PAT-shaped string is redacted to [REDACTED] by formatLogLine.
  • gofmt passes cleanly on both changed files (no diff).
  • Could not run go build/go test in this sandbox: the Go module proxy (proxy.golang.org) is blocked by the environment firewall (403 Forbidden on all module downloads, including toolchain and dependency downloads), so the module graph cannot be resolved here. This is an environment/infrastructure limitation, not a defect in the change. The change is a small, syntactically-verified (gofmt -e) addition of a single sanitize call and a corresponding unit test using only existing test patterns already present in global_state_test.go; please run make test / make agent-finished in CI to confirm.

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • goproxy.io
  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "goproxy.io"
    - "proxy.golang.org"

See Network Configuration for more information.

Generated by Repo Assist · auto · 175.6 AIC · ⊞ 18.1K ·
Comment /repo-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@851905c06e905bf362a9f6cc54f912e3df747d55

Closes #10763

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox
lpcox marked this pull request as ready for review August 6, 2026 15:12
Copilot AI balanced review requested due to automatic review settings August 6, 2026 15:12
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — default AWF

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 (issues/PRs/file/commits) data returned ALLOWED
B MCP writes (reaction/star/issue/comment/branch/file/PR) all refused BLOCKED
C CLI reads (list issues, get file) data returned ALLOWED
D CLI REST writes (reaction/star/issue/comment/file) refused (no auth token + network restricted) BLOCKED
E CLI GraphQL mutations (addReaction/addStar/createIssue) refused (gh unauthenticated) BLOCKED

Gateway tool registry: 22 read-only tools exposed; all write tools absent from registry.
MCP write refusals: Error [-32602]: unknown tool — gateway-level enforcement (not just backend config).
REST/GraphQL: No auth token (GH_TOKEN/GITHUB_TOKEN unset) + sandbox network restrictions prevent write attempts.

Overall: PASS

References: §31105371023

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

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — gVisor

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: gVisor (runsc) kernel-level isolation

Part Surface Op Result Expected Status
A MCP reads (issues/PRs/file/commits) data returned ALLOWED
B MCP writes (reaction/star/issue/comment/branch/file/PR) Error [-32602]: unknown tool BLOCKED
C CLI reads (issues/PRs/file) data returned ALLOWED
D CLI REST writes (reaction/star/issue/comment/file) rejected — unauthenticated (no GH_TOKEN) BLOCKED
E CLI GraphQL mutations (addReaction/addStar/createIssue) rejected — unauthenticated (no GH_TOKEN) BLOCKED

Notes:

  • Part B: Gateway exposes only 22 read-only tools. All write tool calls return MCP error [-32602] unknown tool — gateway-level enforcement.
  • Parts D/E: gh CLI is unauthenticated (no GH_TOKEN), so all REST/GraphQL write attempts are rejected at authentication layer.
  • No reaction, star, issue, comment, branch, file, or PR was created on any surface.

Overall: PASS

Run: §31105372328

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

@lpcox
lpcox merged commit 99b2514 into main Aug 6, 2026
33 of 35 checks passed
@lpcox
lpcox deleted the repo-assist/fix-sanitize-file-loggers-10763-b416a59cbf779f2e branch August 6, 2026 15:34
@github-actions
github-actions Bot removed the request for review from Copilot August 6, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sanitized logs

1 participant