Skip to content
Access control Audit finding Intermediate

NFT transfer approvals are not removed and cannot be revoked thus leading to loss of NFT tokens

NFT transfer approvals set to true are never cleared and cannot be revoked, so a delegate can transfer the NFT again if it returns to the vault or after the delegate becomes compromised.

0xRajeev Follow

Originally disclosed on Code4rena

Submitted by 0xRajeev, also found by shw

NFT transfer approvals that are set to true in approveTransferERC721() are never set to false and there is no way to remove such an nft approval.

Impact 1: The approval is not removed (set to false) after a transfer in transferERC721(). So if the NFT is ever moved back into the owner’s vault again, then the previous/compromised delegate can again transfer it to any address of choice without requiring a new approval.

Impact 2: If a delegate becomes compromised/untrustworthy after granting approval but before transfer then the owner will lose its NFT because there is no mechanism to revoke the approval that was granted earlier.

PoC-1:

  • Alice grants Eve approval to transfer a particular NFT out of its vault using approveTransferERC721()
  • Eve, who has transfer rights to that NFT from Alice’s vault, transfers that NFT to Bob using transferERC721()
  • Alice decides to buy back that NFT (e.g. because it is now considered rare and more valuable) from Bob and transfers it back to its vault
  • Eve, who continues to have transfer rights to that NFT from Alice’s vault, can steal that NFT and transfer to anyone

PoC-2:

  • Alice grants Eve approval to transfer a particular NFT out of its vault using approveTransferERC721()
  • Alice learns that Eve’s keys are compromises or that Eve is malicious and wants to revoke the approval but there is no mechanism to do so
  • Eve (or whoever stole her credentials) has transfer rights to that NFT from Alice’s vault and can steal that NFT and transfer to anyone

Recommend adding a boolean parameter to approveTransferERC721() and set the nftApprovals to that parameter which can be true for giving approval and false for removing/revoking approval If msg.sender != _getOwner(), call approveTransferERC721() with the boolean false to remove approval before making a transfer in transferERC721() on L515.

xyz-ctrl (Visor) commented:

duplicate https://github.com/code-423n4/2021-05-visorfinance-findings/issues/35

ghoul-sol (Judge) commented:

The original report as published on Code4rena, by 0xRajeev. 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

Likely the approval mapping is only ever set to true and there is no function or logic to set it back to false, including after a transfer.

Impact

A previously approved or compromised delegate can transfer the NFT out of the vault without a new approval, leading to loss of the NFT.

What the attacker needed

Owner grants approval to a delegate; delegate becomes malicious or compromised; or NFT returns to the vault after transfer

The fix

The approval function should accept a boolean to set or clear approval, and a transfer by someone other than the owner should clear the approval first.

How it was found

  1. Alice grants Eve approval to transfer a particular NFT out of its vault using approveTransferERC721()
  2. Eve transfers that NFT to Bob using transferERC721()
  3. Alice buys back the NFT from Bob and transfers it back to its vault
  4. Eve, who still has transfer rights, can steal that NFT and transfer it to anyone

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.

An approval lets someone else move your NFT out of a vault. This code never removes that permission, even after the NFT is transferred, and the owner has no way to cancel it. So if the NFT comes back, or the approved person turns bad, they can still take it.

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 0xRajeev

View all

61 more disclosed reports, best first.

More from Visor Finance

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.