chaduke
high
A malicious forwarder might abuse a sender's approval for a specific market A in a differt market B.
A malicious forwarder might abuse a sender's approval for a specific market A in another different market B. The main problem is that _approvedForwarderSenders[_forwarder]
does not keep track of which market the approval is for.
For the same reason, function hasApprovedMarketForwarder()
might return wrong result.
We show how a malicious forwarder F might abuse a sender X's approval for a specific market A in another different market B, which is a serious security problem since X has never approved F for market B.
- Suppose F is a trusted market forwarder for both markets A and B;
- X calls
approveMarketForwarder(A, F)
to authorize F as X's forwarder for market A. Now_approvedForwarderSenders[F]
will contain X; - F can abuse the approval from X and can serve as X's forwarder for market B as well although X has never authorized this. This is possible because
_approvedForwarderSenders[_forwarder]
does not keep track of which market the approval is for. - To see this, consider that F calls _msgSenderForMarket(B) to retrieve the function caller address by checking the appended
sender
address at the end of calldata. All the checks will pass since_approvedForwarderSenders[B, F]
is true and_approvedForwarderSenders[F].contains(X)
is also true. This meansX
will be considered as thesender
for market B ifX
is appended to the calldata! - Such abuse might lead to unauthorized function calls and loss of funds, for example, the forwarder might loan on behalf of X from another market that X has never authorized.
A malicious forwarder might abuse a sender's approval for a specific market A in a different market B. Such abuse might lead to unauthorized function calls and loss of funds.
The function hasApprovedMarketForwarder()
might return wrong result. For example, X approves F on market A, and F is a forwarder for both markets A and B, then this function will wrongly return the result that X also approves F for market B, which is not true.
See above
VSCode
Manual Review
_approvedForwarderSenders[_forwarder]
should be extended to include _marketId
so that the approval for one market cannot be used for another market.