Skip to content

fix(md): escape template literal metacharacters in bash fence blocks#1457

Open
Mr-In4inci3le wants to merge 1 commit intogoogle:mainfrom
Mr-In4inci3le:fix/bash-fence-js-injection
Open

fix(md): escape template literal metacharacters in bash fence blocks#1457
Mr-In4inci3le wants to merge 1 commit intogoogle:mainfrom
Mr-In4inci3le:fix/bash-fence-js-injection

Conversation

@Mr-In4inci3le
Copy link
Copy Markdown

Bash fence blocks in transformMarkdown() embed content inside a JS tagged template literal (await $...``). This means ${...} and
Backtick characters in bash fence content were interpreted as JS template literal syntax rather than literal shell text.

This commit escapes \, `, and ${ in bash fence lines before embedding them in the template literal, so the content is always
treated as literal shell commands.

Normal shell syntax ($VAR, $(cmd)) is unaffected.

Security regression tests added to test/md.test.ts.

@Mr-In4inci3le
Copy link
Copy Markdown
Author

Hi @antonmedv @antongolub, just following up on this PR. Happy to make any changes or address feedback if needed. Thanks for your time!

@Mr-In4inci3le Mr-In4inci3le force-pushed the fix/bash-fence-js-injection branch from eaed090 to 927650b Compare April 27, 2026 21:46
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.

1 participant