Closed sherlock-admin4 closed 8 months ago
1 comment(s) were left on this issue during the judging contest.
WangAudit commented:
the only public function (bridgeTransfer) doesn't allow matic and reverts; if matic is sent via transfer; then it's user mistake -> invalid under Sherlock's rules
Even though, it's a valid issue.
1 comment(s) were left on this issue during the judging contest.
WangAudit commented:
the only public function (bridgeTransfer) doesn't allow matic and reverts; if matic is sent via transfer; then it's user mistake -> invalid under Sherlock's rules
Than it is ok if user lost funds?
0xKartikgiri00
high
In
BridgeRelay
contract the user MATIC balance can lost permanently.Summary
The contract
BridgeRelay
allows for the transfer of MATIC tokens to a destination account. However, if multiple accounts transfer MATIC tokens to this contract, all the MATIC balance will be sent to a single user address.Vulnerability Detail
In the
BridgeRelay::erc20Rescue
function, which allows the contract owner to return MATIC tokens from the contract to a specified destination. Since there is no logic implemented to differentiate between different users who might have deposited MATIC tokens directly toBridgeRelay
contract, all the MATIC tokens held by the contract will be sent to the single user address specified by the owner, regardless to the original depositors.Impact
The impact is that if multiple users deposit MATIC tokens to the contract, intending to bridge them to another network or perform some other operation, the entire MATIC balance will be redirected to a single address determined by the owner. This could result in loss of funds for the depositors and disrupt the intended functionality of the contract.
Proof Of Concept
The below test case shows how an attacker can transfer matic token to
BridgeRelay
just right after the genuine user transaction and can get the whole amount of matic token available in the contract.FOUNDRY TEST CASE:-
FOUNDRY DEPLOYEMENT SCRIPT:-
Output:-
Code Snippet
https://github.com/sherlock-audit/2024-02-telcoin-platform-audit-update/blob/main/telcoin-contracts/contracts/bridge/BridgeRelay.sol#L88 https://github.com/sherlock-audit/2024-02-telcoin-platform-audit-update/blob/main/telcoin-contracts/contracts/bridge/BridgeRelay.sol#L95
Tool used
Manual Review, Foundry
Recommendation
The recommended mitigation can be is to add new param amount in the
erc20Rescue
function so that only specified amount of the matic token which transfer by user inBridgeRelay
contract is return to the user not the whole matic amount of contract.