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

Token Loss on Failed Destination Chain Call #394

Closed
c4-submissions opened this issue Sep 7, 2023 · 5 comments
Closed

Token Loss on Failed Destination Chain Call #394

c4-submissions opened this issue Sep 7, 2023 · 5 comments
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-50 sufficient quality report This report is of sufficient quality unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@c4-submissions
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2023-09-ondo/blob/main/contracts/bridge/SourceBridge.sol#L77

Vulnerability details

Impact

The burnAndCallAxelar function allows users to burn tokens from their account with the intention of executing a cross-chain call. However, the tokens are burned before the cross-chain call is attempted. If the cross-chain call fails on the destination chain for any reason, such as a contract error or network issue, the burned tokens may become unrecoverable. This poses a risk of financial loss for users and a potential lack of trust in the contract's cross-chain functionality.

Proof of Concept

function burnAndCallAxelar(
uint256 amount,
string calldata destinationChain
) external payable whenNotPaused {
// check destinationChain is correct
string memory destContract = destChainToContractAddr[destinationChain];

if (bytes(destContract).length == 0) {
  revert DestinationNotSupported();
}

if (msg.value == 0) {
  revert GasFeeTooLow();
}

// burn amount
TOKEN.burnFrom(msg.sender, amount);

bytes memory payload = abi.encode(VERSION, msg.sender, amount, nonce++);

_payGasAndCallContract(destinationChain, destContract, payload);
}

Exploitation Scenario:

User Initiation: A user initiates a cross-chain transaction using the burnAndCallAxelar function. They specify an amount of tokens to burn, along with the destination chain and contract.

Token Burning: The function first burns the specified amount of tokens from the user's account. This is a crucial step, and the tokens are now removed from the user's balance.

Cross-Chain Call Attempt: After burning the tokens, the function attempts to execute a cross-chain call to the specified destination chain and contract with a payload.

Cross-Chain Call Failure: If, for any reason, the cross-chain call fails on the destination chain (e.g., due to contract errors, network issues, or other unforeseen circumstances), the transaction fails on the destination chain.

Unrecoverable Token Loss: Since the tokens were already burned in the user's account, and the cross-chain call failed, there is no mechanism in place to refund or return the tokens to the user. As a result, the user experiences an unrecoverable token loss.

Tools Used

Manual review

Recommended Mitigation Steps

Implement error handling mechanisms that allow for token redemption in case of a cross-chain call failure. This may involve creating a mechanism to refund or return tokens to the user if the destination chain transaction fails.

Assessed type

Invalid Validation

@c4-submissions c4-submissions added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Sep 7, 2023
c4-submissions added a commit that referenced this issue Sep 7, 2023
@c4-pre-sort
Copy link

raymondfam marked the issue as duplicate of #162

@c4-pre-sort
Copy link

raymondfam marked the issue as sufficient quality report

@c4-pre-sort c4-pre-sort added the sufficient quality report This report is of sufficient quality label Sep 8, 2023
@c4-pre-sort c4-pre-sort reopened this Sep 8, 2023
@c4-pre-sort
Copy link

raymondfam marked the issue as not a duplicate

@c4-pre-sort
Copy link

raymondfam marked the issue as duplicate of #50

@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Sep 19, 2023
@c4-judge
Copy link
Contributor

kirk-baird marked the issue as unsatisfactory:
Invalid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-50 sufficient quality report This report is of sufficient quality unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

3 participants