fix(security): sanitize untrusted calendar text before rendering (audit bucket 5 — M1) - #6
Merged
Merged
Conversation
… (audit M1)
Event summary, description, location, and attendee names come from an external
iCal feed. An event the user did not author (a meeting invite, a shared or
subscribed calendar) could carry a {{query}}/{{renderer}} in its title or
description and have it execute in the user's graph when rendered.
Add sanitizeForBlock (parsing.ts): inserts a zero-width space inside each
{{ / }} token so it can't be parsed as a macro, visible text unchanged. Applied
to attendee name/email in formatParticipants and to summary/description/location
in insertJournalBlocks.
Scoped to macros only by user preference: page refs [[...]], block refs ((...)),
and #tags are left intact — they are inert and users legitimately put them in
their own event titles/descriptions and want them to link.
Tests: 43 pass; typecheck 0.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019cVCdCtNzUJmy1yen3JyBk
CR0CKER
force-pushed
the
fix/sanitize-block-fields
branch
from
July 20, 2026 18:21
36a52ca to
35a23ac
Compare
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.
What changed
Audit bucket 5, finding M1. Event summary, description, location, and attendee display names come from an external (possibly hostile or compromised) iCal feed and were rendered into Logseq blocks verbatim — with attendee names wrapped in
[[...]]. A crafted value could inject page refs, block refs, or{{macro}}/{{query}}/{{renderer}}into the user's graph.sanitizeForBlock(parsing.ts): inserts a zero-width space inside each Logseq control token ([[]]{{}}(())) so it can't be parsed as markup, while the visible text is unchanged.formatParticipants(inside the plugin's own[[ ]]wrapper, which still links correctly to a sanitized name) and to summary / description / location at the render site ininsertJournalBlocks.Why
Stored-injection from a third party: anyone who can place an entry on your calendar (a meeting invite, a shared calendar) controls these fields. Rendering them as live Logseq markup lets them create pages, run queries, or embed renderers in your notes.
Trade-off (intentional)
A calendar field that legitimately contains
[[...]]will no longer auto-link. That's the correct posture for untrusted external input — the plugin's own intentional links (participant names) still work because the wrapper is added around sanitized content.Testing
npm test: 42 pass (5 new), including a hostile-attendee-name case (evil]] {{query ...}}) asserting no parseable control token survives inside the link.npm run typecheck: 0 (blocking gate stays green).Reviewer note
No automated PR reviewer configured; self-reviewed — sanitization applied at all four untrusted render paths, behavior preserved for the undefined-field case, no secrets.
🤖 Generated with Claude Code
https://claude.ai/code/session_019cVCdCtNzUJmy1yen3JyBk