Commit 7a2f818
fix(security): harden media-URL SSRF guard against IPv6 transition bypass (v0.22.5) (#46)
* fix(security): harden media-URL SSRF guard against IPv6 transition bypass
Switch validateMediaUrl() from a range blocklist to a fail-closed
allowlist (only ipaddr.js "unicast" is permitted). The blocklist missed
the IPv6 transition ranges ipaddr.js can return (rfc6052/NAT64,
rfc6145/SIIT, 6to4, teredo, benchmarking, amt), letting an attacker
reach internal targets via a literal like
http://[64:ff9b::169.254.169.254]/ that encodes a private IPv4.
The allowlist closes the entire class, including any range future
ipaddr.js versions add. (GHSA-5286-6cm5-w3qv)
Also hardened, beyond the reported CVE:
- Extract embedded IPv4 from IPv4-mapped (::ffff:0:0/96) AND deprecated
IPv4-compatible (::/96) IPv6 before the range check, so an internal
IPv4 wrapped in IPv6 (e.g. ::a9fe:a9fe) cannot bypass the guard.
- Validate ALL resolved DNS records, not just the first, so a host with
a public record and a private sibling is rejected.
- allowedHosts matching normalizes IPs (embedded-IPv4 + IPv6 form) and
handles bracketed IPv6 literals; the IP escape hatch requires every
resolved address to be allowlisted.
Adds 12 tests covering the transition ranges, embedded-IPv4 forms,
multi-record resolution, and allowlist normalization (127 total, green).
Reported by tonghuaroot.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore(release): v0.22.5
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 9af424c commit 7a2f818
6 files changed
Lines changed: 396 additions & 131 deletions
File tree
- src/mcp
- primitives/essential/tools/__tests__
- utils
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
Lines changed: 21 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
22 | 27 | | |
23 | 28 | | |
24 | 29 | | |
| |||
35 | 40 | | |
36 | 41 | | |
37 | 42 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 47 | + | |
49 | 48 | | |
50 | 49 | | |
51 | 50 | | |
| |||
277 | 276 | | |
278 | 277 | | |
279 | 278 | | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
284 | 282 | | |
285 | 283 | | |
286 | 284 | | |
| |||
298 | 296 | | |
299 | 297 | | |
300 | 298 | | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
305 | 302 | | |
306 | 303 | | |
307 | 304 | | |
| |||
322 | 319 | | |
323 | 320 | | |
324 | 321 | | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
329 | 325 | | |
330 | 326 | | |
331 | 327 | | |
| |||
387 | 383 | | |
388 | 384 | | |
389 | 385 | | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
394 | 389 | | |
395 | 390 | | |
396 | 391 | | |
| |||
Lines changed: 23 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
| |||
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| |||
390 | 392 | | |
391 | 393 | | |
392 | 394 | | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
397 | 398 | | |
398 | 399 | | |
399 | 400 | | |
| |||
418 | 419 | | |
419 | 420 | | |
420 | 421 | | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | | - | |
453 | | - | |
| 452 | + | |
| 453 | + | |
454 | 454 | | |
455 | 455 | | |
456 | 456 | | |
| |||
502 | 502 | | |
503 | 503 | | |
504 | 504 | | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
| 505 | + | |
509 | 506 | | |
510 | 507 | | |
511 | 508 | | |
| |||
530 | 527 | | |
531 | 528 | | |
532 | 529 | | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
537 | 533 | | |
538 | 534 | | |
539 | 535 | | |
| |||
563 | 559 | | |
564 | 560 | | |
565 | 561 | | |
566 | | - | |
567 | | - | |
| 562 | + | |
| 563 | + | |
568 | 564 | | |
569 | 565 | | |
570 | 566 | | |
| |||
597 | 593 | | |
598 | 594 | | |
599 | 595 | | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
| 596 | + | |
604 | 597 | | |
605 | 598 | | |
606 | 599 | | |
| |||
0 commit comments