Skip to content

test(nano): Add a test for reentrancy attack#1324

Merged
msbrogli merged 1 commit intomasterfrom
test/reentrancy-attack
Jul 23, 2025
Merged

test(nano): Add a test for reentrancy attack#1324
msbrogli merged 1 commit intomasterfrom
test/reentrancy-attack

Conversation

@msbrogli
Copy link
Member

@msbrogli msbrogli commented Jul 16, 2025

Blueprint developers must exercise caution when invoking external contracts, as this can introduce reentrancy vulnerabilities.

This PR includes an example blueprint that demonstrates a common reentrancy flaw: calling an external contract before updating the internal state. This mistake can allow an attacker to exploit the contract and repeatedly withdraw funds before the balance is properly updated.

Acceptance criteria

  1. Add a blueprint that is vulnerable to a reentrancy attack, enabling an attacker to drain all funds from the contract by bypassing the per-address withdrawal limit.

@msbrogli msbrogli requested a review from jansegre as a code owner July 16, 2025 21:05
@msbrogli msbrogli moved this from Todo to In Progress (WIP) in Hathor Network Jul 16, 2025
@github-actions
Copy link

github-actions bot commented Jul 16, 2025

🐰 Bencher Report

Branchtest/reentrancy-attack
Testbedubuntu-22.04
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
minutes (m)
(Result Δ%)
Lower Boundary
minutes (m)
(Limit %)
Upper Boundary
minutes (m)
(Limit %)
sync-v2 (up to 20000 blocks)📈 view plot
🚷 view threshold
1.78 m
(+8.60%)Baseline: 1.64 m
1.48 m
(82.88%)
1.80 m
(98.72%)
🐰 View full continuous benchmarking report in Bencher

@msbrogli msbrogli self-assigned this Jul 17, 2025
@msbrogli msbrogli force-pushed the test/reentrancy-attack branch 2 times, most recently from a62196d to b5ad9ba Compare July 17, 2025 21:36
@msbrogli msbrogli moved this from In Progress (WIP) to In Progress (Done) in Hathor Network Jul 22, 2025
@msbrogli msbrogli requested a review from glevco July 22, 2025 16:06
jansegre
jansegre previously approved these changes Jul 22, 2025
glevco
glevco previously approved these changes Jul 23, 2025
@github-project-automation github-project-automation bot moved this from In Progress (Done) to In Review (WIP) in Hathor Network Jul 23, 2025
@glevco glevco moved this from In Review (WIP) to In Review (Done) in Hathor Network Jul 23, 2025
@msbrogli msbrogli dismissed stale reviews from glevco and jansegre via 8abef61 July 23, 2025 17:47
@msbrogli msbrogli force-pushed the test/reentrancy-attack branch 2 times, most recently from 8abef61 to bca8ac4 Compare July 23, 2025 17:53
@msbrogli msbrogli force-pushed the test/reentrancy-attack branch from bca8ac4 to 0faf646 Compare July 23, 2025 18:24
@msbrogli msbrogli merged commit 0faf646 into master Jul 23, 2025
7 checks passed
@msbrogli msbrogli deleted the test/reentrancy-attack branch July 23, 2025 18:25
@github-project-automation github-project-automation bot moved this from In Review (Done) to Waiting to be deployed in Hathor Network Jul 23, 2025
@codecov
Copy link

codecov bot commented Jul 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.65%. Comparing base (4935e56) to head (0faf646).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1324      +/-   ##
==========================================
+ Coverage   85.60%   85.65%   +0.05%     
==========================================
  Files         424      424              
  Lines       31994    31994              
  Branches     4971     4971              
==========================================
+ Hits        27390    27406      +16     
+ Misses       3603     3595       -8     
+ Partials     1001      993       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jansegre jansegre moved this from Waiting to be deployed to Done in Hathor Network Aug 5, 2025
This was referenced Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants