Commit c2d4db5
committed
fix: restrict device icon data URI parsing to prevent path traversal
The base64 image regex used a greedy `.+` for the extension capture,
letting values like `data:image/png/../../foo;base64,...` flow into
path.join() in saveBase64DeviceIcon and produce arbitrary file writes
via bridge/request/device/options. Anchor the regex, constrain the
extension and data character classes to safe sets, and reject
extensions outside an explicit allowlist.
Includes a regression test for non-allowlisted image extensions via
bridge/request/device/options.1 parent 3785e4a commit c2d4db5
2 files changed
Lines changed: 23 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
386 | 387 | | |
387 | 388 | | |
388 | 389 | | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
389 | 396 | | |
390 | | - | |
| 397 | + | |
391 | 398 | | |
392 | 399 | | |
393 | 400 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3442 | 3442 | | |
3443 | 3443 | | |
3444 | 3444 | | |
| 3445 | + | |
| 3446 | + | |
| 3447 | + | |
| 3448 | + | |
| 3449 | + | |
| 3450 | + | |
| 3451 | + | |
| 3452 | + | |
| 3453 | + | |
| 3454 | + | |
| 3455 | + | |
| 3456 | + | |
| 3457 | + | |
| 3458 | + | |
3445 | 3459 | | |
3446 | 3460 | | |
3447 | 3461 | | |
| |||
0 commit comments