Skip to content
Access control Audit finding Intermediate

CollateralToken should allow to execute token owner’s action to approved addresses

The collateral token contract restricted certain owner-only actions, such as starting a flash action or releasing funds, to the token owner and ignored addresses the owner had approved. An approved operator therefore could not perform actions the owner had authorised it to carry out, and the authority check in the vault commitment validation also omitted the approved operator as a valid caller.

ladboy233 Follow

Originally disclosed on Code4rena

Submitted by ladboy233

https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/CollateralToken.sol#L274 https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/CollateralToken.sol#L266 https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/VaultImplementation.sol#L238

Let us look into the code below in VaultImplementation#_validateCommitment

function _validateCommitment(
IAstariaRouter.Commitment calldata params,
address receiver
) internal view {
uint256 collateralId = params.tokenContract.computeId(params.tokenId);
ERC721 CT = ERC721(address(COLLATERAL_TOKEN()));
address holder = CT.ownerOf(collateralId);
address operator = CT.getApproved(collateralId);
if (
  msg.sender != holder &&
  receiver != holder &&
  receiver != operator &&
  !CT.isApprovedForAll(holder, msg.sender)
) {
  revert InvalidRequest(InvalidRequestReason.NO_AUTHORITY);
}

the code check should also check that msg.sender != operator to make the check complete, if the msg.sender comes from an approved operator, the call should be valid.

if (
  msg.sender != holder &&
  receiver != holder &&
  receiver != operator &&
  msg.sender != operator &&
  !CT.isApprovedForAll(holder, msg.sender)
) {
  revert InvalidRequest(InvalidRequestReason.NO_AUTHORITY);
}

AND

CollateralToken functions flashAction, releaseToAddress are restricted to the owner of token only. But they should be allowed for approved addresses as well.

For example, in flashAuction, only the owner of the collateral token can start the flashAction, then approved operator by owner cannot start flashAction.

  function flashAction(
    IFlashAction receiver,
    uint256 collateralId,
    bytes calldata data
  ) external onlyOwner(collateralId) {

Note the check onlyOwner(collateralId) does not check if the msg.sender is an approved operator.

modifier onlyOwner(uint256 collateralId) {
	require(ownerOf(collateralId) == msg.sender);
	_;
}

Recommended Mitigation Steps

Add ability for approved operators to call functions that can be called by the collateral token owner.

SantiagoGregory (Astaria) confirmed


The original report as published on Code4rena, by ladboy233. 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 authority checks compare the caller only against the token owner and the approved operator in some branches, but omit the approved operator as a valid caller in the commitment validation and in the owner-only modifier used by flashAction and releaseToAddress.

Impact

Approved operators could not exercise the permissions the token owner had granted them, so legitimate delegated actions such as starting a flash action would revert; the text does not describe any theft or loss of funds.

What the attacker needed

Caller is an approved operator, not the owner

The fix

The authority checks should be extended so that an approved operator is accepted wherever the token owner is accepted, including in the commitment validation and the owner-only modifier.

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 token owner can approve another address to act on their behalf, much like giving someone a key to your flat. Here the contract only checked for the owner's own address in several places, so the approved helper was turned away even though the owner had allowed it. The report asks for those checks to also accept the approved address.

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 ladboy233

View all

47 more disclosed reports, best first.

More from Astaria 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.