Missing balancedBooks modifier could result in failed system insolvency detection
The balancedBooks modifier, which checks that funds have not gone missing during a function call, was missing from the refundUser() and topupMarketBalance() functions. Any miscalculations in these functions could lead to the system becoming insolvent.
0xRajeev Follow with gpersoon and paulius.eth
Originally disclosed on Code4rena
Submitted by 0xRajeev, also found by gpersoon and paulius.eth
The balancedBooks modifier is used to “check that funds haven’t gone missing during this function call” and is applied to deposit, withdrawDeposit, payRent, payout and sponsor Treasury functions which move funds in and out of the Treasury or adjust its market/user balances.
However, this modifier is missing in the refundUser() and topupMarketBalance() functions which also perform similar actions. The impact is that any miscalculations in these functions will lead to the system becoming insolvent.
Recommend adding modifier to the two functions above where it is missing.
Splidge (Reality Cards) confirmed and resolved in a duplicate issue:
implemented here
Note: Additional conversation regarding this vulnerability can be found here
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely, the balancedBooks modifier was not applied to all functions that move funds or adjust balances, leaving refundUser() and topupMarketBalance() without the solvency check.
Impact
Any miscalculations in these functions could lead to the system becoming insolvent.
What the attacker needed
None
The fix
The modifier should be added to the two functions where it is missing; the text says the issue was confirmed and resolved in a duplicate issue.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A modifier is a piece of code that runs before and after a function to enforce a rule. Here, a rule called balancedBooks checks that the total funds in the system still add up after money moves. Two functions that move money did not have this check, so if they had a bug, the system might not notice that funds were missing.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.