Skip to content
Access control Audit finding Intermediate

Access restrictions on NotionalV1ToNotionalV2.notionalCallback can be bypassed

The notionalCallback function's access control can be bypassed by passing sender as the contract's own address, allowing an attacker to steal tokens from any account that has approved the contract. An attacker can front-run a victim's migration transaction to withdraw the victim's funds and deposit them into their own account.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel, also found by pauliax

The NotionalV1ToNotionalV2.notionalCallback is supposed to only be called from the verified contract that calls this callback but the access restrictions can be circumvented by simply providing sender = this as sender is a parameter of the function that can be chosen by the attacker.

function notionalCallback(
    address sender,
    address account,
    bytes calldata callbackData
) external returns (uint256) {
    require(sender == address(this), "Unauthorized callback");

An attacker can call the function passing in an arbitrary account whose tokens can then be stolen. The account first has to approve this contract but this can happen with accounts that legitimately want to migrate their tokens and therefore have to send a first transaction to approve the contract, but then an attacker frontruns the actual migration transaction.

The attacker can steal the tokens by performing an attack similar to the following:

  • first transaction is used to withdraw the victim’s funds to the contract. This can be done by choosing account=victim, v1RepayAmount=0, v1CollateralId=WBTC, v2CollateralId=DAI. The NotionalV1Erc1155.batchOperationWithdraw (not part of this contest) will withdraw the victim’s funds to this contract. Note that the attacker has to deposit the same v2CollateralBalance = uint256(collateralBalance) for the victim into the V2 version, but they can choose different cheaper collateral (for example, withdraw WBTC, deposit same amount of DAI).
  • second transaction is now used to deposit the victim funds in the contract into the user’s account. They use account=attacker, v1DebtCurrencyId=WBTC, v1RepayAmount=amount to deposit it into Notional V1. (They need to have a small collateralBalance, etc. to pass all checks).

Recommend fixing the authorization check.

The original report as published on Code4rena, by cmichel. 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 authorization check relies on a user-supplied parameter (sender) that can be set to the contract's own address, instead of verifying the actual caller (msg.sender).

What the attacker needed

Victim has approved the contract; attacker can front-run transactions

The fix

The authorization check should be fixed to verify the actual caller (msg.sender) instead of a user-supplied parameter.

How it was found

  1. Wait for a victim to approve the contract for token migration.
  2. Front-run the victim's migration transaction by calling notionalCallback with sender set to the contract's address and account set to the victim.
  3. Use the first transaction to withdraw the victim's funds to the contract by choosing appropriate collateral IDs and zero repay amount.
  4. Use a second transaction to deposit the withdrawn funds into the attacker's account by calling notionalCallback with account set to the attacker.

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.

This contract has a function that is supposed to be callable only by the contract itself, but the check is flawed: it compares a parameter that the caller controls. So anyone can pretend to be the contract and trigger a transfer of someone else's tokens, as long as that person has already given the contract permission to spend their tokens.

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 cmichel

View all

196 more disclosed reports, best first.

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