Skip to content
Access control Audit finding Intermediate

KUMABondToken.approve() should revert if the owner of the tokenId is blacklisted

The KUMABondToken.approve() function only checks if the caller and the approved address are not blacklisted, but does not check if the owner of the tokenId is blacklisted. This allows an operator to approve a blacklisted user's bond token, even though transfers would still be blocked.

hihen Follow with 0xsomeone

Originally disclosed on Code4rena

Submitted by hihen, also found by 0xsomeone

It is still possible for a blacklisted user’s bond token to be approved.

Proof of Concept

KUMABondToken.approve() only checks if msg.sender and to are not blacklisted. It doesn’t check if the owner of the tokenId is not blacklisted.

For example, the following scenario allows a blacklisted user’s bond token to be approved:

  1. User A have a bond token bt1.
  2. User A calls KUMABondToken.setApprovalForAll(B, true), and user B can operate on all user A’s bond tokens.
  3. User A is blacklisted.
  4. User B calls KUMABondToken.approve(C, bt1) to approve user C to operate on bond token bt1.

Tools Used

VS Code

Recommended Mitigation Steps

KUMABondToken.approve() should revert if the owner of the tokenId is blacklisted:

diff --git a/src/mcag-contracts/KUMABondToken.sol b/src/mcag-contracts/KUMABondToken.sol
index 569a042..906fe7b 100644
--- a/src/mcag-contracts/KUMABondToken.sol
+++ b/src/mcag-contracts/KUMABondToken.sol
@@ -146,6 +146,7 @@ contract KUMABondToken is ERC721, Pausable, IKUMABondToken {
         whenNotPaused
         notBlacklisted(to)
         notBlacklisted(msg.sender)
+        notBlacklisted(ERC721.ownerOf(tokenId))
     {
         address owner = ERC721.ownerOf(tokenId);

Alex the Entreprenerd (judge) commented:

The Warden has shown an inconsistency in implementation for the blacklist functionality.

Because a transfer would still be broken, due to transferFrom performing a check on all accounts involved, I agree with Medium Severity.

m19 (KUMA) confirmed and commented:

We confirmed this issue in a test and intend to fix it:

    function test_approve_RevertWhen_TokenOwnerBlacklistedAndApproveCalledByOperator() external {
        _kumaBondToken.issueBond(_alice, _bond);
        vm.prank(_alice);
        _kumaBondToken.setApprovalForAll(address(this), true);
        _blacklist.blacklist(_alice);
        vm.expectRevert(abi.encodeWithSelector(Errors.BLACKLIST_ACCOUNT_IS_BLACKLISTED.selector, _alice));
        _kumaBondToken.approve(_bob, 1);
    }

m19 (KUMA) mitigated:

https://github.com/code-423n4/2023-02-kuma/pull/4

Status: Mitigation confirmed by 0xsomeone, 0x52, and hihen.


The original report as published on Code4rena, by hihen. 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 approve function checks the caller and the approved address against the blacklist but omits a check on the token owner.

Impact

A blacklisted user's bond token could be approved, though a transfer would still be blocked because transferFrom checks all accounts involved.

What the attacker needed

Blacklisted token owner; operator approved via setApprovalForAll

How it was found

  1. User A owns a bond token.
  2. User A calls setApprovalForAll to let user B operate on all their bond tokens.
  3. User A is blacklisted.
  4. User B calls approve to let user C operate on the bond token.

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 meant to stop certain users from doing things with their tokens. Here, a user who was blacklisted could still have their token approved for someone else to use, because the approval function forgot to check the token owner. This is a gap in the rules, not a way to steal funds directly.

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.

More by hihen

View all

10 more disclosed reports, best first.

More from KUMA Protocol - Versus contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.