Submitted by 3docSec, also found by ether_sky
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/tokens/ERC20RebaseDistributor.sol#L618
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/tokens/ERC20RebaseDistributor.sol#L531
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/tokens/ERC20RebaseDistributor.sol#L594
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/tokens/ERC20RebaseDistributor.sol#L688
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/tokens/ERC20RebaseDistributor.sol#L712
When calculating share changes during ERC20RebaseDistributor token transfers, the logic computes the share delta as follows:
It is possible that due to rounding, rebasingStateTo.nShares is higher than toSharesAfter by 1 wei, causing the transfer to fail.
A similar issue can happen when unminted rewards are taken off the rebase pool:
Here it is possible that the amount is higher than _unmintedRebaseRewards, introducing also in this place a revert condition.
Transfers and mints from or towards addresses that are rebasing may fail in real-world scenarios. This failure can be used as a means to DoS sensitive operations like liquidations. Addresses who enter this scenario arent also able to exit rebase to fix their transfers.
Below a foundry PoC (full setup here) which shows a scenario where a transfer (or mint) to a rebasing user can fail by underflow on the _unmintedRebaseRewards - amount operation:
This is with a lower impact because involving a zero-value transfer, the following PoC in Foundry (the full runnable test can be found here) shows a transfer failing on the toSharesAfter - rebasingStateTo.nShares operation:
Foundry
Consider adapting shares calculations to tolerate rounding fluctuations, i.e. by flooring to 0 the mentioned subtractions.
Token-Transfer
eswak (Ethereum Credit Guild) confirmed
Soul22 (warden) commented:
3docSec (warden) commented:
Soul22 (warden) commented:
TrungOre (judge) commented:
