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.
Submitted by SmartSek, also found by csanuragjain and hansfriese
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!
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.