Maximizing security: How to deal with MEV attacks in DeFi
Hash of this article (SHA 1): b366289db9b21c3e9b6668c274e4a179be57a463
No.: Lianyuan Security Knowledge No.008
In the past few years, the blockchain economy has experienced exponential growth, especially in 2022, when the locked value of the DeFi ecosystem reached a peak of $300 billion. Web3 has also seen a variety of attack methods and logical security vulnerabilities. Since 2017, the Maximum Extractable Value (MEV) has been at the forefront of the attack methods that cause losses on the ETH chain. The ChainSource Security Team has conducted relevant analysis and sorting on the basic principles and protection methods of MEV, hoping to help readers improve their protection. The ability to ensure the safety of ones own assets.
MEV Basic Principles
MEV, the full name of which is Maximum Extractable Value, was also called Miner Extractable Value in the POW era of Ethereum. After a large number of blockchains switched to POS, it was renamed Maximum Extractable Value. Because block producers are no longer the only ones who decide the order of transactions (currently, the two roles with these two permissions are miners and validators, but previously there were only miners).
MEV refers to a measure of the profit that participants such as validators or sequencers obtain by performing selective operations on transactions (including transactions, sorting transactions, and reordering transactions) within the blocks they produce.
Validators: Participants responsible for validating transactions and producing blocks;
Sequencer: The participant responsible for deciding the order of transactions;
Include transactions: select which transactions will be included in the block;
Exclude transactions: select which transactions will not be included in the block;
Reorder transactions: determine the order of transactions in a block;
Currently, hackers using MEV mainly target wallet addresses that have obtained airdrop snapshot qualifications and whose pledged tokens are about to be unlocked. The prerequisite for hackers to launch such attacks is to obtain the wallet private key, then turn on dynamic Gas monitoring, and wait for the users After the tokens or gas fees are received, a withdrawal transaction is sent in the same block or adjacent blocks, which is called a front-running transaction. We call this type of monitoring robot a Sweeper robot.
Protection methods (taking ETH as an example)
First of all, there are two ideas for this type of protection. Since the goal is to compete with hackers in terms of speed, the first approach is to increase the Gas price and the Nonce of transaction sorting.
Because Ethereums transaction fee = Gas (quantity) * Gas Price (unit price), and the Gas Limit capacity of each Ethereum block is fixed, whoever has a higher Gas Price will have their transaction packaged into the block first. Block confirmation, in addition, nonce in Ethereum represents the number of transactions. This concept should be combined with the fact that Ethereum itself is account-based, so each different account maintains its own nonce, and each transaction of each account in Ethereum Each transaction has a unique nonce, which can prevent replay attacks (the same transaction is processed multiple times) and allow the EVM virtual machine to clarify the order of transactions (for example, if the nonce of a transaction is 5, then in this transaction Before the transaction can be processed, the transaction with nonce 4 in the account must have been processed)
The second idea is to connect to nodes with faster confirmation speed and higher transaction obfuscation
If you want to change the connection node, the first recommended one is the TAICHI network node. This network is a privacy and security solution based on blockchains such as ETH and Solana. It achieves transaction obfuscation and privacy protection by introducing a series of relay nodes. The node is responsible for receiving the users transaction request and mixing it with other transactions to hide the source and purpose of the transaction.
Relay nodes: These nodes are the core of the TAICHI network and are responsible for receiving, mixing, and forwarding transactions;
Transaction mixing: By mixing multiple transactions together, relay nodes are able to effectively hide the source and purpose of individual transactions;
Privacy protection: This method can effectively prevent on-chain data analysis and tracking, protecting user privacy;
Sweeper works by monitoring transaction records in the public memory pool to preempt transactions, but the TAICHI node allows us to submit signed transactions directly to miners without broadcasting through the public memory pool, which means that Sweeper is likely to monitor If it is not available, there is a possibility of front-running Sweeper (the public memory pool refers to the collection of transactions that have been broadcast but not yet packaged into the block).
The second recommended node is FlashProtect. FlashProtect is a solution to the MEV problem in the Ethereum system provided by the FlashBots organization. It works by packaging the users transactions and sending them directly to the miners through Flashbots instead of through the public memory pool. To prevent malicious miners and robots from discovering and exploiting these transactions in the public memory pool to withdraw funds using MEV. Its disadvantage is that the transaction speed is very slow because it uses the Flashbots memory pool, which has far fewer validators than the public memory pool. .
Conclusion
In general, various protection methods are also aimed at maintaining the sorting process of decentralized transactions and ensuring that smart contracts handle transactions in a fair manner, but the most fundamental solution must be to make adjustments from the perspective of miners and validators.
Lianyuan Technology is a company focusing on blockchain security. Our core work includes blockchain security research, on-chain data analysis, and asset and contract vulnerability rescue. We have successfully recovered many stolen digital assets for individuals and institutions. At the same time, we are committed to providing industry organizations with project security analysis reports, on-chain traceability and technical consulting/support services.
Thank you for your reading. We will continue to focus on and share blockchain security content.
Disclaimer: The content of this article solely reflects the author's opinion and does not represent the platform in any capacity. This article is not intended to serve as a reference for making investment decisions.
You may also like
Bitcoin, XRP and Vantard (VTARD) capture investors’ attention with price gains
The Daily: Dogecoin investors drop class-action lawsuit against Elon Musk, Michael Saylor plans $100K bitcoin party and more
Dogecoin investors have dropped their class-action lawsuit against Elon Musk, which accused him of manipulating the price of DOGE during its 2021 surge from less than $0.10 to around $0.70.JPMorgan analysts anticipate positive regulatory changes for crypto under President-elect Donald Trump, with clearer frameworks likely to benefit the industry.President-elect Donald Trump nominated bitcoin advocate Robert F. Kennedy Jr. for U.S. Secretary of Health and Human Services on Thursday.The following article is
Matrixport Included Developments That Will Affect Bitcoin in December in Its Weekly Report! Here Are the Details
Matrixport's latest weekly report highlights a number of positive factors that have underpinned Bitcoin's recent strong performance.
Trump's Inflow Wave Has Ended! Spot Bitcoin and Ethereum ETFs Experience First Outflows Since Election!
It ended a wave of inflows and outflows in spot Bitcoin and Ethereum ETFs that has been ongoing since Donald Trump was elected president on November 5.