status-network-token icon indicating copy to clipboard operation
status-network-token copied to clipboard

Potential overflow for function `updateValueAtNow`

Open aoli-al opened this issue 5 years ago • 1 comments

Hi,

I'm running a tool that detects vulnerable contracts. While analyzing MiniMeToken, we found that function updateValueAtNow takes a uint256 and further cast it into a uint128. Some overflow attacks can be performed because of this:

in function generateTokens if curTotalSupply + _amount is larger than 2**128 but smaller than 2**256. The overflow check in line 422 can be bypassed. However, _value passed to updateValueAtNow is larger than 2**128, which will wrap around and start from 0.

A potential fix is to add one check before the value is stored(line 500 and 503):

require(_value < 2**128);

aoli-al avatar Nov 12 '18 17:11 aoli-al

@Leeleo3x : except this doesn’t apply because those values being used derived from actual Ether.

ytrezq avatar Sep 16 '19 00:09 ytrezq