Skip to content
Business logic Audit finding Intermediate

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.

0xAsen Follow with Arz, Inspecktor and 4 others

Originally disclosed on Code4rena

Submitted by 0xAsen, also found by Arz, Inspecktor, merlin, Delvir0, BenRai, and 0xStalin

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:

function burn(
    address _account,
    uint256 _amount
  ) external onlyRole(BURNER_ROLE) {
    uint256 sharesAmount = getSharesByRUSDY(_amount);

    _burnShares(_account, sharesAmount);

    usdy.transfer(msg.sender, sharesAmount / BPS_DENOMINATOR);

    emit TokensBurnt(_account, _amount);
  }

  function _burnShares(
    address _account,
    uint256 _sharesAmount
  ) internal whenNotPaused returns (uint256) {
    require(_account != address(0), "BURN_FROM_THE_ZERO_ADDRESS");

    _beforeTokenTransfer(_account, address(0), _sharesAmount); <--

    uint256 accountShares = shares[_account];
    require(_sharesAmount <= accountShares, "BURN_AMOUNT_EXCEEDS_BALANCE");

    uint256 preRebaseTokenAmount = getRUSDYByShares(_sharesAmount);

    totalShares -= _sharesAmount;

    shares[_account] = accountShares - _sharesAmount;

    uint256 postRebaseTokenAmount = getRUSDYByShares(_sharesAmount);

    return totalShares;

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.

Assessed type

Invalid Validation

tom2o17 (Ondo) disputed and commented via duplicate issue #120:

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:

blocklist.removeFromBlocklist()
rUSDY.burn()
blocklist.addToBlocklist()

IFL this is not an issue considering the guardian address can execute any peripheral txns in an atomic fashion.

kirk-baird (judge) commented via duplicate issue #120:

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.

tom2o17 (Ondo) commented via duplicate issue #120:

Not to impact judging,

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.

kirk-baird (judge) commented via duplicate issue #120:

@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.

ali2251 (Ondo) acknowledged


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.

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

  1. Admin calls burn on an account that is blocklisted, sanctioned, or not on the allow-list.
  2. The burn function calls _burnShares, which calls _beforeTokenTransfer with the account as 'from' and the zero address as 'to'.
  3. _beforeTokenTransfer sees that 'from' is not the zero address and checks if 'from' is blocked, sanctioned, or allowed.
  4. 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.

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.

More by 0xAsen

View all

17 more disclosed reports, best first.

More from Ondo Finance

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.