Skip to content

fix(mcp): redact a parenthesis/bracket/colon-prefixed local path in redactLocalPath - #6369

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
joaovictor91123:fix/mcp-local-path-redaction-paren-prefix-6258
Jul 16, 2026
Merged

fix(mcp): redact a parenthesis/bracket/colon-prefixed local path in redactLocalPath#6369
JSONbored merged 1 commit into
JSONbored:mainfrom
joaovictor91123:fix/mcp-local-path-redaction-paren-prefix-6258

Conversation

@joaovictor91123

Copy link
Copy Markdown
Contributor

Closes #6258

Summary

  • redactLocalPath's prefix delimiter class ((^|[\s"'\=])) omitted ( — the exact prefix Node.js stack traces use (at fn (/abs/path:10:5)). Verified directly: a (`-prefixed absolute path passed through completely unredacted, while a space-prefixed path redacted correctly.
  • This function now lives in one shared module (packages/loopover-mcp/lib/redact-local-path.js, consolidated by refactor(mcp): consolidate 3 separately-maintained local-path-redaction implementations #6264) rather than the two separately-duplicated copies the issue originally cited (local-branch.js / bin/loopover-mcp.js) — so this one fix closes the gap for every call site at once, including the validation-summary path that POSTs to the LoopOver API.
  • Per the issue's own ask to check for other missed prefix shapes: also found and fixed [ (bracket-wrapped paths, e.g. [/abs/path]) and : (colon-joined messages with no space, e.g. error:/abs/path) missing from the same class. Also excluded ] from the path-tail/segment character sets so a bracket-wrapped path redacts cleanly ([<local-path>]) instead of swallowing the closing bracket into the match.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves.

Validation

  • git diff --check
  • npm run typecheck
  • npm run test:coverage (full local run; pre-existing Windows-only environment failures unrelated to this change — docker-prune script exec-mode checks, path-separator/CRLF differences — are the only failures present, matching the established baseline on a clean checkout)
  • Regression tests added in test/unit/redact-local-path.test.ts: the exact reproduced parenthesis-prefixed stack-frame case, plus the two additional gaps found (bracket-prefixed, colon-prefixed-no-space).
  • Existing tests for every already-covered prefix/delimiter shape continue to pass unmodified.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise.
  • No auth/cookie/CORS/GitHub App/Cloudflare/session changes in this PR.
  • Not applicable: no API/OpenAPI/MCP schema change (internal redaction-regex tightening only).
  • Not applicable: no UI change.
  • No public docs/changelog changes needed for this fix.

…edactLocalPath

redactLocalPath's prefix delimiter class only recognized whitespace, quotes,
backtick, and "=" immediately before a local path -- missing "(", the Node.js
stack-frame shape ("at fn (/abs/path:10:5)"), so a real absolute path pasted
into validation output could leak upstream unredacted. Verified and closed
two adjacent gaps in the same class ("[" and ":") while at it, and excluded
"]" from the path-tail/segment patterns so a bracket-wrapped path redacts
cleanly instead of swallowing the closing bracket.
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.60%. Comparing base (b7e1bec) to head (88b7684).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6369   +/-   ##
=======================================
  Coverage   95.60%   95.60%           
=======================================
  Files         599      599           
  Lines       47221    47221           
  Branches    15024    15024           
=======================================
  Hits        45147    45147           
  Misses       1290     1290           
  Partials      784      784           
Flag Coverage Δ
shard-1 44.07% <ø> (-0.11%) ⬇️
shard-2 36.60% <ø> (+0.20%) ⬆️
shard-3 32.59% <ø> (+0.06%) ⬆️
shard-4 34.73% <ø> (+0.12%) ⬆️
shard-5 31.60% <ø> (+<0.01%) ⬆️
shard-6 44.87% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 16, 2026
@loopover-orb

loopover-orb Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-16 05:36:19 UTC

2 files · 1 AI reviewer · no blockers · readiness 95/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This closes #6258 by adding `(`, `[`, and `:` to the prefix-delimiter class in the shared `redactLocalPath` heuristic, and excludes `]` from the path-segment/tail character sets so bracket-wrapped paths redact cleanly. I traced the regex by hand: the new `:` delimiter does not cause false positives on URLs like `http:​//example.com/path` because the immediate double-slash after the root causes `pathTail`/`pathSegment` (which exclude `/`) to fail to match, so the scheme-prefixed case is naturally excluded. The three new regression tests (parenthesis, bracket, colon) each map directly to the exact failure mode described and pass against the shown implementation.

Nits — 4 non-blocking
  • packages/loopover-mcp/lib/redact-local-path.js:29 — the second, no-delimiter fallback regex for mid-token `~/` and Windows-root paths still doesn't exclude `]` from its character class, so a bracket-wrapped mid-token tilde path with truly no leading delimiter could still swallow the closing bracket (low-probability overlap with the also-added `[` delimiter in the first pass, but worth a quick confirming test).
  • nit: the added `:` prefix delimiter is a fairly broad heuristic trigger (any `label:/root/path` shape) — worth a one-line comment or test noting the accepted false-positive surface (e.g. `ratio:/x` nonsense strings) is intentional, since it's not obvious from the diff alone that this tradeoff was deliberate.
  • Consider adding one more regression case for a same-line colon-prefixed path adjacent to a scheme-like string (e.g. `scheme:/single/slash/path`) to explicitly lock in that behavior as intentional rather than accidental.
  • The comment above the regex changes is good — consider also documenting the double-slash-blocks-URL-false-positive property inline, since that's the subtlest part of why `:` is safe to add.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #6258
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 168 registered-repo PR(s), 84 merged, 10 issue(s).
Contributor context ✅ Confirmed Gittensor contributor joaovictor91123; Gittensor profile; 168 PR(s), 10 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Review context
  • Author: joaovictor91123
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 168 PR(s), 10 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Triage stale or unlinked PRs.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 16, 2026
@JSONbored
JSONbored merged commit 97e3e6b into JSONbored:main Jul 16, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(mcp): local-path redaction regex misses the most common stack-trace shape, risking a real path leak upstream

2 participants