Skip to content

Latest commit

 

History

History
53 lines (32 loc) · 1.2 KB

019.md

File metadata and controls

53 lines (32 loc) · 1.2 KB

Happy Rouge Coyote

Medium

changeOwner function wont work

Summary

The following changeOwner is intended to change the owner of the contract, but the owner variable is shadowed and it will not change.

Root Cause

The passed parameter owner is the same as the storage variable owner this leads to shadowing.

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No response

Impact

The owners of the contracts DebitaV3Aggregator, AuctionFactory and buyOrderFactory won't change because of a broken function

PoC

    function testChangeOwner() public {
        address newAddress = makeAddr("newOwner");
        factory.changeOwner(newAddress);

        vm.prank(newAddress);
        factory.changeOwner(makeAddr("newOwner2"));
    }

Output:

Failing tests:
Encountered 1 failing test in test/local/auctions/AuctionFactory.t.sol:AuctionFactoryTest
[FAIL: revert: Only owner] testChangeOwner() (gas: 10494)

Mitigation

Change the parameter passed to function to _owner.