Good morning, everyone. Good morning. Thank you for attending our talk. This research is about replay attacks on Ethereum smart contracts. Now let me give a brief self-introduction. I must emphasize here that Zheng Xianbai is a primary researcher. He did more than half of the work, but for some issues of visa, he can't attend this talk today. So the job is ours to introduce the research to you. My name is Yiwei Zhang. I am a security researcher on Unicom team, and this is my colleague, Kun Zhe Chai. Unicom team is a research group within 360 technology. The team was formed in 2014. We focus on the security issues in numerous types of wireless systems, but we also encourage members to do other research that they are interested in. This is why we also have this topic. Today's talk encompasses four parts. At the beginning, we were introducing the backgrounds of blockchain, smart contracts, and Ethereum. Then we will discuss security issues about the potential risks in smart contracts. Thirdly, we will talk about the key point, replay attack, and we are going to show why it exists and how it works. And the last one is a demonstration of replay attacks. And the statistical analysis of similar vulnerabilities. Now, let Kun Zhe Chai show you the first part. Hello. Hello, hello, hello. Hey. Hello, everyone. As you know, my name is Kun Zhe Chai. I come from China. So, the first topic is in background and mainly about the introduction of related files of replay attacks like blockchain, smart contracts, or Ethereum. So, we've heard some news about blockchain, but what is blockchain? Blockchain, so to speak, is a large stack globally, directly computer network, and users can interact with it by sending transitions. Each transition is a message, with cryptographic, central, and the order of currentization in force is defined by a nickname called global conditions. is defined by a message, called global conditions. The advantage of blockchain are listed here. It has unified the database with the replayed concerts, which allows a settlement to be completed within three to 60 seconds, which allows a settlement to be completed within three to 60 seconds, rather than three days and more. It offers a way with a large scale fault tolerance in which system can withstand 33 to 40%. Now, the feature all still operate normally under the blockchain. Now, the feature all still operate normally under the blockchain. Blockchain does not really trust and not controlled by any single administrator or organization, except for prevailed chain and . except for prevailed chain and . So, it is able to be audited external observer can verify the history of transitions. It can operate autonomously without any human involvement. So, next, What actually can blockchain achieve? First, it can actually which is digital assets on the blockchain. Right now, Sorry, sorry, public chains offer their own tokens to limit the rate of updating transitions and incentives the monetization of blockchain. Next, it has some non-monetary features, including recloud as the expense on blockchain and timestamp machines to create high-value data. Then, blockchain systems have some other functionality, including concepts that can assure... ...custom digital assets, offer options and face code, deal with this, and generate computers. I'm sorry, my poor English, so I tried to relax. Sorry. For now, we have no main application. Blockchain is a field of monetization. How about those in the non-monetary field? About 2013, the public realized that blockchain can be used in hundreds of applications besides that. And such as... ...and such as asset... ...dominant... ...recognization and ownership recognition market for FISA sitting and Internet of Things voting and so on. And how to release those applications? We need a smart contact. What is smart contact? It is a computer program running in a secure environment. That actually... ...that... ...automatically transfers digital assets according to previous rules. For example, I will give you a tip. Suppose you are with your girlfriend and she will give you 100 bucks if you can figure out what's inside her shopping bag. Maybe that is a dress or a t-shirt. And you made it. But your girlfriend will not pay you anything. You have money. You have to accept it because you have no other way to get your reward. However, if there is a smart contact, once you made your guess current and the coder will automatically be enforced and the reward in real solution, it might be a digital token will come into your pocket. So... ...smart contacts are a piece of coder living in the blockchain and enforcing certain functionalities. How do you construct the secure environment for smart contact? Certainly, there are many public chains for smart contacts. And let's see the most popular one. ASM. What is ASM? It's a blockchain with a built-in programming language. And it offers maximum app server and works steadily. So, it is very ideal to process smart contracts. ASM has a secure operating system called ASM. Called ASM virtual machine. Also known as EVM. This is not encased by a sandbox. But in fact, it is completely isolated. That is the coder that runs inside the EVM does not have access to the network or file system or another proxy. Even smart contracts have limited contact with another or other smart contracts. With EVM. So, our smart contacts can be used in many things. One of them is financial things. Financial things including hedging, contract saving, and other non-financial things. Includes online voting. Decentralized marketing. And managing and DNS reconnotations. However, with increasing speed of applications of ASM and smart contracts, many security issues come along. According to analytics. 100 and a thousand news users join the ASM ecosystem daily on the average. They are quite active and in for delay transitations over 1 million times on the ASM. This is in fact, the biggest problem of ASM. With increasing marketplace attack, many eyes from hackers and security issues come up for more frequently. In many parts of our ecosystem, such as exchange, wallet, and smart contract ATC. There are several security issues come up including exchange attack and wallet hiding. Wallet hijacking and overflow attack in smart contacts. As to smart contact, which is most vulnerable in the ASM. There are also many security issues. Just for 2018 in April. Contacts such as BS were detected with vulnerability. With ASM. With vulnerability. In May, security attacks to several contact like EDU or other. In June, there are another security issues reported to smart contact like SNS. All these open air loopholes made a huge impact on the module exchange. Affecting several. Functions including talking as nature. Talking deposit and a token deposit and a token withdraw. According to the most recent research papers from and University College London. After organizing be close to 1 million smart contact. And 34,200 of them are vulnerable to hacking. And they also assembled another 3,759. So in the case of this smart contact and the phone. 18. At 8 and 9 percent of them. Are currently loopholes. So how to lower the probability of loss? First, we require a complete and objective data for our contact. And second, when any loopholes is found. We need to make. We need to make any emergency response. So that we could now at first time. At first time. This contact is beginning to attack. And the third. There needs to be some. It may. For those who detect and report any bugs. To. To. To. To. To. The whole system is operating And. So. Next part is my college. My. And. By the way I am very sorry my English. So. Give you next good one. Hi I am back now. Next, we are going to focus on the issue of replay attacks in smart contracts. Now, let me explain the concept of replay attack. As distinguished from replay attack in traditional network world, it's not to capture and resend a package. That is, if a transaction is legitimate on one blockchain, it's also legitimate on another blockchain. So, when you transfer BTC1, your BTC2 or BTC3 may be transferred at the same time. That is the replay attack in blockchain. As to replay attack, we found that many smart contracts adopt the same way to verify the validity of the signature. And it's possible for replay attack. Our motivation is that we propose replay attacks on smart contracts and wish to attract the users' attention. We try to detect the vulnerability in smart contracts and make them more secure. Finally, we want to enhance the язы觸 awareness for contract creators and enjoy the interests of investors. To at achieve our goal, we have done several things like that. We freedom the replay attack. attack problem exists in 52 smart contracts, and we analyzed the smart contract example to verify the replay attack. We analyzed the source and the process of replay attack to expound the feasibility of replay attack in principle. We also verified the replay attack based on the signature vulnerability. And finally, we proposed defense strategy to prevent this problem. Then I'm going to show you something. The first item is vulnerability scanning. Our aim is to get the name and the number of vulnerability or replay attack in smart contracts. And then we set the three scanning stands to discover the smart contracts which have the vulnerability. First, judging whether the contract is accorded with the DRC-20 standard. This requires the total supply to be greater than zero. Second, get the name of the contract to determine whether the name is valid. Thirdly, failed smart contracts vulnerable to replay attack. The SRM provides the easy recovery function to verify the signature. If a contract uses the easy recover function, it was marked as suspicious. This scanning program can be found at the following site. It's in our GitHub storage. After we audited and verified the scanning output, we found 52 RISC targets. The first one is the RISC target. texted character. and this is the code to scan ERC-20 talking contract. You can take it from the GitHub, from GitHub's storage. Why does the replay attack occur? Argh! Argh! Argh! Argh! were utilized in smart contracts, if the contents of the signature were not correctly limited by the smart contracts, there is possibility of replay attack, such as the interface transfer proxy. Here is an example. The contents of the MTC contract signature and the contents of the UGT contract signature are exactly the same. This is an example in the contract. The issue lines like this line. The KECC-AK-256 function calculates the hash, and the hash is the input of the signature. So we can see in the parameter of this function, it's just a from, to, value, fee, and an ounce. There is nothing related to the contract itself exactly. Now let me explain the ATT&CK process. Let's suppose that transaction in a contract one. User A wanted to transfer 100 tokens to user B through proxy three C, and the access address three token should be paid for proxy C as a service fee. In this process, the input of the signature, the token, and the hash, is the transaction of user A through the B, A, B, 103, and the latest month, one. Then the transfer were carried by proxy three C. After this transaction being completed, user B can get 100 tokens from user A. Well suppose user A doesn't carry out the transfer or a contract two through proxy three. So the latest month is also one. Well suppose user A, now the replay attack starts. After we see 100 tokens from user A, user B replays that signature, or user A, from RA contract one, in RA contract two. Now he can get another 100 tokens in RA contract two without the permission of user A. That is to say, this smart contract, RA contract two, were attacked by user B, and the 100 tokens of user A were stolen. Next, to verify the existence of this vulnerability, we conducted an experiment. The experiment condition are listed as follow. We choose two ERC-20 smart contracts, the UDT contract and the MTC contract. Then we create two accounts, Alice and Bob. Next, we deposit some tokens in the two accounts in corresponding contracts. And the procedure of this verification is that in step one, the normal transaction records on the Ethereum were scanned to find out accounts which had both UGT tokens and MTC tokens. But here, we use two accounts, Alice and Bob. In step two, Bob induced Alice to send him two UGT tokens. And the transaction input data is shown as below. The length 0 to 6 corresponds to the arguments of the function transfer proxy. In step three, Bob takes out the input data of this transaction on the blockchain. The process is the same. parameter from two value phi, r, v, and s were extracted from this method. The following is the implementation of the transfer function. In step four, Bob used the input data in step two to execute another transfer in the smart contract of MTC. The result of this transaction is shown as below. Step five, Bob got not only two UGT-3, MTC tokens, but also two MTC tokens from Alice. In this procedure, the transfer of two MTC tokens was not authorized by Alice. Now we come into the final part, demonstration and analytics. And to begin with, the demonstration, we select two contracts, the UGT contracts and the MTC contracts. Then we send to our owner accounts, Alice and Bob. Alice is the sender and Bob is the receiver. Both the two accounts own some tokens for transferring. This is the next step. Next, this is a port code. In the code of the parameter from two value phi, v, r, s are all acquired from UGT. This is a call as a parameter read from the chain. The parameters r, s and v are signatures. signature. In another token replay, from two, three are exactly the same as the last call. And the simple proxy transfer scenario is that first they use a delegate's third party, UDC, to help him transfer tokens. UDC gets the address of the contracts and creates the instance of the tokens to be transferred. After that, they will get the signature from user A and invoke the transfer function provided by the contractor to send the tokens to the token receiver, user B. Then the proxy C will wait for the information that the miner has done the package process and finally the transaction process finishes. Now, let me show you the demo. For comparison, I query the balance of Bob on both UGT contract and the MTC contract. He has six tokens on both the two tokens. Now, I transfer three tokens from Alice to Bob on UGT contracts through a proxy. Wait a few seconds. For the miner to pack. Okay, it's finished. Now, I query the signature. And I query the balance of Bob on both UGT contracts and MTC contracts again. The balance on UGT is nine, but on the MTC, it's still six. I copy the parameters from UGT to MTC, I copy the parameters from UGT to MTC, and start the replay attack. and start the replay attack. You can see here, I just need to input the password of proxy. I don't need to input the password of Alice. It means that we don't need the permission of Alice. It's finished. Now I query the balance of Bob on MTC. We can see the balance is nine, is nine now. So Bob's store is still there. Bob stole three tokens of Alice on MTC contract. To show you the impact of this vulnerability, we also made some related statistics and analysis. By April 27th, the vulnerability of this replay attack RISC exists in 52 SRAs. Finally, according to the vulnerability of the replay attack, we divided these contracts into three groups. The group one, there are ten contracts. No specific information is contained in the signature of smart contracts, so the signature can be fully read. And in the group two, there are 37 contracts. In these contracts, specific string is added into the input of the signature, but the signature is still can be reused. In the group three, the address of the contract or the address of the sender is contained in the signature of smart contract. But there are strong restrictions, but there is still have the possibility of replay attack. Secondly, we classified these contracts by feasible replay attack approach. Five contracts can be replayed in the specific contract itself. The first five contracts can be replayed in the specific contract itself. and another 45 contracts can be replayed between different contracts. Besides, we divided these 45 contracts into three groups for the specific prefix data used in the signature. Cross-contract replays may happen among any contracts as long as they are in the same group. The group 1 and the group 2 both aid specific identical data to the input of signature. We mark the specific prefix data used in group 1 as data 1 and we mark the specific prefix data used in group 2 as data 1. We mark the specific prefix data used in group 2 as data 2. So, for example, you can see the data 2 in these contracts is the same string, srm send message. In group 3, they don't aid any prefix data to the input of signature. So, in group 2, they don't aid any prefix data to the input of signature. And there are two chains can be replayed between test chain and main chain. Secondly, according to the trading frequency of above-mentioned contracts, by April 13th, April 13th, Twenty-four contracts were found, which had the transaction records within one week, and nine contracts were found, which have the transaction records from one week to one month. The proportion of nearly 20% of the total number of the contracts is active. Sixteen contracts were found, which have the transaction records beyond one month, and three contracts only have the records for deployment. So according to the comprehensive analysis, 16% of the contract transactions are still active. The reason for this is that the transaction records are still active. The reason for replay-attacking smart contracts is that they misuse the signature when constructing the contractor. So our countermeasures are listed here. First, the designers of smart contracts should always confirm the suitable range of digital signatures when designing smart contracts. Second, the smart contracts deployed on public chains should add in the specific information of the public chain, such as the chain ID and the name of the public chain, and other identical information. Finally, the users of smart contracts need to pay attention to news and reports concerning the order. Third, the smart contracts' regulations Mateo IN And the conclusion is that the security problems of smart contracts have been widely concerned. As long as the signature was misused in smart contracts, there is possibility of replay-attacks. So I use my820 rectangles here. We believe that the vulnerabilities on the Ethereum smart contracts have not totally come to light. Thank you for listening to our talk. If some guys have some questions of this attack, you can send the mail to us. Thank you.