Submitted by cmichel
The CompoundToNotionalV2.notionalCallback is supposed to only be called from the verified contract that calls this callback. But, the access restrictions can be circumvented by simply providing sender = this, as sender is a parameter of the function that can be chosen by the attacker.
An attacker can call the function passing in an arbitrary account whose tokens are then transferred to the contract.
The account first has to approve this contract but this can happen with accounts that legitimately want to call the outer function and have to send a first transaction to approve the contract, but then an attacker front-runs the actual transaction.
Its at least a griefing attack:
I can pass in a malicious cTokenBorrow that returns any token of my choice (through the .underlying() call) but whose repayBorrowBehalf is a no-op.
This will lead to any of the victims approved tokens becoming stuck in the contract, essentially burning them:
Note that the assumption at the end of the function // When this exits a free collateral check will be triggered is not correct anymore but I couldnt find a way to make use of it to lead to an invalid account state.
Recommend fixing the authorization check.
jeffywu (Notional) confirmed
