HolographERC721.approve not EIP-721 compliant
The approve function in HolographERC721 allows an approved address to approve another address, which violates EIP-721. An attacker who is approved for a token could approve a malicious address and steal the token.
Submitted by Lambda
According to EIP-721, we have for approve:
/// Throws unless `msg.sender` is the current NFT owner, or an authorized
/// operator of the current owner.
An operator in the context of EIP-721 is someone who was approved via setApprovalForAll:
/// @notice Enable or disable approval for a third party ("operator") to manage
/// all of `msg.sender`'s assets
/// @dev Emits the ApprovalForAll event. The contract MUST allow
/// multiple operators per owner.
/// @param _operator Address to add to the set of authorized operators
/// @param _approved True if the operator is approved, false to revoke approval
function setApprovalForAll(address _operator, bool _approved) external;
Besides operators, there are also approved addresses for a token (for which approve is used). However, approved addresses can only transfer the token, see for instance the safeTransferFrom description:
/// @dev Throws unless `msg.sender` is the current owner, an authorized
/// operator, or the approved address for this NFT.
HolographERC721 does not distinguish between authorized operators and approved addresses when it comes to the approve function. Because _isApproved(msg.sender, tokenId) is used there, an approved address can approve another address, which is a violation of the EIP (only authorized operators should be able to do so).
Proof Of Concept
Bob calls approve to approve Alice on token ID 42 (that is owned by Bob). One week later, Bob sees that a malicious address was approved for his token ID 42 (e.g., because Alice got phished) and stole his token. Bob wonders how this is possible, because Alice should not have the permission to approve other addresses. However, becaue HolographERC721 did not follow EIP-721, it was possible.
Recommended Mitigation Steps
Follow the EIP, i.e. do not allow approved addresses to approve other addresses.
alexanderattar (Holograph) commented:
Originally, this was a design decision, but we will update the highlighted code to follow the ERC721 spec to avoid unknown consequences.
Consider as duplicate of
#203
@gzeon - Isn’t this a different issue than
#203? Both are related to ERC721 compliance, but they have different causes (wrongsafeTransferFromvs. wrongapprove), very different impacts (failing transfers vs. unintended permissions), and the sponsor will implement different fixes for them (that for instance would not make sense to review together in a fix review)
@Lambda - Fair.
ACC01ADE (Holograph) linked a PR:
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 uses _isApproved(msg.sender, tokenId), which checks both operators and approved addresses, instead of only allowing operators.
Impact
An approved address could approve a malicious address, leading to token theft if the approved address is compromised.
What the attacker needed
Victim has approved an address; approved address is compromised
The fix
The contract was updated to follow the ERC721 spec, so approved addresses can no longer approve other addresses.
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.
In NFT contracts, the owner can approve someone to transfer a specific token. That approved person should only be able to transfer the token, not approve others. Here, the contract mistakenly let the approved person approve someone else, so a phished approved address could hand control to an attacker.
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.