[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/biz/ - Business & Finance

Search:


View post   

>> No.19755024 [View]
File: 227 KB, 1080x1654, hmm.png [View same] [iqdb] [saucenao] [google]
19755024

Serious Question Frens:Just posted in the Tgroup.

Line 135 in the solidity contract can be exploited through a race condition.

Does it apply to us?

Line 135

https://etherscan.io/address/0xa7DE087329BFcda5639247F96140f9DAbe3DeED1#code

https://swcregistry.io/docs/SWC-114

>The race condition that happens the most on the network today is the race condition in the ERC20 token standard. The ERC20 token standard includes a function called 'approve' which allows an address to approve another address to spend tokens on their behalf. Assume that Alice has approved Eve to spend n of her tokens, then Alice decides to change Eve's approval to m tokens. Alice submits a function call to approve with the value n for Eve. Eve runs a Ethereum node so knows that Alice is going to change her approval to m. Eve then submits a tranferFrom request sending n of Alice's tokens to herself, but gives it a much higher gas price than Alice's transaction. The transferFrom executes first so gives Eve n tokens and sets Eve's approval to zero. Then Alice's transaction executes and sets Eve's approval to m. Eve then sends those m tokens to herself as well. Thus Eve gets n + m tokens even thought she should have gotten at most max(n,m).

The Remedy
>The best fix for the ERC20 race condition is to add a field to the inputs of approve which is the expected current value and to have approve revert if Eve's current allowance is not what Alice indicated she was expecting. However this means that your contract no longer conforms to the ERC20 standard. If it important to your project to have the contract conform to ERC20, you can add a safe approve function. From the user perspective it is possible to mediate the ERC20 race condition by setting approvals to zero before changing them.

To remedy the race condition maybe they'll have to add a safe approve function, which is trivial. Thoughts?

Navigation
View posts[+24][+48][+96]