There is no restriction on the owner minting tokens, which leads to token inflation and a loss of user confidence.
Description
The owner can mint any number of tokens without any restrictions, which leads to inflation and a significant drop in the token's value. Furthermore, there is no mechanism for burning tokens when needed.
pragma solidity ^0.8.24;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
contract BriTechToken is ERC20, Ownable {
constructor() ERC20("BriTechLabs", "BTT") Ownable(msg.sender) {}
@> function mint() public onlyOwner {
@> _mint(owner(), 10_000_000 * 1e18);
}
}
Risk
Likelihood:
Impact:
Proof of Concept
1. Make deploy to contract.
2. Try mint tokens More than once.
Put this test in `briVault.t.sol`.
```javascript
function testPrintBalanceFiveMints() public {
vm.startPrank(owner);
MockERC20 token = new MockERC20("Mock Token", "MTK");
console.log("Initial balance:", token.balanceOf(owner));
for (uint256 i = 0; i < 5; i++) {
token.mint(owner, 1 ether);
console.log("Mint #", i + 1);
console.log("Balance after mint:", token.balanceOf(owner));
}
vm.stopPrank();
}
```
Recommended Mitigation
1. Adding a method to the contract to allow burning tokens when needed.
```diff
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
contract BriTechToken is ERC20, Ownable {
constructor() ERC20("BriTechLabs", "BTT") Ownable(msg.sender) {}
function mint() public onlyOwner {
_mint(owner(), 10_000_000 * 1e18);
}
+ function burn(uint256 amount) public onlyOwner {
+ _burn(owner(), amount);
+ }
}
```