Blacksmith in which the vulnerability was found. If you know the exact name of the affected protocol or vulnerable contract you can also search for it directly.



Blacksmith: pool does not exist.
Pool memory pool = pools[_lpToken]; in the deposit function where data is cached, and later updated on line 125 where we see _claimCoverRewards(pool, miner);
The contract used the cache data because the data itself stayed in memory; that’s why later the contract calculated the function using that data. Cache was not updated which resulted in this hack:
example.sol
example.sol
example.sol
- A new pool was approved for liquidity mining, merely hours before the hack. This pool is perfectly normal but since it was new, the blacksmith contract didn’t have any LP token of this pool.
- The attacker deposited some tokens of this pool into the Blacksmith contract.
- The Blacksmith contract keeps track of rewards on a per-token basis. If a lot of tokens are locked, the per-token reward will be small. If very few tokens are locked, the per-token reward will be large. The relevant variable is called
accRewardsPerTokenand is calculated astotalPoolRewards / totalTokenBalance. - The attacker then withdrew almost all of the LP tokens from the Blacksmith contract, reducing the
totalTokenBalanceamount to almost zero. - The attacker then deposited some tokens of this pool again into the Blacksmith contract. This is where the bug showed its true colors. Since the
totalTokenBalancewas reduced a lot in the previous transaction, the newly calculatedaccRewardsPerTokenshot up. The contract usesrewardWriteoffto keep the effect ofaccRewardsPerTokenin check. However, due to the bug, the old (small) value ofaccRewardsPerTokenwas used when calculating therewardWriteoffvalue. Due to this, the large value ofaccRewardsPerTokenremained unchecked. - The attacker then withdrew their rewards. Since there was a large, unchecked value in
accRewardsPerToken, the total reward paid out of the system got inflated and the contract ended up minting 40,796,131,214,802,500,000 COVER tokens.
Thanks to Mudit Gupta for the last part of this hack breakdown - read more about it on his
blog :)