Skip to content
Business logic Audit finding Beginner

Missing whenNotPaused modifier

Two functions in StableSwapFacet, swapExactOut and addSwapLiquidity, lack the whenNotPaused modifier that other swap functions have. An attacker could still swap or add liquidity while the contract is paused, defeating the emergency stop.

SmartSek Follow

Originally disclosed on Code4rena

Submitted by SmartSek, also found by csanuragjain and hansfriese

StableSwapFacet.sol#L279-L286

In StableSwapFacet.sol, two swapping functions contain the whenNotPaused modifier while swapExactOut() and addSwapLiquidity() do not. All functions to swap and add liquidity should contain the same modifiers to stop transactions while paused.

Proof of Concept

Example with modifier

  function swapExact(
    bytes32 canonicalId,
    uint256 amountIn,
    address assetIn,
    address assetOut,
    uint256 minAmountOut,
    uint256 deadline
  ) external payable nonReentrant deadlineCheck(deadline) whenNotPaused returns (uint256) {

Examples without modifier

  function swapExactOut(
    bytes32 canonicalId,
    uint256 amountOut,
    address assetIn,
    address assetOut,
    uint256 maxAmountIn,
    uint256 deadline
  ) external payable nonReentrant deadlineCheck(deadline) returns (uint256) {

and

  function addSwapLiquidity(
    bytes32 canonicalId,
    uint256[] calldata amounts,
    uint256 minToMint,
    uint256 deadline
  ) external nonReentrant deadlineCheck(deadline) returns (uint256) {
    return s.swapStorages[canonicalId].addLiquidity(amounts, minToMint);
  }

Recommended Mitigation Steps

Add the whenNotPaused modifier to all functions that perform swaps or liquidity additions.

jakekidd (Connext) confirmed and resolved:

Resolved by: connext/nxtp@1dd5559

0xleastwood (judge) commented:

I think this makes sense to add!


The original report as published on Code4rena, by SmartSek. 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 developers forgot to add the whenNotPaused modifier to two functions that perform swaps or add liquidity.

What the attacker needed

Contract is paused; attacker can call the functions

The fix

The issue was fixed by adding the whenNotPaused modifier to all functions that perform swaps or liquidity additions.

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 smart contract can have a pause switch to stop trading in an emergency. Some functions check that switch before running, but two functions here do not. That means someone could still trade or add money even when the contract is supposed to be paused.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by SmartSek

View all

2 more disclosed reports, best first.

More from Connext Amarok contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.