Commit fa4a9ef
committed
pkcs7,aes: reject truncated GCM auth tags
wc_PKCS7_DecodeAuthEnvelopedData() accepted an attacker-controlled GCM tag
length from the mac OCTET STRING and did not validate it against the
parsed aes-ICVlen parameter. In parallel, wc_AesGcmDecrypt() accepted
very short tags on decrypt while encrypt enforced WOLFSSL_MIN_AUTH_TAG_SZ.
This made short-tag verification reachable through CMS AuthEnvelopedData
and weakened integrity checks by allowing tag truncation.
Fixes:
- validate parsed macSz range in AuthEnvelopedData decode
- require authTagSz to match parsed macSz
- reject undersized GCM tags in PKCS7 decode
- enforce WOLFSSL_MIN_AUTH_TAG_SZ in wc_AesGcmDecrypt() and
wc_AesGcmDecryptFinal()
Also add a regression test in pkcs7authenveloped vectors that truncates
the final MAC OCTET STRING length from 16 to 1 and verifies decode fails.
Reported by: Nicholas Carlini (Anthropic) & Thai Duong (Calif.io)1 parent 929dd99 commit fa4a9ef
3 files changed
Lines changed: 67 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10217 | 10217 | | |
10218 | 10218 | | |
10219 | 10219 | | |
10220 | | - | |
10221 | | - | |
| 10220 | + | |
| 10221 | + | |
| 10222 | + | |
10222 | 10223 | | |
10223 | 10224 | | |
10224 | 10225 | | |
| |||
10781 | 10782 | | |
10782 | 10783 | | |
10783 | 10784 | | |
10784 | | - | |
10785 | | - | |
| 10785 | + | |
| 10786 | + | |
10786 | 10787 | | |
10787 | 10788 | | |
10788 | 10789 | | |
| |||
12473 | 12474 | | |
12474 | 12475 | | |
12475 | 12476 | | |
12476 | | - | |
| 12477 | + | |
12477 | 12478 | | |
12478 | 12479 | | |
12479 | 12480 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
| |||
14222 | 14223 | | |
14223 | 14224 | | |
14224 | 14225 | | |
| 14226 | + | |
| 14227 | + | |
| 14228 | + | |
| 14229 | + | |
14225 | 14230 | | |
14226 | 14231 | | |
14227 | 14232 | | |
| |||
14267 | 14272 | | |
14268 | 14273 | | |
14269 | 14274 | | |
14270 | | - | |
| 14275 | + | |
| 14276 | + | |
14271 | 14277 | | |
14272 | 14278 | | |
14273 | 14279 | | |
| |||
14458 | 14464 | | |
14459 | 14465 | | |
14460 | 14466 | | |
| 14467 | + | |
14461 | 14468 | | |
14462 | 14469 | | |
14463 | 14470 | | |
| |||
14474 | 14481 | | |
14475 | 14482 | | |
14476 | 14483 | | |
| 14484 | + | |
| 14485 | + | |
| 14486 | + | |
| 14487 | + | |
| 14488 | + | |
| 14489 | + | |
| 14490 | + | |
| 14491 | + | |
| 14492 | + | |
| 14493 | + | |
| 14494 | + | |
14477 | 14495 | | |
14478 | 14496 | | |
14479 | 14497 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57660 | 57660 | | |
57661 | 57661 | | |
57662 | 57662 | | |
| 57663 | + | |
| 57664 | + | |
| 57665 | + | |
57663 | 57666 | | |
57664 | 57667 | | |
57665 | 57668 | | |
| |||
58171 | 58174 | | |
58172 | 58175 | | |
58173 | 58176 | | |
| 58177 | + | |
| 58178 | + | |
| 58179 | + | |
| 58180 | + | |
| 58181 | + | |
| 58182 | + | |
| 58183 | + | |
| 58184 | + | |
| 58185 | + | |
| 58186 | + | |
| 58187 | + | |
| 58188 | + | |
| 58189 | + | |
| 58190 | + | |
| 58191 | + | |
| 58192 | + | |
| 58193 | + | |
| 58194 | + | |
| 58195 | + | |
| 58196 | + | |
| 58197 | + | |
| 58198 | + | |
| 58199 | + | |
| 58200 | + | |
| 58201 | + | |
| 58202 | + | |
| 58203 | + | |
| 58204 | + | |
| 58205 | + | |
| 58206 | + | |
| 58207 | + | |
| 58208 | + | |
| 58209 | + | |
| 58210 | + | |
| 58211 | + | |
| 58212 | + | |
| 58213 | + | |
| 58214 | + | |
| 58215 | + | |
58174 | 58216 | | |
58175 | 58217 | | |
58176 | 58218 | | |
| |||
0 commit comments