REVIEW 4 major objections 5 minor 28 references
Combating Reentrancy Bugs on Sharded Blockchains
T0 review · 4 major / 5 minor · reviewed 2026-08-07 · deepseek-v4-flash
Pith's one-line read Sharded blockchains' asynchronous messaging makes reentrancy bugs more likely, and a caller-scoped lock with trap-safe cleanup plus TLA+ model checking can stop them.
desk verdict Useful locking pattern and PlusCal strategy for sharded-blockchain reentrancy, but the prevalence stat lacks methodology and the trap-cleanup guarantee is asserted, not tested. read the letter →
The pith
A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.
The reading
What carries the argument
The load-bearing mechanism has two parts. First, CallerGuard, a Rust struct that inserts the caller's principal, an ICP user identifier, into a pending-requests set on construction and removes it in Drop; ICP's runtime and Rust libraries are relied on to run that cleanup even when a message handler traps, so the lock cannot be left stuck. Second, a modeling strategy that translates async/await into PlusCal processes and labels, with queues for ordered requests and sets for unordered responses, so that the TLC model checker can explore all interleavings within small bounds; the ckBTC minter contract is the real-world case study.
What would settle it
Deploy a test canister on ICP whose message handler acquires a CallerGuard and then forces a trap, send a second request from the same principal, and check whether it is accepted; if the second request is permanently rejected, the runtime cleanup premise fails and the pattern does not hold.
Extended reading notes
Core claim
The central discovery is that reentrancy in sharded blockchains is not just Ethereum's problem restated: because cross-contract calls split into multiple message handlers with no reliable ordering, a check-then-act method like notify_minter can be interleaved with itself so that two executions both pass the 'unprocessed UTXOs' check and double-mint. The paper claims that 66% (10/15) of reviewed critical ICP contracts contained such bugs, and that a per-caller guard released by Rust's Drop on trap, combined with TLA+ and TLC verification, eliminates the class in practice. It further claims that eight of nine previously vulnerable Rust contract suites adopted the locking pattern in production with no known bugs.
Load-bearing premise
The locking pattern presupposes that the ICP runtime reliably runs cleanup code that drops local variables on every trap, a guarantee the paper asserts but does not demonstrate with a specification, test, or citation.
Editorial extensions
If this is right
- Eight of the nine previously vulnerable Rust contract suites have adopted the locking pattern in production, and the reviewed contracts using it have no known reentrancy bugs.
- The CallerGuard pattern can be adapted to contract-wide locks, locks on subsets of state, or limits on concurrent callers per principal, preserving more of the asynchronous model's parallelism.
- Existing Ethereum patterns, checks-effects-interactions and simple mutexes, do not translate directly because trap rollbacks can leave a mutex stuck and contract-wide locking negates the performance benefits of interleaving.
- TLA+ with TLC, run over small finite bounds, found reentrancy bugs in early versions of the ckBTC contracts and detects property violations whenever the protective locking is removed from the model.
- The TLA+ modeling strategy applies to NEAR and MultiversX as well, where explicit callbacks map to the same two-handler pattern, though PlusCal sugar would be less relevant there.
Reading between the lines
- Beyond the paper, the same modeling idiom could be applied to NEAR and MultiversX contracts directly, since their explicit callbacks already expose the same request-response decomposition that PlusCal labels model explicitly.
- The trap-safe cleanup guarantee could be hardened by a runtime-level test suite that traps in every code path after acquiring a CallerGuard, since the paper asserts but does not formally specify this runtime behavior.
- The per-principal locking granularity suggests a throughput trade-off the paper does not quantify: a single user issuing many serialized operations loses interleaving benefits, so DeFi applications with power users may need finer-grained locks or batching.
- The property that total ckBTC supply never exceeds deposited Bitcoin is a natural invariant family that could be checked on other wrapped-asset chains as a cross-chain reentrancy benchmark.
Editorial analysis
A structured set of objections, weighed in public.
Referee Report
Summary. The paper studies reentrancy vulnerabilities in sharded blockchains that use asynchronous messaging, taking the Internet Computer (ICP), NEAR, and MultiversX as case studies. It argues that the asynchronous, interleaved message-handler model creates new opportunities for reentrancy bugs that do not arise in Ethereum's synchronous model, and it supports this with a simplified ckBTC minter example. The paper evaluates existing Ethereum countermeasures (checks-effects-interactions and mutex locking), identifies why they fail in the asynchronous setting, and proposes a Rust RAII-style CallerGuard pattern with Drop-on-trap cleanup for ICP, plus an analogous Motoko try/finally approach. It then presents a PlusCal/TLA+ model of the ckBTC minter and reports TLC model-checking results for safety and liveness properties under small bounds. The paper also reports that 66% (10/15) of reviewed critical ICP contracts contained medium or high severity reentrancy bugs, and that eight contract suites have adopted the proposed locking solution.
Significance. If the paper's claims hold, it provides two practically valuable contributions: a concrete locking pattern that is applicable to real ICP smart contracts, and a demonstration that TLA+/PlusCal can model and verify the absence of reentrancy bugs in the asynchronous messaging model. The paper is written clearly, and the interleaving examples are easy to follow. Its strengths include a public formal-models repository, a measured instruction overhead of 2.92% for the locking pattern, and a concrete case study (ckBTC minter) with a stated invariant and a reported previously unknown bug found by the model checker. However, the central prevalence statistic and the Drop-on-trap cleanup guarantee are not backed by the level of evidence the paper's recommendations require; these are the main load-bearing points that need strengthening before the results can be fully credited.
major comments (4)
- [Section I (Abstract and Introduction)] The headline statistic that 66% (10/15) of reviewed critical ICP contracts contained medium or high severity reentrancy bugs is not accompanied by any methodology. This figure is load-bearing for the thesis that the asynchronous model makes reentrancy bugs more likely, but the paper does not state how the 15 contracts were selected, what review procedure was used (manual audit, tool-assisted, or both), what severity rubric was applied, or whether the reviews were independent and reproducible. Please provide a detailed methodology, a complete list of reviewed contracts, and ideally a comparator (e.g., a similar review of Ethereum contracts) so the reader can assess representativeness and severity calibration.
- [Section IV, Figure 4 (Drop-on-trap cleanup)] The paper's central remedy for the lock-stuck-on-trap problem is asserted rather than demonstrated. The text states that 'ICP's system API and Rust libraries features that can call cleanup code on traps in order to make sure that any local variables are still dropped,' but no specification, test, or citation is provided. Since the paper itself notes in Section IV issue 1 that the analogous lock on NEAR and MultiversX would stick on a trap, the entire ICP-specific advantage of the CallerGuard pattern depends on this cleanup guarantee holding for every trap class (panic!, unwrap, stack overflow, out-of-memory, failed system API call, and traps raised while processing a response to a downstream call). If any trap path skips cleanup, a contract employing the pattern can become permanently locked. Please provide evidence from the ICP runtime/library implementation or a test suite covering the relevant trap classes, or explicitly state the assumption and its verification status.
- [Section V-A-c and Figure 5 (TLA+ model scope)] The PlusCal model releases locks manually on every path and does not model a trap or panic after a lock has been acquired. Lines 20-21 and 30-31 of Figure 5 show explicit lock removal, and the text says 'We manually release locks in all cases.' Consequently, the TLA+ verification does not cover the Drop-on-trap cleanup mechanism that is the key novel guarantee of the proposed pattern; it verifies the locking discipline only under the assumption that cleanup always runs. Please either add a nondeterministic trap transition (with and without cleanup) to the model, or state explicitly that the verified properties are conditional on the runtime cleanup guarantee and are therefore not a substitute for evidence of that guarantee.
- [Section VI (TLC bounds and generality)] The model-checking results are obtained under very small bounds: 2 parallel invocations of the minter notification call, 2 BTC withdrawal calls, 2 users, and a BTC supply of 3 Satoshi. The paper cites relevant precedents that most bugs reproduce with small bounds, which is a reasonable argument, but the statement that 'we are yet to manually find a reentrancy bug that was missed in the TLC analysis due to the bounds being too small' is anecdotal and does not quantify the coverage gap. Please either provide a more rigorous argument that the verified properties are independent of the bounds (e.g., via parameterized invariants or symmetry reduction), or temper the conclusion that small bounds are sufficient for this class of bugs.
minor comments (5)
- [Section II-A] Typo: 'leding' should be 'leading' in the last paragraph.
- [Section III (ckBTC example)] Typo: 'Bitcion' should be 'Bitcoin' in the first paragraph.
- [Figure 4] The signature 'Result<()), String>' contains mismatched parentheses; it should be 'Result<(), String>'.
- [Section V-B] The liveness property discussion would benefit from stating the exact fairness assumptions used in the TLC model, since the paper notes that the property requires users to call notify_minter sufficiently often.
- [References] The phrase 'a slurry of research papers' is informal for a journal venue; consider replacing with 'a substantial body of research.'
Circularity Check
No significant circularity: the paper's claims rest on execution-model arguments, an empirical review statistic, and a machine-checked TLA+ model, none of which reduce to their own inputs.
full rationale
The paper's central claims are (i) that asynchronous sharded-blockchain messaging creates new reentrancy interleavings, (ii) that a per-caller RAII-style lock (CallerGuard) can prevent them on ICP, and (iii) that TLA+/PlusCal model checking can verify such protections. None of these is derived by definition from its inputs. The 66% (10/15) prevalence figure is reported as an empirical result of internal security reviews of ICP contracts; it is an input observation, not a fitted parameter or a prediction forced by construction. The CallerGuard pattern is proposed as a design, and its effectiveness is argued from the execution-model properties in Section II and from the PlusCal model in Section V. The TLA+ model checks an independently stated invariant (ckBTC supply cannot exceed controlled UTXOs) and can detect violations when protective mechanisms are removed; this is genuine model-based verification rather than a reformulation of the desired conclusion. The only noteworthy gaps are evidential, not circular: the claim that ICP's runtime runs Rust cleanup code on all traps is asserted without a specification or test (Section IV), and the PlusCal model manually releases locks on every path instead of modeling trap-driven cleanup. These are soundness and completeness concerns about the recommended pattern and the model's fidelity, but they are not cases where a prediction reduces to a fitted input or where a conclusion is imported from a self-citation. Self-references to DFINITY documentation and the authors' formal-models repository are non-load-bearing or are reproducible artifacts (the TLA+ model is checked with TLC and publicly available), so they do not raise the circularity score.
Assumptions & free parameters
free parameters (1)
- TLC model-checking bounds =
2 parallel notify_minter invocations, 2 BTC withdrawal calls, 2 users, BTC supply 3 Satoshi
assumptions (6)
- domain assumption ICP executes at most one message handler per smart contract at a time, and message order is not reliable.
- domain assumption If a message handler traps or panics, its state changes are reverted.
- domain assumption Every request eventually receives a response, possibly a system-generated error.
- domain assumption ICP Rust libraries guarantee that local variables are dropped, running cleanup code, even when a message handler traps.
- ad hoc to paper The hand-written PlusCal model faithfully represents the ckBTC minter contract.
- domain assumption Small TLC bounds suffice to detect real reentrancy bugs in practice.
Cite this review
Pith. "Pith review of Combating Reentrancy Bugs on Sharded Blockchains." pith.science (2026). https://pith.science/paper/L373HOYI
@misc{pith2026250605932,
author = {Pith},
title = {Pith review of: Combating Reentrancy Bugs on Sharded Blockchains},
year = {2026},
howpublished = {\url{https://pith.science/paper/L373HOYI}},
note = {Machine review of arXiv:2506.05932}
}
read the original abstract
Reentrancy is a well-known source of smart contract bugs on Ethereum, leading e.g. to double-spending vulnerabilities in DeFi applications. But less is known about this problem in other blockchains, which can have significantly different execution models. Sharded blockchains in particular generally use an asynchronous messaging model that differs substantially from the synchronous and transactional model of Ethereum. We study the features of this model and its effect on reentrancy bugs on three examples: the Internet Computer (ICP) blockchain, NEAR Protocol, and MultiversX. We argue that this model, while useful for improving performance, also makes it easier to introduce reentrancy bugs. For example, reviews of the pre-production versions of some of the most critical ICP smart contracts found that 66% (10/15) of the reviewed contracts -- written by expert authors -- contained reentrancy bugs of medium or high severity, with potential damages in tens of millions of dollars. We evaluate existing Ethereum programming techniques (in particular the effects-checks-interactions pattern, and locking) to prevent reentrancy bugs in the context of this new messaging model and identify some issues with them. We then present novel Rust and Motoko patterns that can be leveraged on ICP to solve these issues. Finally, we demonstrate that the formal verification tool TLA+ can be used to find and eliminate such bugs in real world smart contracts on sharded blockchains.
Figures
Figures from the paper (2 more)
Reference graph
Works this paper leans on
-
[1]
A survey of attacks on ethereum smart contracts sok,
N. Atzei, M. Bartoletti, and T. Cimoli, “A survey of attacks on ethereum smart contracts sok,” in Proceedings of the 6th International Conference on Principles of Security and Trust - Volume 10204. Berlin, Heidelberg: Springer-Verlag, 2017, p. 164–186. [Online]. Available: https://doi.org/10.1007/978-3-662-54455-6 8
-
[2]
Smart contract security field guide - reentrancy,
D. Muhs, “Smart contract security field guide - reentrancy,” (accessed April 15 2024) https://scsfg.io/hackers/reentrancy/, 2023
work page 2024
-
[3]
Refactoring solidity smart contracts to protect against reentrancy exploits,
S. Demeyer, H. Rocha, and D. Verheijke, “Refactoring solidity smart contracts to protect against reentrancy exploits,” in Leveraging Ap- plications of Formal Methods, Verification and Validation. Software Engineering, T. Margaria and B. Steffen, Eds. Cham: Springer Nature Switzerland, 2022, pp. 324–344
work page 2022
-
[4]
Reguard: Finding reentrancy bugs in smart contracts,
C. Liu, H. Liu, Z. Cao, Z. Chen, B. Chen, and B. Roscoe, “Reguard: Finding reentrancy bugs in smart contracts,” in Proceedings of the 40th International Conference on Software Engineering: Companion Proceeedings, ser. ICSE ’18. New York, NY , USA: Association for Computing Machinery, 2018, p. 65–68. [Online]. Available: https://doi.org/10.1145/3183440.3183495
-
[5]
Online detection of effectively callback free objects with applications to smart contracts,
S. Grossman, I. Abraham, G. Golan-Gueta, Y . Michalevsky, N. Rinetzky, M. Sagiv, and Y . Zohar, “Online detection of effectively callback free objects with applications to smart contracts,” Proc. ACM Program. Lang. , vol. 2, no. POPL, dec 2017. [Online]. Available: https://doi.org/10.1145/3158136
doi:10.1145/3158136 2017
-
[6]
A survey on security verification of blockchain smart contracts,
J. Liu and Z. Liu, “A survey on security verification of blockchain smart contracts,” IEEE Access, vol. 7, pp. 77 894–77 904, 2019
work page 2019
-
[7]
Formal verification of smart contracts: Short paper,
K. Bhargavan, A. Delignat-Lavaud, C. Fournet, A. Gollamudi, G. Gonthier, N. Kobeissi, N. Kulatova, A. Rastogi, T. Sibut-Pinote, N. Swamy, and S. Zanella-B ´eguelin, “Formal verification of smart contracts: Short paper,” in Proceedings of the 2016 ACM Workshop on Programming Languages and Analysis for Security , ser. PLAS ’16. New York, NY , USA: Associati...
arXiv 2016
-
[8]
The internet computer for geeks,
DFINITY , “The internet computer for geeks,” (accessed April 15 2024) https://eprint.iacr.org/2022/087, 2022
work page 2024
Show all 28 references
-
[9]
The near white paper,
NEAR, “The near white paper,” (accessed April 15 2024) https://pages. near.org/papers/the-official-near-white-paper/, 2021
2024
-
[10]
MultiversX - A Highly Scalable Public Blockchain via Adaptive State Sharding and Secure Proof of Stake,
T. M. Team, “MultiversX - A Highly Scalable Public Blockchain via Adaptive State Sharding and Secure Proof of Stake,” Tech. Rep., 2019. [Online]. Available: https://files.multiversx.com/multiversx-whitepaper. pdf
2019
-
[11]
POLKADOT: VISION FOR A HETEROGENEOUS MULTI-CHAIN FRAMEWORK,
G. Wood, “POLKADOT: VISION FOR A HETEROGENEOUS MULTI-CHAIN FRAMEWORK,” Tech. Rep
-
[12]
Cerberus: Minimalistic Multi-shard Byzantine-resilient Transaction Processing,
J. Hellings, D. P. Hughes, J. Primero, and M. Sadoghi, “Cerberus: Minimalistic Multi-shard Byzantine-resilient Transaction Processing,” Aug. 2020, arXiv:2008.04450 [cs]. [Online]. Available: http://arxiv.org/ abs/2008.04450
2020 arXiv
-
[13]
Motoko programming language,
DFINITY , “Motoko programming language,” (accessed April 15 2024) https://internetcomputer.org/docs/current/motoko/main/motoko
2024
-
[14]
Chain-key bitcoin (ckbtc),
——, “Chain-key bitcoin (ckbtc),” (accessed April 15 2024) https://inte rnetcomputer.org/docs/current/developer-docs/integrations/bitcoin/ckb tc
2024
-
[15]
Bitcoin: A peer-to-peer electronic cash system,
S. Nakamoto, “Bitcoin: A peer-to-peer electronic cash system,” Decen- tralized business review, 2008
2008
-
[16]
Design and analysis of a distributed ecdsa signing service,
J. Groth and V . Shoup, “Design and analysis of a distributed ecdsa signing service,” Cryptology ePrint Archive, Paper 2022/506, 2022, https://eprint.iacr.org/2022/506. [Online]. Available: https: //eprint.iacr.org/2022/506
2022
-
[17]
Analysis of the bitcoin utxo set,
S. Delgado-Segura, C. P ´erez-Sola, G. Navarro-Arribas, and J. Herrera- Joancomart´ı, “Analysis of the bitcoin utxo set,” in Financial Cryptog- raphy and Data Security: FC 2018 International Workshops, BITCOIN, VOTING, and WTSC, Nieuwpoort, Curac ¸ao, March 2, 2018, Revised Se...
2018
-
[18]
Declarative control flow,
A. Alexandrescu, “Declarative control flow,” (accessed April 15 2024) https://github.com/CppCon/CppCon2015/blob/18943d6288b1cba54922 627b71b7d21d7f1175f1/Presentations/Declarative%20Control%20Flow/ Declarative%20Control%20Flow%20-%20Andrei%20Alexandrescu% 20-%20CppCon%202015.pdf, 2015
2024
-
[19]
Motoko try / finally construct,
DFINITY , “Motoko try / finally construct,” (accessed Jan 9 2025) https: //internetcomputer.org/docs/current/motoko/main/reference/language-m anual/#try
2025
-
[20]
Lamport, Specifying Systems: The TLA+ Language and Tools for Hardware and Software Engineers
L. Lamport, Specifying Systems: The TLA+ Language and Tools for Hardware and Software Engineers . Addison-Wesley, June 2002. [Online]. Available: https://www.microsoft.com/en-us/research/publica tion/specifying-systems-the-tla-language-and-tools-for-hardware-and-s oftware-engineers/
2002
-
[21]
Model checking tla+ specifica- tions,
Y . Yu, P. Manolios, and L. Lamport, “Model checking tla+ specifica- tions,” in Correct Hardware Design and Verification Methods, L. Pierre and T. Kropf, Eds. Berlin, Heidelberg: Springer Berlin Heidelberg, 1999, pp. 54–66
1999
-
[22]
Tla+ model checking made symbolic,
I. Konnov, J. Kukovec, and T.-H. Tran, “Tla+ model checking made symbolic,” Proceedings of the ACM on Programming Languages, vol. 3, no. OOPSLA, pp. 1–30, 2019
2019
-
[23]
Tla+ proofs,
D. Cousineau, D. Doligez, L. Lamport, S. Merz, D. Ricketts, and H. Vanzetto, “Tla+ proofs,” in FM 2012: Formal Methods: 18th Inter- national Symposium, Paris, France, August 27-31, 2012. Proceedings
2012
-
[24]
Springer, 2012, pp. 147–154
2012
-
[25]
The pluscal algorithm language,
L. Lamport, “The pluscal algorithm language,” in International Collo- quium on Theoretical Aspects of Computing. Springer, 2009, pp. 36–60
2009
-
[26]
ckbtc tla+ model,
O. Mari ´c, “ckbtc tla+ model,” (accessed April 17 2025) https://github.c om/dfinity/formal-models/tree/55f806d396a999a7a244545028f8d2187 4457f56/tla/ckbtc
2025
-
[27]
Learning from mistakes: a comprehensive study on real world concurrency bug characteristics,
S. Lu, S. Park, E. Seo, and Y . Zhou, “Learning from mistakes: a comprehensive study on real world concurrency bug characteristics,” in Proceedings of the 13th international conference on Architectural support for programming languages and operating systems , ser. ASPLOS XIII....
2008
-
[28]
Simple Testing Can Prevent Most Critical Failures: An Analysis of Production Failures in Distributed Dataintensive Systems,
D. Yuan, Y . Luo, X. Zhuang, G. R. Rodrigues, X. Zhao, Y . Zhang, P. U. Jain, and M. Stumm, “Simple Testing Can Prevent Most Critical Failures: An Analysis of Production Failures in Distributed Dataintensive Systems,” in Proceedings of the 11th Symposium on Operating Systems D...
2014
Reviewed August 7, 2026 · model on record in the stance chip above.
Discussion (0). Sign in to comment.