fix: prevent escrow reinitialization attack#28
Open
z0neSec wants to merge 1 commit intoironaddicteddog:masterfrom
Open
fix: prevent escrow reinitialization attack#28z0neSec wants to merge 1 commit intoironaddicteddog:masterfrom
z0neSec wants to merge 1 commit intoironaddicteddog:masterfrom
Conversation
…dation SECURITY FIX: Critical vulnerabilities patched 1. CRITICAL - Escrow Reinitialization Attack: - Changed init_if_needed to init for escrow account - Prevents attackers from overwriting existing escrows - Impact: Complete fund theft was possible 2. HIGH - Missing mint_a validation in Exchange: - Added has_one = mint_a constraint - Ensures mint consistency throughout escrow lifecycle - Impact: Potential accounting errors prevented Signed-off-by: zone <zone@security-agent.dev>
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.
Pull Request: Security Fix - Prevent Escrow Reinitialization Attack
Summary
This PR fixes critical security vulnerabilities that allow complete fund theft in the anchor-escrow program.
Vulnerabilities Fixed
🔴 CRITICAL: Escrow Reinitialization Attack
Location:
programs/anchor-escrow/src/contexts/initialize.rs:24-29Problem: The use of
init_if_neededon the escrow account allows attackers to callinitialize()on an already-created escrow, overwriting the state and becoming the newinitializer.Attack Scenario:
initialize(seed=X)- escrow state is overwritteninitializercancel()to drain the vaultImpact: 100% fund theft of any tokens deposited into escrows.
Fix: Changed
init_if_neededtoinitfor both escrow and vault accounts.🟡 HIGH: Missing
has_one = mint_ain ExchangeLocation:
programs/anchor-escrow/src/contexts/exchange.rs:41Problem: The escrow constraints in Exchange validate
mint_bbut notmint_a, creating potential for mint mismatches.Fix: Added
has_one = mint_aconstraint.Changes Made
Testing
A proof-of-concept exploit test is included in
tests/exploit-reinit.tsthat demonstrates:After applying the fix, the exploit test should fail with "account already initialized" error.
Reproduction
Severity Assessment
Checklist
References
Submitted by: zone (AI Security Agent)
Bounty Program: Superteam Earn - Solana Security Audit
Date: February 9, 2026