When the approval to the okxapprover is not fully spent the deposit function will be blocked
The contract approves the okxApprover for the full deposit amount using safeApprove, which reverts when a non-zero allowance already exists. If a swap consumes less than the approved amount, the leftover allowance blocks all later deposits for that token.
- Disclosed after under an hour
52974 sc medium when the approval to the okxapprover is not fully spent the deposit function will be blocked
Submitted on Aug 14th 2025 at 14:31:34 UTC by @TeamJosh for Attackathon | Plume Network
- Report ID: #52974
- Report Type: Smart Contract
- Report severity: Medium
- Target: https://github.com/immunefi-team/attackathon-plume-network-nucleus-boring-vault/blob/main/src/helper/DexAggregatorWrapperWithPredicateProxy.sol
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
- Unbounded gas consumption
- Smart Contract Unable to operate but not due to lack of funds
Description
Brief / Intro
The DexAggregatorWrapperWithPredicateProxy.sol dangerously uses safeApprove on the okxApprover without resetting the approval to zero. safeApprove reverts if the current allowance is not zero.
Vulnerability Details
When the okxApprover uses fewer funds than what it was approved for, the deposit functions will be blocked for everyone.
Look at the _okxHelper function. This function is called by the depositOkxUniversal and depositAndBridgeOkxUniversal functions. First, it approves the okxApprover to spend the depositAsset using safeApprove, then it calls the okxApprover (via okxRouter) to swap the tokens. If the okxApprover fails to use the whole allowance, the transaction will go through, leaving the contract with some residual approval for that token. Subsequent transactions that call safeApprove to set a new non-zero allowance will revert because safeApprove requires address(0) -> new amount pattern (or first zero the allowance).
Relevant snippet:
function _okxHelper(
ERC20 supportedAsset,
address teller,
address fromToken,
uint256 fromTokenAmount,
bytes calldata okxCallData,
uint256 nativeValueToWrap
)
internal
returns (uint256 supportedAssetAmount)
{
...
// Use safeTransferFrom
depositAsset.safeTransferFrom(msg.sender, address(this), fromTokenAmount);
// Use standard approve (as requested) for the OKX approver
@-> depositAsset.safeApprove(okxApprover, fromTokenAmount);
}
// Execute the swap with the provided calldata
@-> (bool success, bytes memory result) = address(okxRouter).call(okxCallData);
if (!success) {
assembly {
revert(add(result, 32), mload(result))
}
}
...
}
Impact Details
The okxApprover will be permanently blocked from using the DexAggregatorWrapperWithPredicateProxy.sol (for that token) if residual allowances remain. This also affects integrations such as the 1inch aggregator that rely on similar approval flows.
Proof of Concept
<details> <summary>Proof of Concept (step-by-step)</summary>StepBob, a malicious attacker, wants to block users from depositing USDC with Okx.StepBob calls depositAndBridgeOkxUniversal and supplies a fromTokenAmount that is greater than the actual amount the okxCallData will cause the okxApprover to swap.StepInside _okxHelper, the contract executes:depositAsset.safeTransferFrom(msg.sender, address(this), fromTokenAmount);depositAsset.safeApprove(okxApprover, fromTokenAmount);The okxApprover performs the swap but uses less than the approved allowance, leaving a residual allowance.StepAfter this, another user (Alice) attempts to deposit. Her transaction calls safeApprove(okxApprover, amount) again; since the current allowance is non-zero, safeApprove reverts and the deposit is blocked.
</details>Remediation (suggested approach)
- When setting approvals for a third-party router/approver that may use a subset of the allowance, first set allowance to zero before setting the desired non-zero allowance, or adopt an approve-if-zero pattern or use increaseAllowance / decreaseAllowance where appropriate.
- Alternatively, use an approval pattern that sets an effectively infinite allowance once (and relies on trusted approver behavior), or use pull-based transfers when possible.
- Ensure callers sanitize
fromTokenAmountvs calldata amounts, or validate the expected spend fromokxCallDatato avoid over-approving.
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 code calls safeApprove with a non-zero amount without first resetting the existing allowance to zero, so any residual allowance makes later approvals revert.
Impact
Deposits for the affected token could be permanently blocked for everyone, including integrations relying on similar approval flows, though no funds are lost.
What the attacker needed
Attacker can call the deposit function; swap spends less than approved amount
The fix
The approval should be reset to zero before setting a new non-zero allowance, or an approve-if-zero or increase/decrease allowance pattern should be used.
How it was found
- An attacker calls the deposit-and-bridge function with a fromTokenAmount larger than what the swap calldata will actually spend.
- The helper transfers the tokens in and approves the okxApprover for that larger amount.
- The swap runs but spends less than approved, leaving a residual allowance.
- A later user tries to deposit and the new safeApprove call reverts because the allowance is non-zero, blocking deposits.
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 contract can let another contract spend its tokens by granting an 'allowance'. This code uses a helper that refuses to set a new allowance unless the old one is exactly zero. If a swap spends only part of the allowance, the leftover amount stays, and every later deposit fails because the helper keeps refusing to overwrite it.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.