Return to site
Return to site

Bug Deep Dive #23

View::queryAssetBalances does not account for JIT penalties - $886

· Bug Deep Dive
Section image

View::queryAssetBalances is used to query how much assets an user would receive if they were to withdraw their funds at the moment. However, the value returned will be wrong as it does not account for potential JIT penalties that the position might incur.
When a user removes their maker position it calculates the amount of assets to return and then applies a JIT penalty if needed afterwards.

Section image

However, when the view function is used it does not properly account for the JIT penalty.

Section image

This would cause a mismatch between the 2 values of more than 0.01% as long as the JIT penalty is more than 0.01% (which is likely the case).

From the readme: Issues that lead to getting incorrect return values (i.e. deviates from the withdrawal value of the asset by more than 0.01%) from the queryAssetBalance function (even if the appropriate input is used), which will lead to issues when executing other functions, may be considered valid with Medium severity at max.

Alpha: view functions are not usually med, but the protocol specifically indicated they want to take this into account.

Conclusion

This finding would earn you $886, the easiest way to find such issues is just compare the state changing function with the view function to check if they return the same values, and read the readme.

Full Report
Codebase

Subscribe
Previous
Bug Deep Dive #22
Next
 Return to site
Cookie Use
We use cookies to improve browsing experience, security, and data collection. By accepting, you agree to the use of cookies for advertising and analytics. You can change your cookie settings at any time. Learn More
Accept all
Settings
Decline All
Cookie Settings
Necessary Cookies
These cookies enable core functionality such as security, network management, and accessibility. These cookies can’t be switched off.
Analytics Cookies
These cookies help us better understand how visitors interact with our website and help us discover errors.
Preferences Cookies
These cookies allow the website to remember choices you've made to provide enhanced functionality and personalization.
Save