Vulnerability Patch: Technical Details and Steps Forward

TL;DR The Minswap Team was notified of a critical vulnerability that would allow someone to drain all the Liquidity in the Smart Contract. After putting safeguards in place to prevent this, the Team used this same vulnerability to migrate all Liquidity for all users to a new, secured, contract with a patch. All positions, including Liquidity Provision and Staking, remain intact for users. The boost for those staking MIN/ADA with the LBE NFT has been extended 2 days. We explain in detail and further steps forward below.

After having open sourced our Smart Contract and Audit Report, on March 22nd, we were alerted to a critical vulnerability in our contracts. Upon learning of it, we confirmed the vulnerability and successfully reproduced it on the private testnet. As a result, and given that currently the batching on our DEX is done by the Minswap Team, we decided to immediately censor all orders to prevent this vulnerability from being exploited, and start focusing on a solution.

At the time of writing, the vulnerability has been patched and all funds are safe. All users retain their positions from before we went into maintenance mode, including staked LP Tokens in Farms and accumulation of MIN rewards during that time for doing so. In addition, as we announced earlier, the NFT Boost for those providing Liquidity in the MIN/ADA pair will be extended 2 days until the 25th of March 07:00 AM UTC. LP Tokens are being airdropped to users based on a snapshot, and over 40% of LP Tokens have been migrated as of now. Please follow our Twitter for further announcements regarding the migration and opening of trading.

Below, we explain in more detail the vulnerability, and our steps forward. We understand and take seriously the responsibility to explain as thoroughly and transparently as we can, especially since the Cardano DeFi ecosystem is still in its infancy.

Vulnerability Explanation

The critical vulnerability consisted of the possibility to mint duplicated pool NFT tokens and use those NFT tokens to mint infinite LP tokens of any pool. After putting the appropriate safeguards in place for this attack to be impossible to be executed, we found the best solution to be to write a new Smart Contract that patched this vulnerability, and use that same vulnerability to migrate all the funds to the new Smart Contract, so all users would retain their positions. So, in order to conduct the migration, we used the exploit ourselves to drain all liquidity, then create liquidity pools on the new contract and airdrop new LP tokens back to users based on a snapshot we had taken of their prior positions.

We feel it is important to clarify that the Minswap Team cannot migrate liquidity at its own will from one Smart Contract to another. Liquidity was migrated to a new Smart Contract because a vulnerability was discovered that would allow this to happen, and it was migrated precisely to avoid this exploit from happening. So, in a bizarre but fortunate turn of events, the vulnerability and exploiting it made it possible to migrate funds into the new, upgraded contract where this vector was patched. Sadly, neither we nor our auditors noticed this bug before implementing the Smart Contract, so migrating the liquidity was the only solution. Now that the fix has been implemented, it is no longer possible for the Minswap Team to unilaterally move liquidity.

During the security upgrade, we were notified of three additional, less severe vulnerabilities that could lead to misuses by the batcher or owner (aka admin) agents regarding pool parameters and datum manipulation. We have addressed them as well. Although batchers are trusted agents, we believe making the batching process as trustless as possible and removing these vulnerabilities will help moving to a more trustless context in an appropriate way, in turn increasing infrastructure security.

Resolution Plan

While we were able to update our Smart Contracts to fix the vulnerability, we’re implementing additional security measures moving forward to provide additional protections for user funds. For added security, we have decided to temporarily make new pool creation permissioned. This is undesired in terms of decentralization, but it helps us to make sure pool creation is well-formatted, avoid duplicated pools by accident or malice, and gives more safety control if a vulnerability discovery were to happen again. In Minswap DEX v2, with the help of upcoming hard-forks and ledger updates, we are going to move into a more decentralized and trustless model. We’ll be releasing our formal process for pool creation in the coming week.

In an effort to strengthen security, we are immediately entering a continuous audit and code review process with a new top Haskell security firm. The change to the code that was implemented for our new contracts was small without any known dependencies. Given the lack of experience any firm has conducting audits on production grade Plutus dApps, we feel this process is appropriate moving forward.

It is fortunate that the issue was discovered promptly and no funds were lost during the process. We are building in a very young ecosystem and there aren’t yet many security best practices and tooling for developers or auditors. We strongly believe events such as these make Minswap and the Cardano ecosystem stronger and more resilient moving forward. We’re also deeply grateful for the support and patience of our community as we learn, build, and grow together.

Additional Analysis

In the coming weeks the Minswap Team will publish an additional in-depth article further explaining the security vulnerabilities discovered. We plan on holding an AMA along with other community engagement sessions to answer questions, address concerns, and provide additional clarity. The team is currently working tirelessly with complete focus on relaunching the DEX in an upgraded and secure form.

Open-source

While the open-sourcing of our contracts exposed a vulnerability, we believe that the long-term benefits of open-source development outweigh potential risks. Growing and strengthening Cardano’s technical community, the scalability of decentralized solutions, and accessibility for future builders to deploy innovative applications are all benefits of an open ecosystem.

Moving forward, Minswap will release its new contracts in the near future once specific processes and benchmarking is complete.

Acknowledgement

We would like to thank the WingRiders Team for their help and notifying us of these vulnerabilities. The WingRiders team have been compensated with a bug bounty from the DAO treasury, as is standard in such situations.

--

--

--

Minswap is the multi-pool decentralized exchange on the Cardano blockchain: https://minswap.org

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Minswap Labs

Minswap Labs

Minswap is the multi-pool decentralized exchange on the Cardano blockchain: https://minswap.org

More from Medium

Announcing MIN Yield Farms

anetaBTC — ErgoDEX Listing

Maestro — World’s 1st ISPO platform

Liquidity Makes Trading Possible, Efficient Liquidity Makes Trading Easy