Commit b0db69d
committed
feat(mdviewer): add Content-Security-Policy to block injected scripts
Add CSP meta tag to md viewer iframe HTML:
- script-src 'self': blocks inline scripts and external script URLs
from markdown content, only allows the bundled mdviewer JS
- connect-src 'self': blocks fetch/XHR to external URLs, preventing
data exfiltration even if a script somehow executes
- img-src allows external URLs (needed for markdown images)
- style-src allows self + unsafe-inline (needed for element positioning)
Combined with the existing iframe sandbox (no allow-same-origin),
this provides defense-in-depth against malicious markdown content.1 parent 79696f0 commit b0db69d
1 file changed
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
7 | 14 | | |
8 | 15 | | |
9 | 16 | | |
| |||
0 commit comments