Skip to content
Access control Audit finding Intermediate

Approved operators of Position token can’t call Trading.initiateCloseOrder

The contract's owner check compared the position token's owner directly to the caller, so addresses approved as operators on that token could not pass it. As a result, approved operators were unable to call functions such as initiateCloseOrder on behalf of the owner.

rvierdiiev Follow with __141345__ and UniversalCrypto

Originally disclosed on Code4rena

Submitted by rvierdiiev, also found by 141345 and UniversalCrypto

https://github.com/code-423n4/2022-12-tigris/blob/main/contracts/Trading.sol#L235

https://github.com/code-423n4/2022-12-tigris/blob/main/contracts/Trading.sol#L847-L849

Impact

Approved operators of owner of Position token can’t call several function in Trading.

Proof of Concept

Functions that accept Position token in Trading are checking that the caller is owner of token using \_checkOwner function.

https://github.com/code-423n4/2022-12-tigris/blob/main/contracts/Trading.sol#L847-L849

    function _checkOwner(uint _id, address _trader) internal view {
        if (position.ownerOf(_id) != _trader) revert("2"); //NotPositionOwner
    }

As you can see this function doesn’t allow approved operators of token’s owner to pass the check. As a resul, functions are not possible to call for them on behalf of owner.

For example here, there is a check that doesn’t allow to call initiateCloseOrder function.

Tools Used

VS Code

Recommended Mitigation Steps

Allow operators of token’s owner to call functions on behalf of owner.

Alex the Entreprenerd (judge) commented:

The warden has shown how, due to an inconsistency between the check and the permissions, some functions will not work for an approved operator.

Because some functions will, and the system seems to be written with the intention of allowing that functionality, I believe Medium Severity to be the most appropriate.

GainsGoblin (Tigris Trade) acknowledged and commented:

@Alex the Entreprenerd We want to keep _checkOwner() the way it is currently implemented. For approving another address for trading on behalf of the user’s address, we have the approveProxy() function.


The original report as published on Code4rena, by rvierdiiev. 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 owner check compared the position token's owner directly with the caller instead of also accepting addresses approved as operators for that token.

Impact

Approved operators could not call several Trading functions, including initiateCloseOrder, on behalf of the position owner; the project said it intends to keep the check and expects users to use a separate approveProxy function instead.

What the attacker needed

Position token owner approves an operator; operator calls a Trading function

The fix

The project chose not to change the check and said operators should instead be granted trading rights through the approveProxy function.

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 position is represented by a token, and the token's owner can approve another address to act for them. The contract only checked whether the caller was the owner itself, not whether they were an approved operator, so the approved address was rejected. This is a permissions bug: the code's check was stricter than the token's own rules.

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 Tigris Trade 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.