Skip to content

fix(security): mitigate reentrancy in transfer operations#394

Merged
ISTIFANUS-N merged 2 commits intorinafcode:mainfrom
mofejo1:fix/reentrancy-transfer-ops
Apr 23, 2026
Merged

fix(security): mitigate reentrancy in transfer operations#394
ISTIFANUS-N merged 2 commits intorinafcode:mainfrom
mofejo1:fix/reentrancy-transfer-ops

Conversation

@mofejo1
Copy link
Copy Markdown
Contributor

@mofejo1 mofejo1 commented Apr 22, 2026

Summary

  • add a shared reentrancy guard utility and module-level lock keys
  • enforce checks-effects-interactions in transfer-heavy paths across modules
  • protect transfer flows in:
    • contracts/teachlink/src/rewards.rs
    • contracts/teachlink/src/bridge.rs
    • contracts/teachlink/src/atomic_swap.rs
    • contracts/teachlink/src/insurance.rs
  • add focused unit tests that assert guard-trigger behavior for critical transfer entry points

Security changes

  • introduced reentrancy::with_guard(...) wrapper to prevent nested execution on protected code paths
  • moved state mutation ahead of external token calls in vulnerable flows (CEI)
  • added explicit reentrancy error variants:
    • BridgeError::ReentrancyDetected
    • EscrowError::ReentrancyDetected
    • RewardsError::ReentrancyDetected

Validation

  • cargo check -p teachlink-contract --lib
  • full cargo test could not be completed locally due disk exhaustion from this repository’s heavy build graph in current environment

Closes #229

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 22, 2026

@mofejo1 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! 🚀

Learn more about application limits

@ISTIFANUS-N ISTIFANUS-N merged commit 3b4fa67 into rinafcode:main Apr 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix potential reentrancy vulnerability in transfer operations

2 participants