Repository navigation
Commit 11b0bb9
committed
fix(runtime): harden marshaling, release logging and remote loading
Marshaling (both the classic and napi engines):
- A pointer comes only from an External, a BigInt or null. A Number or string `handle` or
`__native_ptr` is refused, since JSON can carry those: `{"handle": 1094795585}` passed to
an Object parameter used to be AddRef'd as a COM pointer.
- Interface and class parameters QueryInterface every pointer, boxed primitives included, and
no longer fall back to the raw pointer when that fails, so a string passed as a Uri can't be
called through the wrong vtable. Delegate parameters accept JS delegates the runtime made and
QueryInterface anything else; GenericMethodCall fails instead of calling a slot on the wrong
interface.
- Shapes the call layout can't express (non-byte arrays, received arrays, array returns,
structs larger than the return buffer, JS delegates taking arrays) fail at construction
instead of corrupting the libffi call.
- Struct buffers must cover the struct, serialized structs are padded to their ABI size, and
IReference<T> struct fields are pointer-sized.
- Buffer arguments are rechecked before the call, since parsing a later argument can run JS
that detaches or resizes them.
- Only two-field wrappers are read as a DeclarationFFI, and URL accessors check their receiver,
so a URL passed to WinRT or `instanceof` is no longer read as the wrong type.
Release builds keep app console output out of the Windows Event Log and the on-disk trace log,
and the trace log no longer falls back to a hardcoded user directory.
Remote modules: allowlist entries match by origin and path boundary rather than string
prefix, the response's final URL must also pass the gate after redirects, the gate reads the
entry's package.json for script entries too, and NSWinRT.dynamicImport goes through the native
loader. WebSocket subprotocols must be HTTP tokens and a message is capped at 100 MiB.
Also: crypto.getRandomValues and crypto.randomUUID backed by the OS RNG, and NSWinRT.win32.bind
loads a bare DLL name from the app directory and System32 only.1 parent 7f82c69 commit 11b0bb9
24 files changed
Lines changed: 1004 additions & 395 deletions
File tree
- packages/test
- runtime/src
- globals
- js
- napi_engine
- windows-napi
- src
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
261 | | - | |
| 261 | + | |
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
267 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
268 | 282 | | |
269 | 283 | | |
270 | 284 | | |
| |||
277 | 291 | | |
278 | 292 | | |
279 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
280 | 299 | | |
281 | 300 | | |
282 | 301 | | |
| |||
340 | 359 | | |
341 | 360 | | |
342 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
343 | 369 | | |
344 | 370 | | |
345 | 371 | | |
| |||
403 | 429 | | |
404 | 430 | | |
405 | 431 | | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
406 | 458 | | |
407 | 459 | | |
408 | 460 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
| |||
93 | 98 | | |
94 | 99 | | |
95 | 100 | | |
96 | | - | |
97 | | - | |
| 101 | + | |
98 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
99 | 107 | | |
100 | 108 | | |
101 | 109 | | |
| |||
126 | 134 | | |
127 | 135 | | |
128 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
129 | 140 | | |
130 | 141 | | |
131 | 142 | | |
| |||
207 | 218 | | |
208 | 219 | | |
209 | 220 | | |
210 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
211 | 226 | | |
212 | | - | |
213 | | - | |
214 | | - | |
| 227 | + | |
215 | 228 | | |
216 | 229 | | |
217 | 230 | | |
218 | 231 | | |
219 | 232 | | |
220 | 233 | | |
221 | | - | |
222 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
223 | 241 | | |
224 | 242 | | |
225 | 243 | | |
| |||
237 | 255 | | |
238 | 256 | | |
239 | 257 | | |
240 | | - | |
| 258 | + | |
| 259 | + | |
241 | 260 | | |
242 | 261 | | |
243 | 262 | | |
| |||
246 | 265 | | |
247 | 266 | | |
248 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
249 | 271 | | |
250 | 272 | | |
251 | 273 | | |
| |||
267 | 289 | | |
268 | 290 | | |
269 | 291 | | |
| 292 | + | |
270 | 293 | | |
271 | 294 | | |
272 | 295 | | |
| |||
340 | 363 | | |
341 | 364 | | |
342 | 365 | | |
343 | | - | |
| 366 | + | |
344 | 367 | | |
345 | 368 | | |
346 | 369 | | |
| |||
352 | 375 | | |
353 | 376 | | |
354 | 377 | | |
| 378 | + | |
355 | 379 | | |
356 | 380 | | |
357 | 381 | | |
| |||
362 | 386 | | |
363 | 387 | | |
364 | 388 | | |
365 | | - | |
| 389 | + | |
366 | 390 | | |
367 | 391 | | |
368 | 392 | | |
| |||
430 | 454 | | |
431 | 455 | | |
432 | 456 | | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
433 | 461 | | |
434 | 462 | | |
435 | 463 | | |
| |||
0 commit comments