Unsafe cast from uint256
to uint32
in the TempleGold::mint
function which can cause the TempleGold::mint
function keep reverting and hence disrupt the protocol.
The TempleGold::mint
function casts block.timestamp
of type uint256
to a type uint32
. In the event block.timestamp
exceeds type(uint32).max
, the solidity compiler will throw an overflow
error and revert. This means that this unsafe casting can prevent the protocol from minting TGLD
when there is no conditions are violated causing a breach in the protocol.
If ever the block.timestamp
exceeds type(uint32).max
, the TempleGold
contract will not be able to set the lastMintTimestamp
because the the solidity compiler will revert with an overflow
issue preventing the protocol from minting tokens.
A simple demonstration in foundry
using chisel
demonstrates that solidity compiler reverts whenever it encounters an arithmetic overflow
or underflow
. In our demonstration, we defined a variable of type uint32
and assigned it a value slightly above type(uint32).max
and the compiler did not complete the assignment operation but reverted
In order to avoid unsafe casting of uint256
to uint32
, we recommend as follows:
the lastMintTimestamp
variable be changed from a uint32
to a uint256
as follows
modify the TempleGold::mint
function to remove the unsafe casting
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.