Skip to content

fix(review): harden impact map path markdown#4078

Merged
JSONbored merged 1 commit into
mainfrom
codex/propose-fix-for-markdown-injection-vulnerability
Jul 7, 2026
Merged

fix(review): harden impact map path markdown#4078
JSONbored merged 1 commit into
mainfrom
codex/propose-fix-for-markdown-injection-vulnerability

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • The impact-map rows previously wrapped contributor-controlled file paths in single-backtick code spans and attempted to backslash-escape embedded backticks, which is insufficient to prevent Markdown breakout and allowed attacker-crafted filenames to inject Markdown into trusted PR comments.
  • Filenames can include CR/LF and other control characters that break table rows and permit content injection unless normalized and rendered defensively.

Description

  • Replaced the prior backslash-escaping strategy with a safe renderer that normalizes CR/LF and other control characters, entity-escapes table/HTML metacharacters, computes the longest run of backticks in the value, and uses a code-span delimiter of length longestBacktickRun + 1 so embedded backticks cannot close the span (see markdownPathCode in src/review/unified-comment-bridge.ts).
  • Continued to use the hardened markdownPathCode for both changed-module and affected-module cells so all impact-map paths are consistently protected.
  • Added regression tests in test/unit/impact-map-collapsible.test.ts that assert safe rendering for hostile filenames containing backticks, pipes, angle-brackets, and newline-separated Markdown content.

Testing

  • Ran npx vitest run test/unit/impact-map-collapsible.test.ts and the unit suite passed (15 tests passed).
  • Ran npm run typecheck (i.e., tsc --noEmit) and type checking passed without errors.
  • git diff --check was run and returned no issues.
  • Attempted coverage with npx vitest run ... --coverage and the tests executed but coverage remapping failed with TypeError: jsTokens is not a function (coverage remapping error outside this change); and npm audit --audit-level=moderate failed due to the registry audit endpoint returning 403 Forbidden (environmental/registry issue rather than a code regression).

Codex Task

@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.63%. Comparing base (3356fc6) to head (78879b5).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4078   +/-   ##
=======================================
  Coverage   93.63%   93.63%           
=======================================
  Files         384      384           
  Lines       35822    35825    +3     
  Branches    13146    13146           
=======================================
+ Hits        33543    33546    +3     
  Misses       1618     1618           
  Partials      661      661           
Files with missing lines Coverage Δ
src/review/unified-comment-bridge.ts 99.54% <100.00%> (+<0.01%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

loopover-orb Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-07 23:53:04 UTC

2 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI green · unstable

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
Replaces the prior backslash-escaping of backticks inside inline code spans (invalid under CommonMark, since code spans don't process backslash escapes) with the correct longest-backtick-run+1 delimiter technique, plus CR/LF and control-character normalization and entity-escaping of |/</> for the impact-map path cells in unified-comment-bridge.ts. I traced the delimiter math and CommonMark's space-stripping rule by hand against every new/changed test assertion in impact-map-collapsible.test.ts, including the new multi-line hostile-markdown injection test, and the output matches what the code actually produces on the real buildImpactMapCollapsible path — this is a genuine, narrowly-scoped security hardening fix, not a can't-occur guard or a fabricated test. CI is green across the board.

Nits — 5 non-blocking
  • markdownPathCode escapes |, <, and > but not &, a minor inconsistency for a fully HTML-safe table cell even though it isn't the exploitable vector here.
  • The control-character normalization regex skips tab (\u0009) while normalizing most other control chars and CR/LF — unlikely to break a table row but worth a follow-up look.
  • The removed comment said this helper mirrored buildBeforeAfterCollapsible's markdownCode; worth confirming that sibling helper gets the same longest-backtick-run treatment for consistency (not visible in this diff).
  • The PR description doesn't link an open tracked issue, which this repo's contribution policy calls for even on security-motivated fixes.
  • Verify/align markdownCode in buildBeforeAfterCollapsible with the same longest-backtick-run + padded-delimiter technique used here, for consistency across all path-rendering helpers in this file.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
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 (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 51 registered-repo PR(s), 43 merged, 503 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 51 PR(s), 503 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, JavaScript, Ruby, Go, Kotlin, MDX, Shell
  • Official Gittensor activity: 51 PR(s), 503 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
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.

🟩 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 Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 7, 2026
@JSONbored
JSONbored merged commit e8f715c into main Jul 7, 2026
10 checks passed
@JSONbored
JSONbored deleted the codex/propose-fix-for-markdown-injection-vulnerability branch July 7, 2026 23:53
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

Development

Successfully merging this pull request may close these issues.

1 participant