Skip to content
Access control Audit finding Intermediate

_validateCommitment fails for approved operators

The _validateCommitment function only checks if the caller is the token owner or an approved operator for a specific token, but not if they are an operator for all tokens. An attacker who is an approved operator for all tokens would be incorrectly rejected from taking actions with those tokens.

rvierdiiev Follow with obront

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/52

Found by

rvierdiiev, obront

Summary

If a collateral token owner approves another user as an operator for all their tokens (rather than just for a given token), the validation check in _validateCommitment() will fail.

Vulnerability Detail

The collateral token is implemented as an ERC721, which has two ways to approve another user:

  • Approve them to take actions with a given token (approve())
  • Approve them as an "operator" for all your owned tokens (setApprovalForAll())

However, when the _validateCommitment() function checks that the token is owned or approved by msg.sender, it does not accept those who are set as operators.

Solidity
if (msg.sender != holder) {
  require(msg.sender == operator, "invalid request");
}

Impact

Approved operators of collateral tokens will be rejected from taking actions with those tokens.

Code Snippet

https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/VaultImplementation.sol#L152-L158

Tool used

Manual Review

Recommendation

Include an additional check to confirm whether the msg.sender is approved as an operator on the token:

Solidity
    address holder = ERC721(COLLATERAL_TOKEN()).ownerOf(collateralId);
    address approved = ERC721(COLLATERAL_TOKEN()).getApproved(collateralId);
    address operator = ERC721(COLLATERAL_TOKEN()).isApprovedForAll(holder);

    if (msg.sender != holder) {
      require(msg.sender == operator || msg.sender == approved, "invalid request");
    }

The original report as published on Sherlock, by rvierdiiev. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 code only checks for per-token approval and not for operator approval (setApprovalForAll).

Impact

Approved operators of collateral tokens will be rejected from taking actions with those tokens.

What the attacker needed

Caller is an approved operator for all tokens

The fix

The function should also check if the caller is an approved operator for all tokens using isApprovedForAll.

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 this smart contract, a function checks who is allowed to use a token. It only allows the owner or someone approved for that specific token, but not someone approved for all tokens. So a user who should have permission is wrongly blocked.

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 rvierdiiev

View all

72 more disclosed reports, best first.

More from Astaria

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.