Submitted by bin2chen, also found by Koolex and Udsen
CoreBranchRouter.addGlobalToken() is used to set the local token of chains.
When CoreBranchRouter.addGlobalToken(_dstChainId = ftm), it will execute follow step:
Call sequence [root]->[branch]->[root], with asynchronous calls via layerzero.
Since it is asynchronous, in the case of concurrency, the check in step 1.2 is invalid because step 3.2 is executed after a certain amount of time.
Consider the following scenarios:
So bob_LocalTokenAddress will override alice_LocalTokenAddress.
The main problem here, is that the check in step 3.1 is wrong because the local token is a regenerated address, so isLocalToken() is always false. It should be checking isGlobalToken(_globalAddress, _dstChainId)).
In the case of concurrency, the second local token will overwrite the first local token. Before overwriting, the first local token is still valid. If someone exchanges the first local token and waits until after overwriting, then the first local token will be invalidated and the user will lose the corresponding token.
The following code demonstrates that with layerzero asynchronous and due to _setLocalToken() error checking, it may cause the second localToken to overwrite the first localToken; the layerzero call is simplified.
Add to CoreRootBridgeAgentTest.t.sol
Check isGlobalToken() should replace check isLocalToken().
Context
0xBugsy (Maia) disputed and commented via duplicate issue #822:
alcueca (judge) commented via duplicate issue #822:
0xBugsy (Maia) commented via duplicate issue #822:
alcueca (judge) commented via duplicate issue #822:
alcueca (judge) decreased severity to Medium and commented:
bin2chen (warden) commented:
alcueca (judge) commented:
0xBugsy (Maia) commented:
Note: For full discussion, see here.
