Users can bypass fees by calling receiveFromBridge
to swap & execute
#639
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-590
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-01-decent/blob/main/src/UTB.sol#L311-L319
https://github.com/code-423n4/2024-01-decent/blob/main/src/UTB.sol#L108-L125
Vulnerability details
Impact:
Any user can call the
receiveFromBridge
function to perform a swap & execute without paying the protocol fees, thereceiveFromBridge
function allows the users to invoke_swapAndExecute
without the processing of fees through theretrieveAndCollectFees
modifier that it's present in theswapAndExecute
function. Basically the fees can be bypassed by callingreceiveFromBridge
instead ofswapAndExecute
resulting in a financial loss for the protocol.Proof of Concept:
The
swapAndExecute
function allows a user to swap currency from the incoming to the outgoing token and executes a transaction with that payment, in the process the user must also pay a protocol fee which is handled by theretrieveAndCollectFees
modifier :As it can be seen the function internally invokes
_swapAndExecute
for handling the swap & execution logic.The issue now is that there is another function that also internally invokes
_swapAndExecute
which is thereceiveFromBridge
function:The function is public so it's callable by anyone to perform a swap and execute a tx but this function doesn't include the
retrieveAndCollectFees
modifier as inswapAndExecute
and so it doesn't charge fees when it's called.In normal situations the
receiveFromBridge
function should only be called by the approved bridge adapters (registered by the owner) but because there is no check for that the caller is really a bridge adapter, any user can use the function instead ofswapAndExecute
to bypass the fees while running his swap transaction.Tools Used:
Manual review
Recommended Mitigation Steps:
Update the
receiveFromBridge
function to incorporate proper access control allowing only approved bridge adapters as caller, the following check could be added:Assessed type
Access Control
The text was updated successfully, but these errors were encountered: