You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Access Control Vulnerability in mintFromInterest Allows Unauthorized Token Minting
Summary
The mintUBIFromInterest in GoodDollarExpansion.sol function does not have an access control mechanism itself.
function mintUBIFromInterest(bytes32exchangeId, uint256reserveInterest) external {
require(reserveInterest >0, "Reserve interest must be greater than 0");
IBancorExchangeProvider.PoolExchange memory exchange =IBancorExchangeProvider(address(goodDollarExchangeProvider))
.getPoolExchange(exchangeId);
uint256 amountToMint = goodDollarExchangeProvider.mintFromInterest(exchangeId, reserveInterest);
require(IERC20(exchange.reserveAsset).transferFrom(msg.sender, reserve, reserveInterest), "Transfer failed");
IGoodDollar(exchange.tokenAddress).mint(address(distributionHelper), amountToMint);
// Ignored, because contracts only interacts with trusted contracts and tokens// slither-disable-next-line reentrancy-eventsemitInterestUBIMinted(exchangeId, amountToMint);
}
This means anyone can call it, and they can potentially trigger the minting of tokens.
Then, when mintUBIFromInterest calls mintFromInterest, the msg.sender is the goodDollarExpansion.sol contract. Since msg.sender in mintFromInterest is the contract address (goodDollarExpansion.sol) , it passes the onlyExpansionController check.
Here's the function that sets the expansion controller address.
function setExpansionController(address_expansionController) public onlyOwner {
require(_expansionController !=address(0), "ExpansionController address must be set");
expansionController =IGoodDollarExpansionController(_expansionController);
emitExpansionControllerUpdated(_expansionController);
}
So when a user, whether malicious or not interacts with the mintUBIFromInterest and makes an external call to mintFromInterest where the msg.sender is expansionController , the check will pass. Because
modifier onlyExpansionController() {
require(msg.sender==address(expansionController), "Only ExpansionController can call this function");
_;
}
An attacker could mint an arbitrary number of tokens without proper authorization, resulting in inflation, dilution of existing token holders’ assets, and potential collapse of the token's value.
In GoodDollarExpansion.sol:147, an unauthorized user or attacker can bypass the onlyExpansionController access control mechanism by exploiting external function calls where the msg.sender is an expansion controller.
Internal pre-conditions
The contract must be designed such that mintUBIFromInterest that doesn't have access control and callable by anyone calls the external function mintFromInterest.
The goodDollarExchangeProvider must have the onlyExpansionController modifier that allows its address to pass the access control check because the call came from an expansion controller contract.
External pre-conditions
A malicious user must be able to interact with the contract and call the mintUBIFromInterest function.
There must be no additional check to detect that the original caller is an attacker.
Attack Path
A user (malicious or not) can invoke mintUBIFromInterest.
This function calls mintFromInterest on goodDollarExchangeProvider.
Because msg.sender in mintFromInterest is the GoodDollarExpansion contract, the onlyExpansionController check passes.
The attacker could effectively mint tokens without proper authorization.
Impact
Financial Loss: An attacker could mint an arbitrary number of tokens without proper authorization, resulting in inflation, dilution of existing token holders’ assets, and potential collapse of the token's value.
Havoc: If an attacker gains unauthorized access, they can destabilize the entire system by minting excess tokens, undermining trust in the token economy and damaging the project’s reputation.
PoC
Invoke the Function: An attacker creates a transaction that calls mintUBIFromInterest with valid parameters.
Trigger External Call: The transaction executes, calling mintFromInterest through the goodDollarExpansion contract.
Mint Tokens: The attacker successfully mints tokens due to the absence of proper access controls.
Mitigation
Consider this:
Use a mapping to store addresses associated with each role. For example:
mapping(address=>bool) public expansionControllers;
Then, create modifiers to restrict access. For example
modifier onlyExpansionController() {
require(expansionControllers[msg.sender], "Not an Expansion Controller");
_;
}
Provide functions to assign and revoke roles. For example:
function assignExpansionController(address_controller) public onlyOwner {
expansionControllers[_controller] =true;
}
function revokeExpansionController(address_controller) public onlyOwner {
expansionControllers[_controller] =false;
}
Finally, Use the role modifiers in critical functions to enforce access control.
The text was updated successfully, but these errors were encountered:
sherlock-admin3
changed the title
Spicy Fuchsia Sawfish - Access Control Vulnerability in mintFromInterest Allows Unauthorized Token Minting
0xpetern - Access Control Vulnerability in mintFromInterest Allows Unauthorized Token Minting
Nov 5, 2024
0xpetern
Medium
Access Control Vulnerability in mintFromInterest Allows Unauthorized Token Minting
Summary
The
mintUBIFromInterest
in GoodDollarExpansion.sol function does not have an access control mechanism itself.This means anyone can call it, and they can potentially trigger the minting of tokens.
Then, when mintUBIFromInterest calls mintFromInterest, the msg.sender is the goodDollarExpansion.sol contract. Since msg.sender in mintFromInterest is the contract address (goodDollarExpansion.sol) , it passes the onlyExpansionController check.
Here's the function that sets the expansion controller address.
So when a user, whether malicious or not interacts with the
mintUBIFromInterest
and makes an external call tomintFromInterest
where the msg.sender is expansionController , the check will pass. BecauseAn attacker could mint an arbitrary number of tokens without proper authorization, resulting in inflation, dilution of existing token holders’ assets, and potential collapse of the token's value.
Root Cause
https://github.com/sherlock-audit/2024-10-mento-update/blob/main/mento-core/contracts/goodDollar/GoodDollarExpansionController.sol#L137C3-L150C4
https://github.com/sherlock-audit/2024-10-mento-update/blob/main/mento-core/contracts/goodDollar/GoodDollarExchangeProvider.sol#L172C3-L188C4.
In
GoodDollarExpansion.sol:147
, an unauthorized user or attacker can bypass the onlyExpansionController access control mechanism by exploiting external function calls where the msg.sender is an expansion controller.Internal pre-conditions
External pre-conditions
Attack Path
The attacker could effectively mint tokens without proper authorization.
Impact
PoC
Mitigation
Consider this:
The text was updated successfully, but these errors were encountered: