Admin can’t burn tokens from blocklisted addresses because of a check in _beforeTokenTransfer
The burn function is intended to let an admin burn tokens from any account, but a check in _beforeTokenTransfer prevents burning from blocklisted, sanctioned, or non-allowlisted addresses. An attacker cannot directly exploit this, but it could delay the admin's ability to burn tokens from a blocked account.
The function burn is made so the admin can burn rUSDY tokens from any account (this is stated in the comments). However, the admin can’t burn tokens if the account from which they’re trying to burn tokens is blocklisted/sanctioned/not on the allow-list.
Proof of Concept
Let’s check the burn function which calls the internal _burnShares function:
We can see that it calls _beforeTokenTransfer(_account, address(0), _sharesAmount).
Here is the code of _beforeTokenTransfer:
function _beforeTokenTransfer(
address from,
address to,
uint256
) internal view {
// Check constraints when `transferFrom` is called to facilitate
// a transfer between two parties that are not `from` or `to`.
if (from != msg.sender && to != msg.sender) {
require(!_isBlocked(msg.sender), "rUSDY: 'sender' address blocked");
require(!_isSanctioned(msg.sender), "rUSDY: 'sender' address sanctioned");
require(
_isAllowed(msg.sender),
"rUSDY: 'sender' address not on allowlist"
);
}
if (from != address(0)) { <--
// If not minting
require(!_isBlocked(from), "rUSDY: 'from' address blocked");
require(!_isSanctioned(from), "rUSDY: 'from' address sanctioned");
require(_isAllowed(from), "rUSDY: 'from' address not on allowlist");
}
if (to != address(0)) {
// If not burning
require(!_isBlocked(to), "rUSDY: 'to' address blocked");
require(!_isSanctioned(to), "rUSDY: 'to' address sanctioned");
require(_isAllowed(to), "rUSDY: 'to' address not on allowlist");
}
}
In our case, the form would be the account from which we’re burning tokens, so it’ll enter in the 2nd if: if (from != address(0)). But given that the account is blocked/sanctioned/not on the allow-list, the transaction will revert and the tokens won’t be burned.
Given that there are separate roles for burning and managing the block/sanctions/allowed lists (BURNER_ROLE and LIST_CONFIGURER_ROLE), it is very possible that such a scenario would occur.
In that case, the Burner would have to ask the List Configurer to update the lists, so the Burner can burn the tokens, and then the List Configurer should update the lists again. However, in that case, you’re risking that the blocked user manages to transfer their funds while performing these operations.
Recommended Mitigation Steps
Organize the logic of the function better. For example, you can make the 2nd if to be: if (from != address(0) && to != address(0)). That way, we’ll not enter the if when burning tokens, and we’ll be able to burn tokens from blocked accounts.
Can I not assume that the guardian can batch execute transactions? Given that the guardian will also have the ability to add/remove from blocklist, can I not assume that the guardian can batch:
This is an interesting edge case. While it may be possible for guardian to bypass this issue, if it is a smart contract that can batch transactions, I see this as a potential issue.
Going to downgrade issue #120 to medium severity, as there are some theoretical workarounds to this problem.
But to your point @kirk-baird, we are using a gnosis safe contract as the guardian, and plan to do a similar setup for the majority of tokens going forward. Perhaps we should have made note of that in the ReadME.md.
@tom2o17 - Okay thanks for clarifying - that does resolve the issue. Though, for the judging the wardens weren’t aware of this so I’ll consider it a valid issue.
The original report as published on Code4rena, by 0xAsen. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
The _beforeTokenTransfer function checks the 'from' address even when burning (to is the zero address), so it reverts if the 'from' address is blocked, sanctioned, or not allowed.
Impact
The admin cannot burn tokens from a blocked account, which could delay the burn until the lists are updated, potentially allowing the blocked user to transfer funds in the meantime.
What the attacker needed
Admin has BURNER_ROLE; target account is blocked, sanctioned, or not allowed
The fix
The check should be changed so that the 'from' address is only validated when it is not a burn (i.e., when 'to' is not the zero address), for example by using 'if (from != address(0) && to != address(0))'.
How it was found
Admin calls burn on an account that is blocklisted, sanctioned, or not on the allow-list.
The burn function calls _burnShares, which calls _beforeTokenTransfer with the account as 'from' and the zero address as 'to'.
_beforeTokenTransfer sees that 'from' is not the zero address and checks if 'from' is blocked, sanctioned, or allowed.
Because the account is blocked, sanctioned, or not allowed, the check fails and the transaction reverts.
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.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
This is a smart contract for a token. The admin has a special power to destroy (burn) tokens from any user's account, for example to punish a blocked user. But the code also checks if the account is blocked before burning, so the admin cannot burn tokens from a blocked account. This is a problem because the admin should be able to burn tokens even from blocked accounts.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.