feat: protect against reentrancy attacks in smart contracts#421
Open
od-hunter wants to merge 1 commit into
Open
feat: protect against reentrancy attacks in smart contracts#421od-hunter wants to merge 1 commit into
od-hunter wants to merge 1 commit into
Conversation
- Add reentrancy latch (_acquire_lock/_release_lock) to all mutative functions in contracts/src/lib.rs: create_project, batch_create_projects, fund_project, submit_work, approve_work, raise_dispute, resolve_dispute, check_deadline, set_metadata, remove_metadata, pause, unpause - Enforce checks-effects-interactions (CEI) pattern across all functions: deposited is zeroed and status committed to storage before any event emission or token transfer interaction in approve_work, resolve_dispute, and check_deadline - Add emergency circuit breaker: pause(admin) / unpause(admin) / is_paused() backed by DataKey::Paused; all mutative functions call _require_not_paused first; upgrade intentionally exempt so security patches can deploy while paused - Add nonReentrant modifier to BatchSplitter.batchTransfer (was the only EVM contract missing a reentrancy guard) - Add cross-contract reentrancy protection via shared latch that blocks all mutative entry points simultaneously - Add fuzz and invariant tests in contracts/test/foundry/ReentrancyFuzz.t.sol covering: direct reentrancy, cross-function reentrancy, read-only reentrancy, constructor reentrancy, BatchSplitter guard, forwarder nonce replay, balance invariant, no-double-payment, over-withdraw prevention - Add formal verification spec contracts/certora/specs/ReentrancySafety.spec with 10 rules: latch zero at entry/exit, latch released on revert, no direct/cross-function reentrancy, balance bounds, only-owner withdraw, platformFeeBps bounded - Expand contracts/src/security_properties.rs with 14 new proptest properties covering latch mutual-exclusion, read-only reentrancy, cross-function reentrancy, constructor reentrancy, CEI invariants, circuit-breaker state machine All 39 Rust tests pass. Solidity files compile clean.
|
@od-hunter is attempting to deploy a commit to the smartdevs17's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@od-hunter Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Closes #397
#397