Litecoin

Web3 Security Series: Can funds misdirected to other chains be saved

2025/12/16 12:24
👤PANews
🌐en
Web3 Security Series: Can funds misdirected to other chains be saved

In the encrypted world, a single click error could trigger a &ldquao; a digital catastrophe &rdquao; One of the most common nightmares is sending assets to the wrong block chain. For example, it was intended to send EPH to the Etherma Sepolia to test the address of the Internet, and it was accidentally sent to the Etherleas. In such a case, can funds misdirected from the Ether host network be recovered? The key to the recovery of assets is the type of receiving address. It will be analysed in the light of different circumstances。

1. SCENARIO I: EOA

EOA (Externally Owned Account) is what we often call a regular wallet address directly controlled by a private key or assistive word。

Prerequisites for recovery of assets:

  • YOU TRANSFERRED THE ASSET TO AN EOA ADDRESS。
  • YOU HAVE THIS TARGET EOA ADDRESS WITH A PRIVATE KEY OR A NOTE. (USUALLY YOUR OTHER WALLET ADDRESS, OR YOUR FRIEND'S ADDRESS, AND HE'S WILLING TO COOPERATE)。
  • THE TARGET CHAIN IS THE EVM COMPATIBILITY CHAIN。

Asset recovery method:

COLLECTION EOA ADDRESS PRIVATE KEY HOLDERS CAN SIMPLY WITHDRAW FUNDS DIRECTLY FROM THE TARGET CHAIN。

2. Scenario two: receipt address is a contract

This is one of the most desperate scenes. Since the address of the smart contract is not created by a private key, no one has a private key to the smart contract and cannot control it as much as controls the EOA. And if the contract is not pre-prepared for processing “ misdirected to the asset ” the rescue function, the misdirected funds may be permanently locked into the contract and no one can remove them。

IN SOME CASES, HOWEVER, THERE IS A CHANCE. AND THEN WE'RE GOING TO BUILD A SCENE THAT LOCKS ETH INTO THE ETHERWOOD HOST NETWORK, AND THEN WE'RE GOING TO TALK ABOUT HOW TO GET THE MONEY OUT。

2.1. Presentation of the scene

The scene summarised that the user had tried to call the Sepolia Test Network contract, transferring ETH to the contract to forge a token, but when the transaction was initiated, it was wrongly connected to the main network, resulting in ETH being locked into the main network contract. The specific scenario construction process is as follows:

1. On the Ether's Sepolia test, the projecter (EOA) deployed the contract realization, assuming that the main function of the contract is for the user to deposit an ETH to make the corresponding ATokeen, the approximate code is shown in the MintTokens function. The deployment is assumed to be A. It is important to note thatTHERE IS NO FUNCTION IN A THAT CAN EXTRACT ETH DIRECTLY。

2. On the Ether's Sepolia test, the projecter (EOA) deployed the plant contract, the function of the contract is to be based on the address provided for the performance of the contract and on the deployment of the minimum agency contract (Clones) to the performance agent contract (as indicated by the function deproyProxyByImplation). Assuming deployment at B. Suppose here we call the deployProxyByImplementation function so that the contract A address is entered as _implicationAN AGENT CONTRACT HAS BEEN DEPLOYED TO A AT C。

3. Users wanted to test the web at Sepolia to cast Token by moving to ETH, so the user initiated the call to the proxy contract C address, normally the proxy contract C calls further to the MintTokens function of contract A to complete the user operation. However, when the users called, they were wrongly connected to the Etherwood host network. So the user transferred the ETH directly to the C address of the Ether host。THE USER'S MONEY WAS TEMPORARILY LOCKED ON THE MAIN NETWORK'S C ADDRESS。

2.2. Key knowledge points

Before presenting specific relief programmes, the basic knowledge points on relief needs are presented。

2.2.1. create & create2

create and Create2 are the two deployment contracts that are common in Solidity。

  • at the time of deployment of the contract, the address of the contract was determined jointly by the address of the sponsor of the transaction and the number of transactions (nonce) of the account, irrespective of the content of the contract。
  • at the time of deployment of the contract, the contract address was no longer dependent on the nonce of the sponsor of the transaction but related to the following four parameters。
    • 0xff
    • create a contractual address for a new contract (address)
    • confusion value as parameter (salt)
    • create bytes to create the contract (init_code)

2.2.2. Minimum agency contract (Clones)

https://docs.openzeppelin.com/contracts/4.x/api/proxy#cones

The minimum agency contract, also often referred to as the Cloones contract, was based on the idea of deploying an agent contract at a very low cost (Gas), which pointed to a specified contract for its realization. In the Cones contract, a proxy contract can be deployed either by creating or by creating 2 or, for example, by deploying a proxy contract through the ClineDeterministic function。

In the clineDeterministic function, the byte code of the created agency contract is very short in format: 0x363d3d373d3d363d73&t; the > address of the realization contract; 5af43d8203e903d91602b57fd5bff3, directly encoded to the byte code for the realization of the address of the contract, and will be called to call all calls to the agent contract delegate to reach the contract。

As can be seen from the cloneDeterministic function, it creates proxy contracts by means of creating2the address of the created proxy contract is related to the address of the contract founder, salt, the address of the contract realization, a fixed byte code, and not to the byte code of the contract realization。

2.3. Rescue programmes

HERE'S HOW TO RESCUE USERS ON THE C ADDRESS. THE MAIN IDEA IS TO DEPLOY THE CONTRACT CODE, TAKE OVER THE MAIN NETWORK C ADDRESS AND EXTRACT THE ETH. SPECIFIC OPERATIONAL STEPS ARE AS FOLLOWS:

1. PLANT CONTRACT TO DEPLOY AND TEST THE SAME ADDRESS ON THE MAIN NETWORK B。The same plant contract address was required because the agent contract was calculated in relation to the plant contract address at the time of the subsequent call for the line Deterministic deployment agent contract. By looking at Sepolia ' s transaction to test the contract for the online deployment plant, obtaining the nonce of the person deployed in the transaction (the project owner ' s address), moving the nonce of the project party ' s (EOA) address to the nonce prior to the contract for the deployment plant, and then deploying the contract for the plant on the main network, as both the location of the person deployed and the nonce are identical to the test for the online deployment transaction, the plant contract address deployed on the main network is also B。

2. CONTRACT FOR THE DEPLOYMENT OF THE SAME ADDRESS A AS THE TESTING NETWORK ON THE MAIN NETWORK。In part #Minimum Agent Contract (Clones)# it is mentioned that the agent contract is deployed through the Clane Deterministic function of the Clones Contract, which calculates the proxy contract address, which relates to the participation salt and the realization of the contract address, and is not related to the byte code of the contract. SoALL WE HAVE TO DO IS PUT A CONTRACT ON ADDRESS A, AND THE DETAILS OF THE CONTRACT DO NOT AFFECT THE CALCULATION OF THE PROXY ADDRESS。SO WE CAN DEPLOY A CONTRACT THAT HAS THE CAPABILITY TO EXTRACT ETH DIRECTLY FROM ADDRESS A, THE CODE IS AS FOLLOWS。

On the test network, contract realization A is deployed by the project provider's address (EOA), so similarly, the location of contract realization A is related only to the operator of the transaction and its nonce. Thus, observing the transaction of online deployment realization A, finding the relevant nonce, pushing the main online project provider's address (EOA) to the designated noce, and deploying contract realization A is sufficient。

3. AGENT CONTRACT TO DEPLOY ON THE MAIN WEB SITE WITH THE SAME ADDRESS AS TEST NETWORK C。Observe the transactions of the online deployment agent contract C, obtain salt information, call on the deploy ProxyByImplementation function of the plant contract B, and pass in the address of contract A, salt as a parameter to deploy the agent contract on the address C of the main network。

4. CALL MAIN NETWORK AGENT CONTRACT C FOR WITHDRAWALS。Project Party Address (EOA) calls the agent contract C withdraw function and designates the recipient of the funds, successfully removing the frozen ETH in agent contract C and returning it to the relevant user。

2.4. Summary

As can be seen from the above-mentioned relief programmes, there are a number of conditions that need to be met when funds can be rescued, such as the fact that the contract-deployer does not use the relevant nonce on the target chain, the fact that the contract in which the funds are trapped has a withdrawal function or the fact that it can be deployed in various ways (the contract can be upgraded or used as an agent such as Clones)。

SO, WHEN YOU MAKE A DEAL, YOU HAVE TO BE CAREFUL, CHECK EVERY TRANSACTION INITIATED CAREFULLY, AND YOU CAN USE ZAN BEFORE YOU INTERACT WITH THE CONTRACTAI SCANGAP SCANNING TOOL TO DETECT CONTRACT SECURITY. YOU CAN CONTACT THE ZAN CONTRACT SECURITY AUDIT TEAM TO TRY TO HELP YOU WITH THE FUNDS。

This is by ZANTeam (X account)@zan_team& Antchain OpenLabs (X account)@AntchainOpenLabCara@Cara6289) Written。

QQlink

암호화 백도어 없음, 타협 없음. 블록체인 기술 기반의 탈중앙화 소셜 및 금융 플랫폼으로, 사용자에게 프라이버시와 자유를 돌려줍니다.

© 2024 QQlink R&D 팀. 모든 권리 보유.