Dria

Swan
NFTHardhat
21,000 USDC
View results
Submission Details
Severity: high
Invalid

Ensuring compatibility with PAX/BUSD by resetting allowances before increasing allowances.

Summary

In the _increaseAllowance function of the LLMOracleCoordinator, LLMOracleRegistry contract, tokens like **PAX **and **BUSD **require the current allowance to be reset to 0 before setting a new allowance. Without this reset, the function call to increase the allowance can fail, preventing the correct approval of additional tokens for use. This issue specifically impacts tokens with custom implementations of the ERC-20 standard.

Vulnerability Details

For tokens such as **PAX **and BUSD, which implement a stricter approve mechanism, an attempt to increase the allowance directly (without first resetting it to 0) will fail. The current code in the _increaseAllowance function tries to increase the allowance without accounting for this, resulting in potential transaction failures when using these tokens.

feeToken.approve(spender, feeToken.allowance(address(this), spender) + amount);

For **PAX **and **BUSD **, this method fails if there is already a non-zero allowance.

https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/llm/LLMOracleRegistry.sol#L130
https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/llm/LLMOracleCoordinator.sol#L397

Impact

  • Transaction Failures: The allowance cannot be increased directly without resetting it to 0, leading to failed transactions for **PAX **and **BUSD **tokens.

  • Inability to Use Tokens: This prevents the proper use of these tokens within the contract, potentially blocking key functions that depend on token transfers.

Tools Used

  • Understanding of the specific behavior of **PAX **and **BUSD **token contracts and their approval mechanisms.

Recommendations

Modify the _increaseAllowance function to handle tokens like **PAX **and **BUSD **by first resetting the allowance to 0 before increasing it:

function _increaseAllowance(address spender, uint256 amount) internal {
- feeToken.approve(spender, feeToken.allowance(address(this), spender) + amount);
+ uint256 currentAllowance = feeToken.allowance(address(this), spender);
+ // If allowance is non-zero, reset to 0 first
+ if (currentAllowance > 0) {
+ feeToken.approve(spender, 0);
+ }
+ // Now set the new allowance
+ feeToken.approve(spender, currentAllowance + amount);
}

This update ensures compatibility with **PAX **and **BUSD **, preventing failures when working with these tokens.

Updates

Lead Judging Commences

inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.