Submitted by cccz, also found by cmichel, Fitraldys, kenzo, onewayfunction, and tqts
There is a reentrancy vulnerability in the _safeMint function
The lock function changes the totalDepositedXDEFI variable after calling the _safeMint function
Since the updateDistribution function does not use the noReenter modifier, the attacker can re-enter the updateDistribution function in the _safeMint function. Since the value of totalDepositedXDEFI is not updated at this time, the _pointsPerUnit variable will become abnormally large.
If the attacker calls the lock function to get the NFT before exploiting the reentrance vulnerability, then the unlock function can be called to steal a lot of rewards, and the assets deposited by the user using the reentrance vulnerability can also be redeemed by calling the unlock function. Since the unlock function calls the _updateXDEFIBalance function, the attacker cannot steal the assets deposited by the user
https://github.com/XDeFi-tech/xdefi-distribution/blob/v1.0.0-beta.0/contracts/XDEFIDistribution.sol#L253-L281
deluca-mike (XDEFI) resolved:
deluca-mike (XDEFI) commented:
Ivshti (Judge) commented:
