substrate-erc20-multi icon indicating copy to clipboard operation
substrate-erc20-multi copied to clipboard

`transfer_from` decreases allowance too soon

Open drozdziak1 opened this issue 6 years ago • 0 comments
trafficstars

In transfer_from the allowance subtraction happens before _transfer gets the chance to check that from has sufficient token funds. As a result the following erroneous scenario is possible:

  • Alice allows Bob to spend more tokens than she has
  • Bob attempts to transfer_from more tokens than Alice can afford
  • The execution does fail, but the error is returned only after the allowance is already decreased

At this point the transfer is prevented, but global state is modified in an unintended way.

Solution

A. Move the _transfer call before the subtraction B. Add a redundant from token balance check before the subtraction

drozdziak1 avatar Apr 30 '19 10:04 drozdziak1