-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Malicios users can grief admin calls to pushProtocolFeeBipsUpdates causing tranasctions to revert #9
Comments
The proposed attack seems pretty outlandish IMO, that someone would pay gas fees to frontrun these update transactions just for the sake of griefing the admins. Definitely a low not a medium but probably worth changing just in case. |
Thanks! |
3docSec changed the severity to QA (Quality Assurance) |
3docSec marked the issue as grade-b |
Hello @3docSec , I believe this issue fits well into the medium severity criteria for the following reasons: 1. The attacker can cause actual loss of fees for either the protocol or users.Consider this example: The protocol fee bips is increased by 1% accross the entire protocol. At $25m in loans(current tvl of wildcat is ~25m), this would make the protocol fee increase by 25000000*1/100/365 ~ 685 USD per day. Thus the attacker will cause a 685 USD loss(on average across loans) to the protocol for each day the fee update is not pushed. On the other hand if the fee is decreased by 1% the loss will be 685 USD of additional fees for the users for each day the fee is not updated. Either way the attacker will cause a loss for one party. A competing protocol would have the incentive to mess with this. 2. Users have an incentive to push the value themselves if the fee is decreased as it makes them pay less fees in total. This makes it more likely for the admin transactions to unexpectedly revert by chance.Consider this example: A user has $2.5m in a loan. If the protocol fee bips is decreased by 1% it would mean the user is losing 2500000*1/100/365= 68.5 USD per day for each day the fee is not updated. As a result they would want to push the update as early as possible. 3. When the protocol fee is increased, users have an incentive to delay the update.Borrowers want to pay as little fees as possible. As a result they would want to delay an update to the protocol fee bips if it is increased. 4. As per the competition page, the protocol will be deployed on Base, Arbitrum and Polygon as well.On ethereum mainnet an attacker would have to bear the gas fees, but on the polygon chain, the attack would be practically free. This issue causes the protocol function to be impacted and the proposed attack vector will cause loss of fees for either the protocol or users, so I think it fits well into the code4rena criteria for a medium severity issue. |
Fixed by wildcat-finance/v2-protocol@4c7fc06 |
Hi @gesha17
|
Lines of code
https://github.com/code-423n4/2024-08-wildcat/blob/main/src/HooksFactory.sol#L553
https://github.com/code-423n4/2024-08-wildcat/blob/main/src/market/WildcatMarketConfig.sol#L171
Vulnerability details
Impact
The pushProtocolFeeBipsUpdates function is callable by anyone, meaning anyone can push a fee update. However, whenever a market has already been updated, the setProtocolFeeBips() function will revert when the update is pushed again. As a result malicios users can frontrun batch calls to pushProtocolFeeBipsUpdates() and push the update to only the last market in a batch. This will result in reverting tranasctions for admins or other honest users and thus loss of gas costs, as well as delayed updates. If there are 1000 deployed markets in a template, the admin will have to do 1000 separate transactions to avoid the issue, which is a big overhead. Note that this can happen by accident as well, if a user happens to push an update to their own fees just ahead of the admin.
Proof of Concept
The
pushProtocolFeeBipsUpdates()
function iterates over markets in the range [marketStartIndex, marketEndIndex] and pushes the fees update via calls tomarket.setProtocolFeeBips(protocolFeeBips)
:https://github.com/code-423n4/2024-08-wildcat/blob/main/src/HooksFactory.sol#L553
However, the setProtocolFeeBips function will revert if the protocol fee bips remains the same, meaning the change was already pushed, so
_protocolFeeBips == state.protocolFeeBips
will be true:https://github.com/code-423n4/2024-08-wildcat/blob/main/src/market/WildcatMarketConfig.sol#L171
Thus, a malicios user can frontrun batch calls and cause them to revert and incur gas losses. The malicios user would specifically push the update to the last market in a batch for maximum gas losses. This can also happen if for example a user pushes a fee update to their market just before the admin batch call.
Recommended Mitigation Steps
Do not revert, but just return if the fee bips is unchanged.
Assessed type
MEV
The text was updated successfully, but these errors were encountered: