Open code423n4 opened 1 year ago
0xA5DF marked the issue as duplicate of #370
hansfriese changed the severity to QA (Quality Assurance)
hansfriese marked the issue as grade-a
This previously downgraded issue has been upgraded by hansfriese
hansfriese changed the severity to QA (Quality Assurance)
Lines of code
https://github.com/code-423n4/2023-04-frankencoin/blob/main/contracts/Frankencoin.sol#L152-L157 https://github.com/code-423n4/2023-04-frankencoin/blob/main/contracts/Frankencoin.sol#L293-L295
Vulnerability details
Impact
When
block.timestamp
andminters[_minter]
are equal, a suggested minter can be denied by calling the followingFrankencoin.denyMinter
function becauseblock.timestamp > minters[_minter]
is false.https://github.com/code-423n4/2023-04-frankencoin/blob/main/contracts/Frankencoin.sol#L152-L157
However, when
block.timestamp
andminters[_minter]
are equal, calling the followingFrankencoin.isMinter
function also returns true for the suggested minter sinceminters[_minter] != 0
andblock.timestamp >= minters[_minter]
are both true; this means that such suggested minter can actually mint ZCHF tokens immediately at that moment.https://github.com/code-423n4/2023-04-frankencoin/blob/main/contracts/Frankencoin.sol#L293-L295
Therefore, the
Frankencoin.denyMinter
andFrankencoin.isMinter
functions contradict each other whenblock.timestamp
andminters[_minter]
are equal. Atblock.timestamp
that equalsminters[_minter]
, if a suggested minter is considered as approved, it should be allowed to mint; yet, a qualified pool share holder can frontrun the minter'sFrankencoin.mint
transaction by calling theFrankencoin.denyMinter
function to block such minter from minting. On the other hand, atblock.timestamp
that equalsminters[_minter]
, if a suggested minter is deniable, it should be allowed to be denied; yet, such minter can frontrun a qualified pool share holder'sFrankencoin.denyMinter
transaction by calling theFrankencoin.mint
function to mint some ZCHF tokens before it gets denied. In the former case, the suggested minter cannot mint when it should be able to so the suggested minter is DOS'ed unexpectedly. In the latter case, the suggested minter is able to mint when it should not be, which can be more severe than the former case if the minter is malicious and should be prevented from minting any ZCHF tokens.Proof of Concept
Please replace https://github.com/code-423n4/2023-04-frankencoin/blob/main/test/PluginVetoTests.ts#L59-L68 with the following code in
test\PluginVetoTests.ts
. BothFrontrunning Frankencoin.mint transaction by calling Frankencoin.denyMinter function at block.timestamp that equals minters[_minter]
andFrontrunning Frankencoin.denyMinter transaction by calling Frankencoin.mint function at block.timestamp that equals minters[_minter]
tests will pass to demonstrate the described scenarios.Tools Used
VSCode
Recommended Mitigation Steps
https://github.com/code-423n4/2023-04-frankencoin/blob/main/contracts/Frankencoin.sol#L152-L157 can be updated to the following code:
or
https://github.com/code-423n4/2023-04-frankencoin/blob/main/contracts/Frankencoin.sol#L293-L295 can be updated to the following code:
but not both.