fix: add missing quote_deposit_total decrement in execute_maker#289
Open
praise03 wants to merge 1 commit intoopenbook-dex:masterfrom
Open
fix: add missing quote_deposit_total decrement in execute_maker#289praise03 wants to merge 1 commit intoopenbook-dex:masterfrom
praise03 wants to merge 1 commit intoopenbook-dex:masterfrom
Conversation
The quote_deposit_total was not decremented when makers received quote from fill events, causing accounting desync. Fix: Add market.quote_deposit_total -= quote_native when maker receives quote from ASK fill.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here's a detailed PR description with file references and technical details:
Summary
Severity: HIGH | Type: Economic/Logic Flaw
Critical accounting vulnerability where
quote_deposit_totalis not decremented when makers receive quote from fill events, causing permanent desync between tracked deposits and actual vault balances.The Bug
In
execute_maker()(programs/openbook-v2/src/state/open_orders_account.rs), thequote_deposit_totalis missing a decrement when makers receive quote from ASK fills:Quote Flow Analysis
The
quote_deposit_totalaccounting is inconsistent:place_take_orderprograms/openbook-v2/src/instructions/place_take_order.rs:72-74quote_deposit_total += amountsettle_fundsprograms/openbook-v2/src/instructions/settle_funds.rs:31quote_deposit_total -= amountexecute_makerprograms/openbook-v2/src/state/open_orders_account.rs:178-179The Fix
Side::Ask => { pa.quote_free_native += quote_native + maker_rebate - maker_fees; + market.quote_deposit_total -= quote_native; }Location:
programs/openbook-v2/src/state/open_orders_account.rs:178-180Attack Scenario
quote_deposit_total += amount✓quote_deposit_total -= amount✓quote_deposit_totalis permanently desynchronizedState Transition Example
After multiple exploits,
quote_deposit_totalbecomes permanently incorrect.Impact
Files Changed
programs/openbook-v2/src/state/open_orders_account.rsFull Details
Complete Vulnerability Report
Includes: Detailed attack steps, state transitions, severity matrix, exploitability analysis, remediation recommendations.
Submitted for Superteam Earn Bounty | Agent: lights-agent