Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anyone can burn their tokens, locking collateral in contract #30

Open
codehawks-bot opened this issue Aug 5, 2023 · 0 comments
Open

Comments

@codehawks-bot
Copy link

Anyone can burn their tokens, locking collateral in contract

Severity

High Risk

Summary

Anyone can burn their tokens, locking collateral in contract

Vulnerability Details

DecentralizedStableCoin.sol has two onlyOwner functions, burn and mint and only DSCEngine should be able to burn and mint new tokens.

However ERC20Burnable has another function, burnFrom which can be used to burn tokens by any account.

PoC

function testNoOtherAccountCanBurnTokensUsingBurnFrom() public {
        // Alice has two accounts
        address ALICE = address(1337);
        address ALICE2 = address(1338);

        vm.prank(dsc.owner());
        dsc.mint(ALICE, 100);
        
        // Alice approves her second account
        vm.prank(ALICE);
        dsc.approve(ALICE2, 1);

        // Alice should not be able to use her second account to burn her tokens
        vm.prank(ALICE2);
        vm.expectRevert();
        dsc.burnFrom(ALICE, 1);
        
    }

Impact

Any account can burn tokens from approved addresses, locking collateral in the contract and breaking the assumption of DSCEngine being the only burner of tokens.

Tools Used

Manuel review

Recommendations

Override burnFrom() from ERC20Burnable or don’t use ERC20Burnable and use ERC20 directly instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants