Commit 748c20f
committed
Merged PR 15120207: Fix heap buffer overflow in SymCryptXmssSign when height >= 32
Fix for MSRC 111294: SymCryptXmssSign function - Heap overflow via 64->32-bit leaf-count truncation
This PR fixes heap buffer overflow in `SymCryptXmssSign` when signing with XMSS^MT parameter sets with a height of 32 or greater. Note that XMSS(^MT) signing is only approved by FIPS and Microsoft SDL when performed inside an HSM; XMSS(^MT) signing in SymCrypt is provided only for testing and validation purposes and should not be used in production software.
- Update callers of `SymCryptHbsSizeofScratchBytesForIncrementalTreehash` to consistently use `1ULL << pParams->nLayerHeight` for `nLeaves` - since XMSS^MT operations are done layer-by-layer, scratch space should only allocate space for one layer (consistent with how `SymCryptXmssVerifyInternal` already worked)
- Add regression test with custom parameter set to exercise 32-deep tree
Validated:
- Local unit tests
- Validated POC on VM: ASAN crashes without fix, does not crash with fix
Thanks to [Federico Ponzi](https://fponzi.me) for finding this.
Related work items: #615601041 parent e615174 commit 748c20f
6 files changed
Lines changed: 618 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5096 | 5096 | | |
5097 | 5097 | | |
5098 | 5098 | | |
| 5099 | + | |
| 5100 | + | |
| 5101 | + | |
| 5102 | + | |
| 5103 | + | |
| 5104 | + | |
| 5105 | + | |
| 5106 | + | |
| 5107 | + | |
| 5108 | + | |
| 5109 | + | |
| 5110 | + | |
| 5111 | + | |
| 5112 | + | |
| 5113 | + | |
| 5114 | + | |
| 5115 | + | |
| 5116 | + | |
| 5117 | + | |
| 5118 | + | |
| 5119 | + | |
| 5120 | + | |
| 5121 | + | |
| 5122 | + | |
| 5123 | + | |
| 5124 | + | |
| 5125 | + | |
| 5126 | + | |
| 5127 | + | |
| 5128 | + | |
| 5129 | + | |
| 5130 | + | |
| 5131 | + | |
| 5132 | + | |
| 5133 | + | |
| 5134 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
420 | | - | |
421 | | - | |
| 420 | + | |
| 421 | + | |
422 | 422 | | |
423 | 423 | | |
424 | 424 | | |
| |||
720 | 720 | | |
721 | 721 | | |
722 | 722 | | |
723 | | - | |
| 723 | + | |
| 724 | + | |
724 | 725 | | |
725 | | - | |
| 726 | + | |
| 727 | + | |
726 | 728 | | |
727 | 729 | | |
728 | 730 | | |
| |||
1015 | 1017 | | |
1016 | 1018 | | |
1017 | 1019 | | |
1018 | | - | |
1019 | | - | |
| 1020 | + | |
| 1021 | + | |
1020 | 1022 | | |
1021 | 1023 | | |
1022 | 1024 | | |
| |||
1078 | 1080 | | |
1079 | 1081 | | |
1080 | 1082 | | |
| 1083 | + | |
| 1084 | + | |
1081 | 1085 | | |
1082 | 1086 | | |
1083 | 1087 | | |
| |||
1751 | 1755 | | |
1752 | 1756 | | |
1753 | 1757 | | |
| 1758 | + | |
| 1759 | + | |
1754 | 1760 | | |
1755 | 1761 | | |
1756 | 1762 | | |
| |||
1761 | 1767 | | |
1762 | 1768 | | |
1763 | 1769 | | |
1764 | | - | |
| 1770 | + | |
1765 | 1771 | | |
1766 | 1772 | | |
1767 | 1773 | | |
| |||
2037 | 2043 | | |
2038 | 2044 | | |
2039 | 2045 | | |
2040 | | - | |
2041 | 2046 | | |
2042 | 2047 | | |
| 2048 | + | |
| 2049 | + | |
2043 | 2050 | | |
2044 | 2051 | | |
2045 | 2052 | | |
| |||
2050 | 2057 | | |
2051 | 2058 | | |
2052 | 2059 | | |
2053 | | - | |
| 2060 | + | |
2054 | 2061 | | |
2055 | 2062 | | |
2056 | 2063 | | |
| |||
0 commit comments