[SECURITY] Fix critical vault drain vulnerability in partial fill logic#1
Open
byte541 wants to merge 1 commit intoVK-RED:masterfrom
Open
[SECURITY] Fix critical vault drain vulnerability in partial fill logic#1byte541 wants to merge 1 commit intoVK-RED:masterfrom
byte541 wants to merge 1 commit intoVK-RED:masterfrom
Conversation
CRITICAL SECURITY FIX When a maker's order is partially filled, the Fill event was incorrectly recording base_amount_to_set (the remaining unfilled amount) instead of the actual amount that was matched. This bug allows attackers to be credited more tokens than they're owed when consume_events is called, enabling vault drain attacks. Changes: - Added base_amount_matched field to EditOrders struct - Store base_amount_eaten when creating EditOrders for partial fills - Use base_amount_matched in Fill event instead of base_amount_to_set Impact: Prevents vault drain via inflated partial fill credits
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.
Summary
This PR fixes a critical security vulnerability that allows attackers to drain the market vault by exploiting incorrect amount recording in partial fill events.
Vulnerability Details
Severity: CRITICAL
Type: Vault Drain / Theft of Funds
When a maker's order is partially filled, the Fill event incorrectly records
base_amount_to_set(the remaining unfilled amount) instead of the actual amount that was matched.Vulnerable Code (before fix)
Impact
consume_eventscredits attacker with 9,999 tokens instead of 1Fix
Added
base_amount_matchedfield to track actual matched amount and use it in Fill events:Testing
I have prepared a proof-of-concept test demonstrating the vulnerability and fix. Happy to share if helpful.
Disclosure
This vulnerability was discovered during security research. I'm submitting this fix as part of responsible disclosure.
Found by byte541