Skip to content

Commit 5fe3ab1

Browse files
authored
Merge pull request #1 from BunsDev/okcode/fix-security-alerts
Harden preview security defaults and deps
2 parents 87db68e + 84f97d4 commit 5fe3ab1

27 files changed

Lines changed: 585 additions & 869 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ jobs:
3232

3333
- name: Install dependencies
3434
run: pnpm install --frozen-lockfile
35+
36+
- name: Run security audit
37+
run: pnpm run security-audit --strict
3538

3639
- name: Build packages
3740
run: pnpm run build

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const themed = applyPreviewTheme(raw); // wraps elements with cm-* classes
7373
```
7474

7575
Pair with any theme CSS (`github.css`, `github-dark.css`, `minimal.css`, or `system.css`) and the styled output just works.
76+
Sanitize untrusted HTML before assigning the themed output to the DOM.
7677

7778
### React Components
7879

@@ -117,6 +118,8 @@ const html = await renderAsync(blocks, {
117118
});
118119
```
119120

121+
Preview output is intended for trusted content by default. If the markdown or generated HTML can come from users, sanitize it before rendering.
122+
120123
### CSS Custom Property Theming
121124

122125
The `system.css` theme uses CSS custom properties so it adapts to any design system:
@@ -148,7 +151,7 @@ import '@create-markdown/preview/themes/system.css';
148151

149152
### BYO Sanitizer
150153

151-
Pass any sanitizer function instead of relying on a built-in implementation:
154+
Pass any sanitizer function when rendering untrusted content:
152155

153156
```typescript
154157
import { blocksToHTML } from '@create-markdown/preview';
@@ -193,6 +196,8 @@ Use `shadowMode: 'none'` to render in the light DOM and inherit page styles:
193196
registerPreviewElement({ shadowMode: 'none' });
194197
```
195198

199+
The web component also assumes trusted markdown by default, so sanitize user-provided content before passing it in.
200+
196201
## Documentation
197202

198203
| Document | Description |

SECURITY.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ We release patches for security vulnerabilities in the following versions:
66

77
| Version | Supported |
88
| ------- | ------------------ |
9-
| 1.x.x | :white_check_mark: |
10-
| < 1.0 | :x: |
9+
| 2.x.x | :white_check_mark: |
10+
| < 2.0 | :x: |
1111

1212
## Reporting a Vulnerability
1313

@@ -16,7 +16,7 @@ We take the security of create-markdown seriously. If you discover a security vu
1616
### How to Report
1717

1818
1. **Do not** open a public GitHub issue for security vulnerabilities
19-
2. Email your findings to **val@viewdue.ai** (replace with your actual security email)
19+
2. Email your findings to **val@viewdue.ai**
2020
3. Alternatively, use [GitHub's private vulnerability reporting](https://github.com/BunsDev/create-markdown/security/advisories/new)
2121

2222
### What to Include
@@ -51,10 +51,11 @@ We will not pursue civil action or initiate a complaint to law enforcement for a
5151
When using create-markdown in your projects:
5252

5353
1. **Sanitize User Input**: Always sanitize markdown content from untrusted sources before rendering
54-
2. **Keep Dependencies Updated**: Regularly update to the latest version to receive security patches
55-
3. **Content Security Policy**: Implement appropriate CSP headers when rendering markdown in browsers
56-
4. **Review Generated HTML**: Be cautious with HTML output, especially when allowing raw HTML in markdown
54+
2. **Treat Mermaid as Trusted by Default**: Use `mermaidPlugin({ config: { securityLevel: 'strict' } })` when diagram text can come from users
55+
3. **Keep Dependencies Updated**: Regularly update to the latest version to receive security patches
56+
4. **Content Security Policy**: Implement appropriate CSP headers when rendering markdown in browsers
57+
5. **Review Generated HTML**: Be cautious with HTML output, especially when allowing raw HTML in markdown
5758

5859
## Acknowledgments
5960

60-
We appreciate the security research community's efforts in helping keep create-markdown secure. Contributors who report valid security issues will be acknowledged here (with their permission).
61+
We appreciate the security research community's efforts in helping keep create-markdown secure. Contributors who report valid security issues will be acknowledged here (with their permission).

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,18 @@
3838
"devDependencies": {
3939
"@changesets/cli": "^2.27.0",
4040
"@testing-library/react": "^16.0.0",
41-
"@vitejs/plugin-react": "^4.3.0",
4241
"jsdom": "^25.0.0",
4342
"tsup": "^8.5.1",
4443
"tsx": "^4.21.0",
4544
"turbo": "^2.3.0",
4645
"typescript": "^5.3.0",
47-
"vitest": "^2.1.0"
46+
"vite": "^7.1.11",
47+
"vitest": "^4.1.2"
48+
},
49+
"pnpm": {
50+
"overrides": {
51+
"lodash-es": "4.18.1"
52+
}
4853
},
4954
"packageManager": "pnpm@10.11.1",
5055
"engines": {

packages/core/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# @create-markdown/core
22

3+
## 2.0.1
4+
5+
### Patch Changes
6+
7+
- Patch release to publish the security remediation update across all packages.
8+
9+
- refresh vulnerable dependency resolutions in the workspace
10+
- ship the pnpm-based security audit improvements
11+
- document trusted-content expectations for preview rendering
12+
313
## 2.0.0
414

515
### Major Changes

packages/core/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@create-markdown/core",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "Block-based markdown parsing and serialization with zero dependencies",
55
"author": "Val Alexander <val@viewdue.ai>",
66
"license": "MIT",
@@ -51,7 +51,8 @@
5151
},
5252
"devDependencies": {
5353
"typescript": "^5.3.0",
54-
"vitest": "^2.1.0"
54+
"vite": "^7.1.11",
55+
"vitest": "^4.1.2"
5556
},
5657
"engines": {
5758
"node": ">=20.0.0"

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,4 @@ export function toMarkdown(blocksOrDoc: Block[] | { blocks: Block[] }): string {
259259
/**
260260
* Package version
261261
*/
262-
export const VERSION = '2.0.0';
262+
export const VERSION = '2.0.1';

packages/create-markdown/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# create-markdown
22

3+
## 2.0.1
4+
5+
### Patch Changes
6+
7+
- Patch release to publish the security remediation update across all packages.
8+
9+
- refresh vulnerable dependency resolutions in the workspace
10+
- ship the pnpm-based security audit improvements
11+
- document trusted-content expectations for preview rendering
12+
13+
- Updated dependencies
14+
- @create-markdown/core@2.0.1
15+
- @create-markdown/react@2.0.1
16+
- @create-markdown/preview@2.0.1
17+
318
## 2.0.0
419

520
### Major Changes

packages/create-markdown/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-markdown",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "Complete block-based markdown notes package - convenience bundle for @create-markdown packages",
55
"author": "Val Alexander <val@viewdue.ai>",
66
"license": "MIT",

packages/create-markdown/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ export * from '@create-markdown/core';
1515
/**
1616
* Package version
1717
*/
18-
export const VERSION = '2.0.0';
18+
export const VERSION = '2.0.1';

0 commit comments

Comments
 (0)