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
It is possible to cause `add` and `sub` to overflow (or underflow) on any type of integer in Solidity.
3
+
It is possible to cause `+` and `-` to overflow (or underflow) on any type of integer in Solidity versions <0.8.0 or within `unchecked` blocks of solidity >=0.8.0
4
4
5
5
## Attack Scenarios
6
6
@@ -12,13 +12,14 @@ the array and alter other variables in the contract.
12
12
13
13
## Mitigations
14
14
15
-
- Use openZeppelin's [safeMath library](https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol)
16
-
- Validate all arithmetic
15
+
- Use solidity >=0.8.0 and use `unchecked` blocks carefully and only where required.
16
+
- If using solidity <0.8.0, use OpenZeppelin's [SafeMath library](https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol) for arithmetic.
17
+
- Validate all arithmetic with both manual review and property-based fuzz testing.
17
18
18
19
## Examples
19
20
20
21
- In [integer_overflow_1](interger_overflow_1.sol), we give both unsafe and safe version of
21
22
the `add` operation.
22
23
23
-
-[A submission](https://github.com/Arachnid/uscc/tree/master/submissions-2017/doughoyte) to the Underhanded Solidity Coding Contest that explots the unsafe dynamic array bug outlined above
24
+
-[A submission](https://github.com/Arachnid/uscc/tree/master/submissions-2017/doughoyte) to the Underhanded Solidity Coding Contest that exploits the unsafe dynamic array bug outlined above
0 commit comments