When using the approval mechanism in USDT, the approval must be set to 0 before it is updated. In Rubicon, when creating a pair, the paired asset’s approval is not set to 0 before it is updated.
Impact
Can’t create pairs with USDT, the most popular stablecoin, as the approval will revert.
Proof of Concept
USDT reverts on approval if previous allowance is not 0:
This doesn’t sound right to me because it implies that USDT is non-compliant with the infinite approval pattern. I believe USDT can be infinitely approved, asking for an extra pair of eyes to verify.
Just tested this on Rubicon trading and there is no need to re-approve USDT before using it so I believe this is a bad issue.
@bghughes This is not related to infinite approval (which USDT allows); you’re approving a specific amount. USDT on mainnet does not allow changing from a non-zero allowance to another non-zero allowance.
Did you test it on Optimism? USDT on optimism seems to use an updated version of USDT, unlike the one in mainnet. In Optimism you can change the approval from non-zero to another non-zero. But if you look at USDT on Ethereum mainnet, the code does not allow this (look at the second clause):
The issue is valid on approveAssetOnMarket() and approveMarket(), but not on the other lines. Even that, it’s likely for these functions to be called just once. Nevertheless, I will let the issue stand.
The reason is because the allowance will be entirely consumed when the deposit function is called, so it will be set to zero always.
desiredPairedAsset.approve(
pairedPool,
initialLiquidityExistingBathToken
);
// Deposit assets and send Bath Token shares to msg.sender
// This will use up the entire allowance given
IBathToken(pairedPool).deposit(
initialLiquidityExistingBathToken,
msg.sender
);
Hence, any issue that does not reference the approveAssetOnMarket() and approveMarket() functions will be marked as invalid.
Thank you for the explanation and thank you @HickupHH3.
The original report as published on Code4rena, by kenzo. 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.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
What is known
A medium-severity smart contracts bug in Rubicon v2. Code4rena made it public on 1 August 2022. Found in the 2022-05-rubicon audit contest (finding M-08).
About Smart contracts
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.