Skip to content

fix(secret): secret_file_dirs hardening follow-ups - #2032

Merged
Dumbris merged 8 commits into
mainfrom
fix/secret-file-dirs-hardening-2031
Nov 25, 2026
Merged

Dumbris merged 8 commits into
mainfrom
fix/secret-file-dirs-hardening-2031

Conversation

@Dumbris

@Dumbris Dumbris commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Refs #2031. Each item was confirmed against main first; tests written red, then fixed.

# Item Result
1 Deny-list depth Fixed. denyPathsAtRead walks the data dir breadth-first: 8 levels, 4096 entries per read, shallow first, secrets/ skipped. Fixed budgets keep the cost independent of data-dir size (bleve segments). Past the budget a file is still refused by path containment and link count; only a post-check path swap onto it goes unmatched.
2 Wildcard race Not real. Identity + link-count are checked on the opened handle in readOpenedSecret for wildcard too (file_policy.go:257,266). Swap test added as a pin; docs sentence corrected.
3 Unresolvable roots Fixed. Missing roots already warned; new warning for a root that is not a directory or cannot be resolved.
4 Doctor finding Fixed. Runtime warning in mcpproxy doctor / GET /api/v1/diagnostics, server names only, scoped callers see their own servers. No contract change (no OAS/Web UI change).
5 CLI save warning Fixed. With no recorder installed the warning prints to stderr (file name only).
6 Dropped secret_file_dirs: [] Fixed. Save refuses (ErrSecretFileDirsUnverified) when the file is undecodable but still shows the key; non-JSON/no-key files stay overwritable.
7 Nil-key case Pinned, no behaviour change. No OAuth override exists in process_overrides.go; read as the missing-entry assertion in runningAPIKeyFromReference (api_key_env.go). Please confirm that was the intended spot.
8 Coverage / Windows Tests added for all of the above. *_windows_test.go run in the Windows unit job (go test ./..., passed on a main run), but that job runs on pushes to main only, not on PRs.

Left unticked in #2031: item 7 (target uncertain) until confirmed.

Checks: go test -race secret/config/runtime/management, scripts/test-api-e2e.sh, golangci-lint bare + --build-tags server (0 new issues), build/vet for windows, linux, server tag.

Independent review (opencode github-copilot/gpt-6.2-sol, high, merge-base diff, 6 rounds): every real finding was fixed with a test (budget starvation, unbounded ReadDir, FIFO/non-directory open, case-insensitive and escaped keys in the undecodable-file guard, live-config doctor lookup, scope-filter before resolving paths, root warnings from both loaders, stderr control characters). Final state: chunk 4 (management) CLEAN; chunks 2a/2b/3 only low/edge findings accepted below; chunk 1 (walk) still reports the items below on the last round.

Accepted, not fixed:

  • A queued directory in the deeper walk swapped for a symlink between Lstat and open can add files outside the data dir to the deny set (false refusal of an unrelated read). Needs write access to the data dir, which can already replace the config.
  • Skipped pass-1 entries are capped per directory (3 x 4096), not globally.
  • Long-s Unicode case folding of the key in a malformed file; SIGPIPE on stderr before the rename; duplicate print of one warning in a pre-runtime serve save; root with mode 000 passes the resolve check; the existing scan-default runtime warning naming other servers to scoped callers (pre-existing, not from this change); doctor --server dropping string warnings.

Review is therefore not fully clean, so auto-merge is not armed.

🤖 Generated with Claude Code

Bounded data-dir identity walk, doctor/diagnostics finding for ${file:} refs
outside the allow-list, startup warning for unusable roots, stderr warning for
standalone CLI saves, refuse saves over an undecodable file holding
secret_file_dirs, pin tests for wildcard swap and the api_key override lookup.

refs #2031

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Dumbris and others added 3 commits November 24, 2026 21:59
…reads, case-insensitive key guard

Review round 1 (Sol 6.2): the shared walk budget could starve the state
directories the old walk always compared; os.ReadDir enumerated whole
directories; the undecodable-file guard missed upper-case keys and a file
with a syntax error after the setting.

refs #2031

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…s accuracy

Review round 1 (Sol 6.2, chunk 4).

refs #2031

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ck, ELOOP chains, escaped keys

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/secret-file-dirs-hardening-2031

Available Artifacts

  • archive-darwin-amd64 (33 MB)
  • archive-darwin-arm64 (30 MB)
  • archive-linux-amd64 (21 MB)
  • archive-linux-arm64 (19 MB)
  • archive-windows-amd64 (33 MB)
  • archive-windows-arm64 (29 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (29 MB)
  • installer-dmg-darwin-arm64 (26 MB)
  • smart-mcp-proxymcpproxy-goIMH2SL.dockerbuild (0 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 45492191787 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

Dumbris and others added 4 commits November 24, 2026 22:54
… a non-directory

Review round 3 (Sol 6.2).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…alk budget

Review round 4 (Sol 6.2).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ped pass-1 entries

Review round 5 (Sol 6.2).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@codecov-commenter

codecov-commenter commented Nov 25, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 87.06897% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/config/secret_file_dirs.go 72.72% 3 Missing and 3 partials ⚠️
internal/secret/deny_at_read.go 90.69% 2 Missing and 2 partials ⚠️
internal/config/process_overrides.go 84.61% 1 Missing and 1 partial ⚠️
internal/management/diagnostics.go 88.88% 1 Missing and 1 partial ⚠️
internal/config/loader.go 88.88% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Dumbris
Dumbris merged commit 793b3e8 into main Nov 25, 2026
53 checks passed
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.

2 participants