11 - Backdoor
Make sure you take enough time to understand each contract!
// Deploy Gnosis Safe master copy and factory contracts
this.masterCopy = await (await ethers.getContractFactory('GnosisSafe', deployer)).deploy();
this.walletFactory = await (await ethers.getContractFactory('GnosisSafeProxyFactory', deployer)).deploy();
this.token = await (await ethers.getContractFactory('DamnValuableToken', deployer)).deploy();// Deploy the registry
this.walletRegistry = await (
await ethers.getContractFactory('WalletRegistry', deployer)
).deploy(this.masterCopy.address, this.walletFactory.address, this.token.address, users);/** SUCCESS CONDITIONS */
for (let i = 0; i < users.length; i++) {
let wallet = await this.walletRegistry.wallets(users[i]);
// User must have registered a wallet
expect(wallet).to.not.eq(ethers.constants.AddressZero, 'User did not register a wallet');
// User is no longer registered as a beneficiary
expect(await this.walletRegistry.beneficiaries(users[i])).to.be.false;
}
// Attacker must have taken all tokens
expect(await this.token.balanceOf(attacker.address)).to.eq(AMOUNT_TOKENS_DISTRIBUTED);Solution
Last updated