Assuming standard flow of events
- User, who is owner of address
A
approves to spendX
ERC20 tokens, usingapprove
method to a smart-contractS
from addressA
. - Then, user calls
S
to spend that amountX
and do its work.
What if in-between 1 and 2, someone else, who can call S
will invoke spending from address A
?
Is there any protection from that in ETH itself, e.g. to check if S
is called by the user who gave the approval (and not someone else)?
What if someone watching me, when I use uniswap, e.g. and calls its smart-contract instead of me? After I give approval, but before the swap tx sinks in?
What is the standard way to handle that risk, if it exists?
S
must have a method that calls the "transferFrom" method from the ERC20 Contract. This method in Contract S has a logic and this logic says who can call it and what will happen if it is called. If this method has a bug or is implemented wrong then your money is at risk.