First Flight #12: Kitty Connect

First Flight #12: Kitty Connect
Beginner FriendlyFoundryNFTGameFi
100 EXP
View results
Submission Details
Severity: high
Valid

Missing tokens approval

Summary

KittyBridge.sol::bridgeNftWithData() will revert since no approval is being granted to the router for the fees transfer.

Vulnerability Details

Bridging NFTs incurs a cost, payable in LINK or alternative assets. Since LINK is an ERC-20 token, it necessitates prior approval for transfer by an external party on behalf of the contract.

Impact

Tokens cannot be bridged since a call to the function will trigger the error: ERC20: transfer amount exceeds allowance. Since the fees token address is hardcoded there is no way to circumvent this issue.

Proof of Code

Add the following to the current test suite:

Code
function test_bridgeNFTReverts() public {
address someUser = makeAddr("someUser");
string
memory catImageIpfsHash = "ipfs://QmbxwGgBGrNdXPm84kqYskmcMT3jrzBN8LzQjixvkz4c62";
vm.prank(partnerA);
kittyConnect.mintCatToNewOwner(
someUser,
catImageIpfsHash,
"Hehe",
"Hehe",
block.timestamp
);
uint64 otherChainSelector = 14767482510784806043;
address destChainBridge = makeAddr("destChainBridge");
vm.expectRevert("ERC20: transfer amount exceeds allowance");
vm.prank(someUser);
kittyConnect.bridgeNftToAnotherChain(
otherChainSelector,
destChainBridge,
0
);
vm.stopPrank();
}

Tools Used

Manual review

Recommendations

Add the following to the function KittyBridge.sol::bridgeNftWithData:

s_linkToken.approve(address(router), fees);
Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Missing fee token approval

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.