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

batchTransferOutV5 could emit multiple TransferOut events, but Bifrost Observation can handle only one per transaction. #7

Open
c4-bot-4 opened this issue Jun 6, 2024 · 0 comments
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working 🤖_19_group AI based duplicate group recommendation sufficient quality report This report is of sufficient quality

Comments

@c4-bot-4
Copy link
Contributor

c4-bot-4 commented Jun 6, 2024

Lines of code

https://github.com/code-423n4/2024-06-thorchain/blob/e5ae503d0dc2394a82242be6860eb538345152a1/ethereum/contracts/THORChain_Router.sol#L247-L253
https://github.com/code-423n4/2024-06-thorchain/blob/e5ae503d0dc2394a82242be6860eb538345152a1/ethereum/contracts/THORChain_Router.sol#L209-L238
https://github.com/code-423n4/2024-06-thorchain/blob/e5ae503d0dc2394a82242be6860eb538345152a1/bifrost/pkg/chainclients/shared/evm/smartcontract_log_parser.go#L166-L343

Vulnerability details

Impact

The batchTransferOutV5 function is the batch version of the transferOutV5 function. When provided with an array of TransferOutData, the batchTransferOutV5 function can emit multiple TransferOut events in one transaction.

However, in the GetTxInItem function in smartcontract_log_parser.go, if there are multiple transferOutEvents in the logs array, the information in txInItem is overwritten during the iteration of the last transferOutEvent. Consequently, only the last transferOutEvent is logged by Bifrost (its txInItem populated by GetTxInItem), and all previous ones are ignored.

As a result, when a THORChain vault uses batchTransferOutV5, their allowance could be spent without the THORChain network acknowledging the outbound from the vault, leading to a loss of funds for the THORChain vault.

Tools Used

Manual Review

Recommended Mitigation Steps

Modify the event logging logic in smartcontract_log_parser.go to accommodate the use of batchTransferOutV5.

Assessed type

Error

@c4-bot-4 c4-bot-4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Jun 6, 2024
c4-bot-4 added a commit that referenced this issue Jun 6, 2024
@c4-bot-12 c4-bot-12 added the 🤖_19_group AI based duplicate group recommendation label Jun 12, 2024
howlbot-integration bot added a commit that referenced this issue Jun 14, 2024
@howlbot-integration howlbot-integration bot added the sufficient quality report This report is of sufficient quality label Jun 14, 2024
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 🤖_19_group AI based duplicate group recommendation sufficient quality report This report is of sufficient quality
Projects
None yet
Development

No branches or pull requests

2 participants