Commit 82d3051
fix(network): enforce 160-entry protocol cap in read_headers (GHSA-438q-jx8f-cccv)
read_headers() relied on TrustedPreallocate which allows up to 1,409
CountedHeader entries per message — ~8.8x the Zcash protocol limit of
160. Unauthenticated peers could force excessive preallocation and parse
work by sending oversized headers messages.
Deserialize the CompactSize count explicitly and reject messages
exceeding MAX_HEADERS_PER_MESSAGE (160) before parsing any entries.
The new constant lives in zebra-chain so both zebra-network (receive)
and zebra-state (send) can reference the same protocol value.1 parent 273185f commit 82d3051
4 files changed
Lines changed: 58 additions & 28 deletions
File tree
- zebra-chain/src
- serialization
- zebra-network/src/protocol/external
- codec/tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
| 44 | + | |
44 | 45 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
12 | 17 | | |
13 | 18 | | |
14 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
678 | 679 | | |
679 | 680 | | |
680 | 681 | | |
681 | | - | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
682 | 695 | | |
683 | 696 | | |
684 | 697 | | |
| |||
Lines changed: 34 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
591 | | - | |
592 | | - | |
593 | | - | |
| 591 | + | |
| 592 | + | |
594 | 593 | | |
595 | | - | |
| 594 | + | |
596 | 595 | | |
597 | 596 | | |
598 | 597 | | |
599 | 598 | | |
600 | | - | |
601 | 599 | | |
602 | 600 | | |
603 | 601 | | |
604 | 602 | | |
605 | 603 | | |
606 | 604 | | |
607 | 605 | | |
608 | | - | |
609 | | - | |
610 | | - | |
| 606 | + | |
| 607 | + | |
611 | 608 | | |
612 | | - | |
613 | 609 | | |
614 | 610 | | |
615 | 611 | | |
616 | 612 | | |
617 | | - | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
618 | 641 | | |
619 | | - | |
620 | 642 | | |
621 | 643 | | |
622 | 644 | | |
623 | 645 | | |
624 | 646 | | |
625 | 647 | | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
| 648 | + | |
633 | 649 | | |
634 | 650 | | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | 651 | | |
641 | 652 | | |
642 | 653 | | |
| |||
0 commit comments