question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Securence of ERC20 transferFrom

See original GitHub issue

Please explain, what prevents such kind of attack ?

Imagine Alice calls approve(Contract.address, amount) to invoke Contract’ method() which withdraws from her address. Then imagine Bob has accidentally found it out, and he wants to prevent Alice invokes method(). So he waits until Alice’ approve transaction is mined, then calls transferFrom(Alice.address, Contract.address, amount) and pushes it faster then Alice pushes method(). In the end, Contract receives money, but method cannot be invoked because allowance now is zero. And so money is lost for Alice.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Skygecommented, Aug 12, 2019

@roleengineer I have asked the same question yesterday, I think someone made a mistake in a pr, at least at the original version, it will check

require(_value <= allowed[_from][msg.sender]);

at first.

1reaction
Skygecommented, Aug 12, 2019

By the way, For support questions (rather than Feature Requests or Bug Reports), as @abcoathup 's suggestion that you can ask in the : OpenZeppelin Community Forum that way the entire community can help answer your question.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Security Pitfalls & Best Practices 201 - Secureum | Substack
ERC20 transfer and transferFrom: Should return a boolean. Several tokens do not return a boolean on these functions.
Read more >
ERC-20's approve/transferFrom security concerns for the ...
Hi everyone, Yesterday during the Ledger&Tokenization Working Group we discussed ERC-20 the approve/transferFrom flow and its issues.
Read more >
Navigating the pitfalls of securely interacting with ERC20 tokens
Our solution to fix the code example is obviously to just check the return value. A simple require(token.transferFrom(msg.sender, address(this), sendAmount), " ...
Read more >
What is the use case of transferFrom function in ERC20 token ...
The use-case is that you give permission for someone else to transfer from your account. That someone else can be either an externally-owned ......
Read more >
Transfer, Approve, TransferFrom methods in ERC20 - YouTube
How are ERC20 tokens transferred?1. transfer2. approve and transferFromGiving unlimited approvals is risky.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found