Commit ca31ad8
authored
docs(js-ts): inline-<script> JSON data-island XSS pattern (#80)
## Summary
Add a JavaScript/TypeScript security pattern for safely embedding
untrusted JSON into an inline `<script>` data island — a stored-XSS sink
distinct from the DOM sinks already in section 3.
## Came from
`/retro` sweep on 2026-07-05 of session `44c102fc` (2026-07-04).
Finding: B8 (a reusable web-security technique had been captured only in
cwd-scoped project-local memory) + B16 (hard-won technique). The class
was found and fixed while building a data dashboard.
## Change
- New **§3a** with BAD/GOOD examples and a poison-test verification
step, covering the three compounding footguns:
- `String.replace` interpreting `$'`/`$&`/`` $` ``/`$$` in the
*replacement* as substitution patterns (breakout via a `$'` in any
value);
- first-match-only replacement shipping a blank page when the template
reuses the variable name;
- case/whitespace bypass of naive `</script>` escaping. Safe form:
`replaceAll('<', '<')` + a function replacement + a distinct placeholder
token.
- Detection pattern **SA-JS-21** (`replaceAll('</script'…`).
- Changelog row.
## Test plan
- [ ] Skill Validation (markdown/link lint) passes
- [ ] Poison payloads (`</script>`, `$'`, `onerror=`) render inert with
the GOOD form
- [ ] SA-JS-21 regex matches the BAD `replaceAll('</script>', …)` line3 files changed
Lines changed: 72 additions & 0 deletions
File tree
- skills/security-audit
- references
- scripts/scanners
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
833 | 833 | | |
834 | 834 | | |
835 | 835 | | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
836 | 843 | | |
837 | 844 | | |
838 | 845 | | |
| |||
Lines changed: 53 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
137 | 188 | | |
138 | 189 | | |
139 | 190 | | |
| |||
761 | 812 | | |
762 | 813 | | |
763 | 814 | | |
| 815 | + | |
764 | 816 | | |
765 | 817 | | |
766 | 818 | | |
| |||
790 | 842 | | |
791 | 843 | | |
792 | 844 | | |
| 845 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
205 | 217 | | |
206 | 218 | | |
207 | 219 | | |
| |||
0 commit comments