Repository navigation
Commit b926504
feat: sanitise uploaded HTML and SVG
Every HTML and SVG document written through da-admin is now reduced to
the DA/Helix document format and stripped of XSS vectors before it is
stored or forwarded.
- src/utils/sanitize.js: parse5-based (hast-util-from-html) sanitiser
with a DA allowlist (hast-util-sanitize) derived from da-parser's
schema. Enforces the DA structure (header/main sections/footer,
da-metadata), keeps the head subset html2md ingests, and returns the
original bytes when nothing changed, so collab output, ETags and the
empty-doc restore point are unaffected. SVG is re-serialised from an
allowlist without scripts, handlers, animation, foreignObject or
external references; CSS loses @import and external url().
- Hooks: POST/PUT /source (incl. collab and the HLX6 dual-write),
HLX6 saveSource before forwarding, and POST /media for SVG.
Mismatched extension/content type -> 415, oversize -> 413. Changed
collab writes are logged but collab is not reset.
- daResp: Content-Security-Policy (default-src 'none'; img-src 'self'
https: data:; sandbox) and X-Content-Type-Options: nosniff on every
response.
- DA_SANITIZE=off kill switch; OpenAPI docs updated.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 29c883e commit b926504
15 files changed
Lines changed: 1870 additions & 77 deletions
File tree
- docs/openapi
- src
- helpers
- routes
- utils
- test
- routes
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
44 | 51 | | |
45 | 52 | | |
46 | 53 | | |
| |||
72 | 79 | | |
73 | 80 | | |
74 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
75 | 86 | | |
76 | 87 | | |
77 | 88 | | |
| |||
91 | 102 | | |
92 | 103 | | |
93 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
94 | 112 | | |
95 | 113 | | |
96 | 114 | | |
| |||
125 | 143 | | |
126 | 144 | | |
127 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
128 | 150 | | |
129 | 151 | | |
130 | 152 | | |
| |||
0 commit comments