Closed c4-bot-1 closed 9 months ago
raymondfam marked the issue as insufficient quality report
raymondfam marked the issue as primary issue
Informational code refactoring involving out-of-scope contract.
As the fee is supplied by the user, using the on-chain mechanism to measure it would be a nice-to-have feature rather than a security vulnerability. The submission would be graded QA (NC) which would not warrant a reward (i.e. C
grade) and thus I am setting it as invalid.
alex-ppg marked the issue as unsatisfactory: Invalid
Hi @alex-ppg,
This issue is a problem because the user will not know how much gas to set to pay for the stargate transfer, which will result in failed transactions.
Stargate Docs:
The fee ensures the cross chain message is paid for.
Reference: https://stargateprotocol.gitbook.io/stargate/developers/cross-chain-swap-fee
This is a similar finding, which marks the problem as M:
Giving another example, this protocol tries to calculate its own quoteLayerZeroFee()
, but underestimates the fee because one component is not factored in:
This shows that calculating the wrong amount of fees is an issue as well. The easiest way to get the fee is to use the given stargate method.
Thanks!
Hey @cryptostaker2, I cannot access the referenced links as they request a login.
The second example as described is invalid as it states a fee was not accounted for; given that the user supplies it we can assume they have accounted for all relevant fees.
The first example title says "instead of sending all native asset balance" which is not what occurs in this instance. In this instance, the user supplies it, and per the relevant SC verdict this issue cannot be more than a QA flaw if at all valid.
Lines of code
https://github.com/code-423n4/2024-01-decent/blob/07ef78215e3d246d47a410651906287c6acec3ef/src/bridge_adapters/StargateBridgeAdapter.sol#L170
Vulnerability details
Impact
Fees paid to Stargate may not be accurate, may result in failing function.
Proof of Concept
In StargateBridgeAdapter, when calling
router.swap
, it carries an arbitrarymsg.value
.This msg.value is calculated in
UTB.callBridge()
.which is set by the user in
UTB.bridgeAndExecute()
.In LayerZero Docs, it is adviced to use
quoteLayerZeroFee()
to get the fee required to callswap()
. It is unsure how the fees are currently calculated now, but if the fees paid is inaccurate then the function will fail.Reference: https://stargateprotocol.gitbook.io/stargate/developers/cross-chain-swap-fee
Tools Used
Recommended Mitigation Steps
Call
router.quoteLayerZeroFee()
to get the estimate of fees to pay.Assessed type
Context