Commit dc91502
committed
fix(chat): give the hand-off card a CSP and a nonced script
Review, and correct: detachedHtml() served a webview document with an inline
<script> and no Content-Security-Policy, while getHtml() and getSessionsHtml()
both inject CSP + nonce. Small is not exempt — the card enables scripts and
carries one, so it was the single document in the extension whose script surface
was undescribed. Worse than untidy: a later tightening elsewhere would have
silently stopped its button from working, and "Bring it back" is the only way out
of the detached state short of closing the tab.
Rather than a third copy of the policy, the construction moves into webviewCsp()
and all three documents call it. It had already been duplicated twice; a third
would have made "tighten the CSP" a three-file change with one easy to miss.
Verified by rendering the card and reading it back:
CSP default-src 'none'; style-src 'unsafe-inline'; script-src 'nonce-…'
script nonce matches the policy
no remote origins allowed
Two guards, verified non-vacuous four ways — drop the meta (12/15), unnonce the
script (12/15), hand-roll a third copy of the policy (13/15), bypass the helper
in getHtml (13/15). One of them asserts the policy string exists exactly ONCE in
the file, so the next document cannot quietly hand-roll its own.
33 suites green.1 parent 599e041 commit dc91502
2 files changed
Lines changed: 59 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2287 | 2287 | | |
2288 | 2288 | | |
2289 | 2289 | | |
2290 | | - | |
| 2290 | + | |
| 2291 | + | |
| 2292 | + | |
| 2293 | + | |
| 2294 | + | |
| 2295 | + | |
| 2296 | + | |
2291 | 2297 | | |
| 2298 | + | |
2292 | 2299 | | |
2293 | 2300 | | |
| 2301 | + | |
2294 | 2302 | | |
2295 | 2303 | | |
2296 | 2304 | | |
| |||
2303 | 2311 | | |
2304 | 2312 | | |
2305 | 2313 | | |
2306 | | - | |
| 2314 | + | |
2307 | 2315 | | |
2308 | 2316 | | |
2309 | 2317 | | |
2310 | | - | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
2311 | 2328 | | |
2312 | | - | |
| 2329 | + | |
2313 | 2330 | | |
2314 | 2331 | | |
2315 | 2332 | | |
2316 | | - | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
2317 | 2338 | | |
2318 | 2339 | | |
2319 | 2340 | | |
| |||
2346 | 2367 | | |
2347 | 2368 | | |
2348 | 2369 | | |
2349 | | - | |
2350 | | - | |
2351 | | - | |
2352 | | - | |
2353 | | - | |
2354 | | - | |
| 2370 | + | |
2355 | 2371 | | |
2356 | 2372 | | |
2357 | 2373 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
173 | 205 | | |
174 | 206 | | |
175 | 207 | | |
| |||
0 commit comments