- Overview
- Input & Metadata Handling
- File-System Boundaries
- Runtime Safeguards
- Dependency & Release Hygiene
Legal Markdown JS processes untrusted markdown/YAML supplied by authors. Security controls focus on preventing prototype pollution, directory traversal and script injection while keeping the CLI/browser experiences predictable.
- YAML parsing uses
js-yamlin safe mode; Phase 1 merges metadata throughmergeMetadata, which copies plain objects and filters out__proto__keys - Force-commands run as string templates only; there is no evaluation of raw JavaScript - helper functions exposed to templates are whitelisted and implemented in TypeScript
- Template field resolution escapes values when necessary; HTML/PDF outputs rely on remark-stringify + HtmlGenerator, which avoid injecting raw script blocks
- Frontmatter merges honour
disableFrontmatterMerge,validateImportTypesandlogImportOperationsflags so operators can inspect or block potentially unsafe metadata coming from imports
- CLI resolves paths relative to the provided
basePathand rejects missing files early - The import plugin is limited to markdown documents on disk; future work
tracked in
plans/2026-03-03-phase2-phase3-span-refactor-plan.mdcovers additional restrictions (e.g., import allowlists) - Archive manager writes to user-chosen directories but never deletes source files
- Debug logging is gated behind
options.debugto avoid leaking metadata in standard runs - Plugin order validation prevents misconfiguration that could surface raw template expressions or bypass sanitising plugins
- Browser bundle runs inside a web worker so unexpected long-running processing does not freeze the UI thread
- Dependency updates run through
npm auditand GitHub Dependabot alerts - Release automation (
semantic-release) executes linting, type checking and the full Vitest suite before publishing - Optional downloads such as Puppeteer are pinned to known-good versions and can be skipped via environment variables in hardened environments
Security is an ongoing effort. Any feature that touches metadata parsing, filesystem access or external execution should start with a threat analysis and update this document with new mitigations.
- MAX_YAML_SIZE: 1MB
- MAX_YAML_DEPTH: 20
- MAX_YAML_ALIAS_REFS: 100 Circular import detection uses canonical path resolution (maxDepth=10).