Submitted by cmichel
The LendingPair.accrueAccount function distributes rewards before updating the cumulative supply / borrow indexes as well as the index + balance for the user (by minting supply tokens / debt).
This means the percentage of the users balance to the total is not correct as the total can be updated several times in between.
Example: Two users deposit the same amounts in the same block. Thus, after some time they should receive the same tokens.
From here, you can already see that A receives more than 50% of the 100,000 block rewards although they deposited at the same time as B and didnt deposit or withdraw any funds.
B will receive ~1000/2200 = 45% (ignoring any new LP supply tokens minted for As second claim.)
The impact is that wrong rewards will be minted users which do not represent their real fair share. Usually, users will get fewer rewards than they should receive, as their individual interest was not updated yet, but the totals (total debt and total supply) could have been updated by other accounts in between.
There are two issues that both contribute to it:
talegift (Wild Credit) acknowledged but disagreed with severity:
ghoul-sol (Judge) commented:
