Users can use credit positions to take out loans. If they take an amount that splits their credit position, then they owe a fragmentation fee. The issue is that this can be avoided as users can use compensate() to split credit positions without a fee. They can split the position in such a way that whenever they input the amount they want to lend/borrow, that amount would be equal to the credit of the position and thus, they would avoid paying fragmentation fees.
For the POC, create an Event log in BuyCreditMarket.sol and add 2 events like shown below (on the 2 last lines):
If these values are equal, then that means the position did not get fragmented and the user doesn't have to pay fragmentation fees. If they are not, the user has to pay fragmentation fees.
Paste the following POC into Compensate.t.sol (use -vvvv to see the events and you can also comment out the lines where Alice is compensating to see the difference in events):
Lines of code
https://github.com/code-423n4/2024-06-size/blob/8850e25fb088898e9cf86f9be1c401ad155bea86/src/libraries/actions/Compensate.sol#L31
Vulnerability details
Impact
Users can avoid paying fragmentation fees
Proof of Concept
Users can use credit positions to take out loans. If they take an amount that splits their credit position, then they owe a fragmentation fee. The issue is that this can be avoided as users can use
compensate()
to split credit positions without a fee. They can split the position in such a way that whenever they input the amount they want to lend/borrow, that amount would be equal to the credit of the position and thus, they would avoid paying fragmentation fees.For the POC, create an Event log in
BuyCreditMarket.sol
and add 2 events like shown below (on the 2 last lines):If these values are equal, then that means the position did not get fragmented and the user doesn't have to pay fragmentation fees. If they are not, the user has to pay fragmentation fees. Paste the following POC into
Compensate.t.sol
(use-vvvv
to see the events and you can also comment out the lines where Alice is compensating to see the difference in events):Tools Used
Manual Review
Recommended Mitigation Steps
It is not trivial to fix this if you want to keep the code the same. Implementing a fee upon compensating is a possible fix.
Assessed type
Other