-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CatalystVault LPs can be drained by deployer on whitelisted Vault #40
Comments
Hope my explanation will be sufficient as I wanted to send this in as fast as possible. The root of the problem is that arbitrary tokens will always be dangerous. I will think about how to best mitigate this while still retaining vault flexibility. |
In the tests case |
Regarding the fake token, the attacker can also do various tricks to make it more convincing: one of them is to mimick the real token's balances: he monitors the approvals to his own vault and sends the fake tokens to potential users and LPs (e.g. LP has 4 WETH, whenever LP approves other assets to the vault, attacker will immediately send 4 fakeWETH to the LP), but he doesn't need to do this if the LP only supplies the other real assets. |
RecommendationsThis would reduce flexibility, but enhance safety: Consider distinguishing between safe and custom vaults on the contract level and disallow custom vault usage until an authorized actor allows it, one way to do that is to have a whitelisted array of tokens that are considered safe along with the whitelisted vaultTemplates and the chainInterfaces. If it matches the safety checks, the vault can be used immediately, if not the vault has to be approved by the factory owner before regular users can use it. Another similar but easier solution is to only allow whitelisted array of tokens to be used as To minimize potential damage, |
When deploying a vault, the factory will tell third parties which tokens it contains: Lines 7 to 23 in fba322f
As such, Alice will know that the vault contains a token she may not expect. This is similar to #12. We do not want to impose any kind of whitelisting or filtering on: Vault Templates, Cross-chain interfaces, or assets. What we can do is filter on the front-end. Token filtering is already common place with https://tokenlists.org and I have also seen Uniswap check to see if a token tries to match another token on the list and then display an additional warning. As such, these are not on-chain implementation concerns. Also not in the scope of the audit is any token. You could create a token say |
Regarding exotic tokens, it is a very fine balance. We want to support mainstream tokens so if you can make the contract behave in unexpected ways with any of these, it might be a valid issue. Might because if you create an ERC20 just for the occasion it is not going to count. See these 2 issues on weird ERC20s for more details: #10 and #29 |
The potential weight difference is an issue in itself, as it can be used to drain the vault via normal |
Got it!
As an auditor focused on the smart contract scope, I didn't have pre knowledge of the extent of front-end filtering, so I didn't have an assumption that tokens were filtered, but will keep in mind!
Usually if an arbitrary token input is in the codebase, it's in scope, but understand it's not a concern here, I will keep this in mind going forward and focus on mainstream / real tokens. |
I mean yes but would you say the same to a Uniswap pool, Balancer pool, or Curve pool? Yes they support any tokens but often they have to implement custom logic in case of fee on transfer, rebasing, or other exotic tokens. We don't mention supporting these borderline tokens anywhere. |
Github username: @0xfuje
Twitter username: 0xfuje
Submission hash (on-chain): 0xe27a0162b2ac6c5ea56983c04cb14a87c28b1576afefc4a3602c538762638b3e
Severity: high
Description:
Impact
Total loss of LP deposited funds of Vault
Description
fakeWETH
and fully controls the token's supplyVault
from the whitelisted templates with popular tokens such asUSDC
,USDT
, but one of the token is their own token that mimicks a popular token (e.g.WETH
), sends normal ($1000) amount ofUSDC
,USDT
to the pool to seem trustworthy for LPSUSDC
,USDT
USDC
andUSDT
localSwap()
to the valid tokens via either minting unbounded amount of tokens, (or via setting unbounded high weight at deployment)Proof of Concept
In this example the attacker abuses setting the weight of their malicious token to high amounts and the total supply to very low, but it's not necessary since he controls the whole supply of their arbitrary token, so he can mint up to the amount that needs to drain the pool.
test/ExampleTest.t.sol
forge test --match-test --via-ir test_localswap_exploit_token -vvvv
Note: Recommendations will be added soon
The text was updated successfully, but these errors were encountered: