Closed c4-bot-10 closed 4 months ago
The Warden describes a potential feature that the Sponsor should integrate into their protocol, however, they fail to pinpoint any security risk that arises from its absence rendering it a nice-to-have recommendation and thus of QA severity.
alex-ppg changed the severity to QA (Quality Assurance)
alex-ppg marked the issue as grade-c
Lines of code
https://github.com/code-423n4/2024-06-badger/blob/9173558ee1ac8a78a7ae0a39b97b50ff0dd9e0f8/ebtc-zap-router/src/ZapRouterBase.sol#L115
Vulnerability details
Impact
A third party can't do a CDP operation on original borrower's behave.
Proof of Concept
The protocol provides a way for permit handling CDP like ERC20Permit, which requires original borrower's signature to open, adjust or close a CDP. Such feature also presents in zap routers. However, the value passed into permitting function is incorrect, and causing third party address can't operate on CDP on behave of borrowers.
As we can see, both routers implement
ZapRouterBase
contract, and whenever permitting is required,_permitPositionManagerApproval
function will be called:Where we notice that the first parameter is set to
msg.sender
, and inborrowerOperations.permitPositionManagerApproval
, the first parameter is borrower, and meaning where the debt will go to:In the above function, we can see that once signature is recovered, it's checked if it's from the original borrower, and in the router's case, it's essentially:
And after the successful execution, the function continues, for example, in
EbtcZapRouter._openCdpWithPermit
, which is internally called by opening CDP, CDP will be opened for whoever calls the function. This brings an issue for people who want their assets being managed by third party sources, also as mentioned in the leverage router, the permit feature is meant to support apps like instadapp, defi saver and such.In the scenario where CDP is created, through a delegator, the CDP will be opened for delegator, and collaterals will also be taken from delegator, which is incorrect, as the delegator should operate the CDP with borrower's signature and collaterals should be taken from the borrower but not delegator. The result is, third party delegation will not work.
Example:
One may argue that Alice can transfer required amount of tokens to Bob, and let Bob do the rest, but Bob can also take all assets from Alice and keep as his own. The design here is meant to have a third party handle the CDP operations on behaves of borrowers, but this obviously defeats the purpose, and third parties cannot do anything even if they have proper signatures.
Tools Used
Manual review
Recommended Mitigation Steps
Allow callers to specify the address of borrower instead of using
msg.sender
. And if users have provide a valid signature, check if the borrower is signature signer instead ofmsg.sender
.Assessed type
Context