fix(template): neutralize feed-controlled note injection#228
Merged
Conversation
Feed-controlled fields are written into generated notes by the template
engines without escaping, letting a malicious RSS feed inject Markdown,
external/tracking images, phishing links, Obsidian wikilinks, and
(speculatively) executable Dataview code blocks into a reader's vault.
- Escape raw {{title}}/{{author}} via sanitizeInlineText: collapse control
characters to spaces (no line/block breakout from `# {{title}}`) and
neutralize the link/image/inline-code/raw-HTML metacharacters, while
keeping ordinary punctuation readable.
- Percent-encode all URL tags (artwork/stream/url/feedurl/feed*/episode*)
via a broadened sanitizeUrlForTemplate so a crafted value cannot break
out of ``/`[](...)`, inject a line, or terminate a quoted YAML
scalar. {{url}}/{{episodeurl}} still pass a trusted local-file vault
wikilink through verbatim (isLocalFile gate).
- Strip `[` and `]` in replaceIllegalFileNameCharactersInString so a feed
<title> cannot inject a wikilink through {{podcast}}/{{safetitle}}/
{{podcastlink}} (getFeedNoteWikilink).
- Render injected Dataview code fences (```dataviewjs/```dataview, ~~~,
any blockquote/callout/list container) inert via feedHtmlToMarkdown.
Legitimate show-note rich text (links, images, normal code blocks) is
preserved by design.
Applied consistently across NoteTemplateEngine, FeedNoteTemplateEngine,
and TranscriptTemplateEngine. Adds unit tests proving each malicious input
is neutralized and legitimate input is preserved.
Fixes deepsec findings other-markdown-injection and other-wikilink-injection.
Deploying podnotes with
|
| Latest commit: |
3f2ae1c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b22d7db2.podnotes.pages.dev |
| Branch Preview URL: | https://chhoumann-deepsec-note-injec.podnotes.pages.dev |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a371df8771
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Address PR #228 review (Codex P1): isLocalFile() alone keys off podcastName === "local file", which the feed parser sets from the channel <title>. A feed titled exactly "local file" would make NoteTemplateEngine / TranscriptTemplateEngine treat its episode as a trusted local file and skip sanitizeUrlForTemplate for {{url}}/{{episodeurl}}, bypassing the injection fix on the bare {{url}} line. Gate the verbatim passthrough on episode.filePath in addition to isLocalFile: filePath is set only by getContextMenuHandler for genuine local files and never by feedParser, so a feed cannot forge it. Factored into a resolveEpisodeUrl helper shared by both engines. Adds a regression test for the forged-"local file" feed title and updates local-file fixtures to carry the realistic filePath.
github-actions Bot
pushed a commit
that referenced
this pull request
Jul 9, 2026
## [2.17.3](2.17.2...2.17.3) (2026-07-09) ### Bug Fixes * **feed/search:** parse feed once + content-based search cache ([#225](#225)) ([053d51f](053d51f)), closes [#149](#149) * make episode identity key collision-resistant and prototype-safe ([#226](#226)) ([a5683db](a5683db)) * **opml:** correct import progress math and saved-count reporting ([#221](#221)) ([a79e529](a79e529)) * **security:** validate feed/URI URLs and cap download size ([#223](#223)) ([edef281](edef281)) * **template:** neutralize feed-controlled note injection ([#228](#228)) ([ef4ecbd](ef4ecbd)) * **timestamp:** escape live table-cell pipe after an escaped backslash ([#227](#227)) ([a34dfca](a34dfca)) * **transcription:** resolve three deepsec transcription-pipeline bugs ([#224](#224)) ([83c34e7](83c34e7))
Contributor
|
🎉 This PR is included in version 2.17.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Summary
Feed-controlled fields are written into generated notes by the template engines in
src/TemplateEngine.tswithout escaping. A malicious RSS feed can therefore inject Markdown, external/tracking images, phishing links, Obsidian[[wikilinks]], and (speculatively) executable Dataview code blocks into a reader's vault.This fixes two deepsec-confirmed findings, both scoped to
src/TemplateEngine.ts:other-markdown-injection(adb1a853c0) - raw{{title}}/URL tags (artwork/stream/url/feedurl/feed*/episode*) andhtmlToMarkdown'd{{description}}/{{content}}injected verbatim. The headline attack: a craftedartworkUrllikex) [click](http://phish)breaks out of the default template'sto inject external tracking images / phishing links.other-wikilink-injection(7a7cf39683) -replaceIllegalFileNameCharactersInStringdid not strip[/], so a feed<title>such asReal]] [[Victims Private Noteinjects an extra wikilink into every episode note'spodcast:frontmatter via{{podcastlink}}.What changed (
src/TemplateEngine.ts){{title}}, feed{{title}}/{{author}}) - newsanitizeInlineText: collapses control characters to spaces (no line/block breakout from# {{title}}) and neutralizes link/image/inline-code/raw-HTML metacharacters ([ ] < > \``), while keeping ordinary punctuation readable (deliberately lighter thanescapeMarkdownText`).sanitizeUrlForTemplatepercent-encodes the characters that would break a Markdown link/image target, a bare-line autolink, or a quoted YAML scalar (control/space/"'\()[]<>\), losslessly for real URLs.{{url}}/{{episodeurl}}still pass a trusted **local-file** vault wikilink through verbatim (isLocalFile` gate); feed URLs are sanitized.replaceIllegalFileNameCharactersInStringnow also strips[/], closing the wikilink injection through{{podcast}}/{{safetitle}}/{{podcastlink}}.feedHtmlToMarkdownrenders injected Dataview fences (```dataviewjs/```dataview,~~~, in any container: top-level, blockquote, callout, or list item) inert. A 3+ fence run followed by the language token only ever occurs as a code-fence info string, so the container-agnostic rewrite is always safe.Applied consistently across
NoteTemplateEngine,FeedNoteTemplateEngine, andTranscriptTemplateEngine.Deliberately preserved (not bugs)
{{description}}/{{content}}(links, images, ordinary code blocks) is the feature, so it is kept. A feed can still place an external image (readers can disable external-image loading in Obsidian) or a literal[[wikilink]]in this free-text body; unlike the structured tags these are accepted as show-note content.`= `/`$= `) are a documented residual of the same speculative, Dataview-must-be-installed class - not rewritten to avoid mangling legitimate inline code in programming show notes.Behavior-change note
Adding
[/]to the file-name sanitizer also affects derived download/note paths: a title likeEpisode [Bonus]now yieldsEpisode Bonus. Acceptable for the wikilink-injection fix.Tests
New/updated unit tests in
src/TemplateEngine.test.tsprove each malicious input is neutralized and legitimate input is preserved: artwork![]()breakout, feed{{url}}/{{stream}}injection, raw{{title}}newline/Markdown injection,dataviewjsfences (incl. blockquote/callout, 4-space list indent, and long-fence-desync regressions from adversarial review), wikilink injection viapodcastName, a feed-forged[[...]]url, and local-file wikilink passthrough.Validation
npm run lint,typecheck,build,test- all green (872 tests).htmlToMarkdownoutput shape was validated against Obsidian's Turndown-based converter during review.Do not merge yet - opening as draft for maintainer review.