Commit 085b7be
authored
sm2: fix SM2PKE decryption DoS vulnerability [SECURITY] (#1602)
This fixes a potential denial-of-service attack in the SM2PKE decryption
implementation originally reported as GHSA-78p6-6878-8mj6 by @XlabAITeam
The implementation parses the ciphertext, extracting the bytes that
represent the `C1` curve point, however previously after attempting to
invoke `AffinePoint::from_encoded_point` the result was subsequently
being `unwrap()`ed in the event the provided candidate encoded point is
not actually a valid point on the SM2 elliptic curve, leading to a
potential DoS in this case.
This is unfortunate because it was not caught by the
`clippy::unwrap_used` lint, most likely because the actual method being
invoked was `subtle::CtOption::unwrap` and it seems clippy does not
check for every "unwrap" method invocation on every type, only
`std::option::Option`/`Result`.
The problem was corrected by replacing the `unwrap` by converting to
`Result` and then propagating the error.1 parent 86ca4a6 commit 085b7be
1 file changed
+3
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
171 | 173 | | |
172 | 174 | | |
173 | 175 | | |
| |||
0 commit comments