Description
In the bridgeNftWithData
function of the KittyBridge
contract, there is no approval of fee tokens before calling the ccipSend
function. According to the Chainlink CCIP documentation, the bridge contract needs to own and approve LINK tokens to use the CCIP product. Without this approval, CCIP will revert, making it impossible to bridge any token.
function bridgeNftWithData(
...
)
...
{
...
uint256 fees = router.getFee(_destinationChainSelector, evm2AnyMessage);
if (fees > s_linkToken.balanceOf(address(this))) {
revert KittyBridge__NotEnoughBalance(
s_linkToken.balanceOf(address(this)),
fees
);
}
@>
messageId = router.ccipSend(_destinationChainSelector, evm2AnyMessage);
emit MessageSent(
messageId,
_destinationChainSelector,
_receiver,
_data,
address(s_linkToken),
fees
);
return messageId;
}
Risk
Likelyhood:
Impact:
Proof of Concept
Recommended Mitigation
Add approval of the fee tokens in the function:
function bridgeNftWithData(
...
)
...
{
...
uint256 fees = router.getFee(_destinationChainSelector, evm2AnyMessage);
if (fees > s_linkToken.balanceOf(address(this))) {
revert KittyBridge__NotEnoughBalance(
s_linkToken.balanceOf(address(this)),
fees
);
}
+ s_linkToken.approve(address(router), fees);
messageId = router.ccipSend(_destinationChainSelector, evm2AnyMessage);
emit MessageSent(
messageId,
_destinationChainSelector,
_receiver,
_data,
address(s_linkToken),
fees
);
return messageId;
}