Malicious users can bypass the blacklist
The protocol implements a blacklist by assigning a role to addresses, but users can renounce that role themselves via the standard AccessControl renounceRole function. A blacklisted user could therefore remove their own blacklist status and transfer funds again.
0xloscar01 Follow with Drynooo, PNS and 5 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-05-midas-judging/issues/9
The protocol has acknowledged this issue.
Found by
0xloscar01, Drynooo, PNS, blutorque, deepkin, den_sosnovskyi, recursiveEth, wildflowerzx
Summary
The protocol sets the blacklist through roles, and users can bypass the blacklist through the renounceRole function.
Vulnerability Detail
mTBILL does not allow blacklisted users to transfer funds.
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
)
internal
virtual
override(ERC20PausableUpgradeable)
onlyNotBlacklisted(from)
onlyNotBlacklisted(to)
{
ERC20PausableUpgradeable._beforeTokenTransfer(from, to, amount);
}
But it is implemented in the form of giving BLACKLISTED_ROLE.
function _onlyNotBlacklisted(address account)
private
view
onlyNotRole(BLACKLISTED_ROLE, account)
{}
The AccessControlUpgradeable contract has a renounceRole function, through which users can give up their BLACKLISTED_ROLE, thereby bypassing the blacklist.
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
Impact
Malicious users can bypass the blacklist.
Code Snippet
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
)
internal
virtual
override(ERC20PausableUpgradeable)
onlyNotBlacklisted(from)
onlyNotBlacklisted(to)
{
ERC20PausableUpgradeable._beforeTokenTransfer(from, to, amount);
}
Tool used
Manual Review
Recommendation
It is recommended not to use roles to implement blacklists.
Discussion
pkqs90
Nice issue. I missed the escalation period but still want to make a comment - should this therotically be medium instead of high, since it won't cause a direct loss of funds or non-material losses?
amankakar
Nice issue. I missed the escalation period but still want to make a comment - should this therotically be medium instead of high, since it won't cause a direct loss of funds or non-material losses?
Although i have missed this finding But I think the High is appropriate because the user can easily bypass the blacklist status.
blutorque
I think this is more severe, considering the mTBill can immediately be traded in a secondary market(such as Morpho), which already hold ~30% of mTBill supply.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The blacklist was implemented using a self-renounceable role, so the restricted party could remove its own restriction.
What the attacker needed
User is blacklisted; user can call renounceRole
The fix
The blacklist should not be implemented using roles that the restricted user can renounce; a separate mechanism that only the protocol can change should be used.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A blacklist is a list of addresses that are not allowed to move tokens. Here the blacklist is enforced by giving each blocked address a special role (a permission tag) in the smart contract. The standard role system lets any address remove its own roles, so a blocked user can simply drop the blacklist role and become unblocked.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.