fix(reporter): escape pipes and newlines in Markdown table cells#23
Open
dmchaledev wants to merge 1 commit into
Open
fix(reporter): escape pipes and newlines in Markdown table cells#23dmchaledev wants to merge 1 commit into
dmchaledev wants to merge 1 commit into
Conversation
The Markdown reporter interpolated component names, versions, and CVE fields straight into table rows. SBOM-derived strings are attacker-influenced, so a package name containing `|` injected a phantom column and a newline started a new row — corrupting (or letting crafted input forge/hide entries in) the report. This matters because the README pitches the Markdown output for posting into PR comments. Add an escapeCell() helper that escapes `|` and flattens line breaks, and route every Markdown cell value through it. Output is unchanged for ordinary inputs; the empty/undefined fallback (—) is preserved. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FgX1cVFKBmvvypM4Bj8pdd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Markdown reporter interpolates component names, versions, and CVE fields directly into table rows with no escaping:
These strings come from the SBOM under inspection, whose package names and CVE descriptions are attacker-influenced. A
|in a value adds a phantom column; a newline starts a new row. Both corrupt the rendered table — or let crafted input forge/hide entries. This matters because the README pitches the Markdown output specifically for posting into PR comments.Reproduction (before)
A package named
evil | pkgproduces a 5-cell row in a 3-column table:CVE rows behave the same way (
affects: 'a | b'→ extra column).Fix
Add an
escapeCell()helper that escapes|(→\|) and flattens line breaks, and route every Markdown cell value through it. The existing empty/undefinedfallback (—) is preserved, so output is byte-for-byte unchanged for ordinary inputs.After
Scope
src/reporter.ts(themarkdownpath) and adds one test.textandjsonoutput are unaffected.Tests
Added a case asserting that
|is escaped (not treated as a column break) and that an Added-table body row keeps its exact column count. Full suite: 30 passing; lint and typecheck clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01FgX1cVFKBmvvypM4Bj8pdd
Generated by Claude Code