stake.link

stake.link
DeFiHardhatBridge
27,500 USDC
View results
Submission Details
Severity: low
Invalid

Function `getFee()` in `RESDLTokenBridge` can return wrong fee values to users

Summary

When a user tries to know how much tokens he should approve/transfer to the RESDLTokenBridge to bridge a lock, he can get a wrong amount

Vulnerability Details

In the current implementation, the fee calculation within the getFee function utilizes a hardcoded empty lock when determining the required fee for executing a CCIP message. This can lead to inaccurate quotes for users attempting to bridge their locks, potentially causing discrepancies in the amount needed for approval or transfer.

function getFee(uint64 _destinationChainSelector, bool _payNative) external view returns (uint256) {
Client.EVM2AnyMessage memory evm2AnyMessage = _buildCCIPMessage(
address(this),
0,
ISDLPool.RESDLToken(0, 0, 0, 0, 0), <-
address(this),
_payNative ? address(0) : address(linkToken),
extraArgsByChain[_destinationChainSelector]
);
return IRouterClient(sdlPoolCCIPController.getRouter()).getFee(_destinationChainSelector, evm2AnyMessage);
}

Impact

Low

Tools Used

Manual review

Recommendations

Compute the fee with the real values of the user's lock

- function getFee(uint64 _destinationChainSelector, bool _payNative) external view returns (uint256) {
+ function getFee(uint64 _destinationChainSelector, bool _payNative, uint256 _lockId) external view returns (uint256) {
+ uint256[] memory lockId = new uint256[](1);
+ lockId[0] = _lockId;
+ Lock[] memory locks = sdlPool.getLocks(lockId);
Client.EVM2AnyMessage memory evm2AnyMessage = _buildCCIPMessage(
address(this),
- 0,
+ _lockId,
- ISDLPool.RESDLToken(0, 0, 0, 0, 0),
+ locks[0]
address(this),
_payNative ? address(0) : address(linkToken),
extraArgsByChain[_destinationChainSelector]
);
return IRouterClient(sdlPoolCCIPController.getRouter()).getFee(_destinationChainSelector, evm2AnyMessage);
}
Updates

Lead Judging Commences

0kage Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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