You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Detects <code>if (a+b>c) a=c-b</code>, which incorrectly implements
9
+
<code>a = min(a,c-b)</code> if <code>a+b</code> overflows.
10
+
</p>
11
+
<p>
12
+
Also detects variants such as <code>if (b+a>c) a=c-b</code> (swapped
13
+
terms in addition), <code>if (a+b>c) { a=c-b }</code> (assignment
14
+
inside block), <code>c<a+b</code> (swapped operands), and
15
+
<code>>=</code>, <code><</code>, <code><=</code> instead of
16
+
<code>></code> (all operators).
17
+
</p>
18
+
<p>
19
+
This integer overflow is the root cause of the buffer overflow in
20
+
the SHA-3 reference implementation (CVE-2022-37454).
21
+
</p>
22
+
</overview>
23
+
<recommendation>
24
+
<p>
25
+
Replace by <code>if (a>c-b) a=c-b</code>. This avoids the overflow
26
+
and makes it easy to see that <code>a = min(a,c-b)</code>.
27
+
</p>
28
+
</recommendation>
29
+
<references>
30
+
<li>CVE-2022-37454: <ahref="https://nvd.nist.gov/vuln/detail/CVE-2022-37454">The Keccak XKCP SHA-3 reference implementation before fdc6fef has an integer overflow and resultant buffer overflow that allows attackers to execute arbitrary code or eliminate expected cryptographic properties. This occurs in the sponge function interface.</a></li>
31
+
<li>GitHub Advisory Database: <ahref="https://github.com/advisories/GHSA-6w4m-2xhg-2658">CVE-2022-37454: Buffer overflow in sponge queue functions</a></li>
0 commit comments