Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Funds can be stolen because of approval + send #10

Closed
code423n4 opened this issue Jul 10, 2021 · 1 comment
Closed

Funds can be stolen because of approval + send #10

code423n4 opened this issue Jul 10, 2021 · 1 comment
Labels
3 (High Risk) bug Something isn't working duplicate This issue or pull request already exists sponsor confirmed Yes, this is a problem and we intend to fix it.

Comments

@code423n4
Copy link
Contributor

Handle

cmichel

Vulnerability details

Vulnerability Details

The fulfill transaction on the receiving chain first approves the txData.callTo contract with the toSend amount.

It then tries to call the addFunds and execute actions on txData.callTo.
When any of the calls reverts, the funds are sent to the txData.receivingAddress.

Note this is a different attack from "Funds are sent twice on callTo errors". Assume that issue was already fixed and it would only send out the transfer once.

The txData.callTo is user-controlled and an attacker can deploy a contract to this address and revert on all calls.
They then receive the funds once (or twice if other issue was not fixed) through the direct LibAsset.transferAsset(txData.receivingAssetId, payable(txData.receivingAddress), toSend) call.
Afterwards, as the approval was given to callTo, the attacker can send a transaction to their callTo contract to transferFrom(TransactionManager, toSend) again.

Impact

The receiver can get twice the amounts of funds that the router agreed to (and locked up).
This allows stealing all added liquidity in the contract by an attacker engaging in cross-chain transfers with themselves.

Recommended Mitigation Steps

Giving approvals to arbitrary contracts is very dangerous. It should probably be removed completely.
If it's really desired, at least reset the approval to 0 again at the end of the fulfill function such that callTo must have used transferFrom within the same transaction in the execute call.

@code423n4 code423n4 added 3 (High Risk) bug Something isn't working labels Jul 10, 2021
code423n4 added a commit that referenced this issue Jul 10, 2021
@LayneHaber LayneHaber added the sponsor confirmed Yes, this is a problem and we intend to fix it. label Jul 12, 2021
@LayneHaber
Copy link
Collaborator

#31

@LayneHaber LayneHaber added the duplicate This issue or pull request already exists label Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) bug Something isn't working duplicate This issue or pull request already exists sponsor confirmed Yes, this is a problem and we intend to fix it.
Projects
None yet
Development

No branches or pull requests

2 participants