Function Admin
of addMinterContract
has too much power
#311
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-303
sufficient quality report
This report is of sufficient quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/NextGenCore.sol#L315-L318
Vulnerability details
Impact
In
NextGenCore.sol
, theaddMinterContract
function allows theFunction Admin
ofaddMinterContract
to set the address of theminterContract
, meaning he could add any contract instead of an actualminterContract
, as long as it defines the same function names (because of the checkrequire(IMinterContract(_minterContract).isMinterContract() == true, "Contract is not Minter");
)This is dangerous as it means this
Function Admin
’s malicious contract could the execute all the functions checkingin the
NextGenCore.sol
contract.This includes the
airDropTokens
,mint
andburnToMint
functions, which are key to the functioning of the NextGenCore contract.We mark this vulnerability as MEDIUM because the probability of the
Function Admin
to be malicious is relatively low, as he is himself set by aGlobal Admin
.Proof of Concept
Let’s have a look at the
addMinterContract
function belowThis allows the
Function Admin
foraddMinterContract
to set a new address for theminterContract
variable of theNextGenCore
contract.The line
means that this admin will be able to set any value for this address as long as it points to a contract defining the same function names as an actual
minterContract
(including aisMinterContract
public function returningtrue
).Through this malicious contract, he could then bypass all the
require(msg.sender == minterContract, "Caller is not the Minter Contract");
checks in the various functions of theNextGenCore
, which is a clear shortfall of governance for this contract, as these functions govern airdrops, burning and minting mechanisms.Tools Used
Manual Review / Visual Studio
Recommended Mitigation Steps
Set the value of
minterContract
address at contract creation, in theconstructor
. That will prevent anyFunction Admin
from manipulating theNextGenCore
contract.Assessed type
Governance
The text was updated successfully, but these errors were encountered: