user-image
CertiK
Apr 02, 2024

Blast Chain's $97 Million Battle: Are North Korean Hackers Rusty?

 

On March 21, 2024, the SSS Token (Super Sushi Samurai) was exploited due to a contract flaw. A logic error in the token contract allowed the attacker to arbitrarily increase the SSS Token balance of a specified account, resulting in a loss of over 1,310 ETH (approximately $4.6 million) for the project.

Less than a week after the SSS Token attack, another larger attack occurred on Blast, targeting the Munchables project. The attacker made off with 17,413.96 ETH, amounting to approximately $62.5 million. Half an hour after this attack transaction, 73.49 WETH from the project's contract was also stolen and transferred to another address by the hacker. At that time, the project's contract address still held 7,276 WETH, 7,758,267 USDB, and 4 ETH, all of which were at risk of falling into the hacker's hands. The hacker had the ability to take all the funds of the entire project, exposing a total of approximately $97 million to risk.

Following the breach, onchain detective @zachxbt identified North Korean hackers as the primary perpetrators.

Social Media Reactions to Munchables Project Compromise

Due to the significant losses suffered by users in this attack, we immediately initiated our own onchain investigation. Let's delve deeper into how these North Korean hackers executed an attack nearing a hundred million dollars.

The Victim's Statement: March 26, 2024, at 21:37 [UTC+0] (5 minutes after the attack), Munchables publicly confirmed the incident on X.

Munchables Project Compromise Announcement

The Crime Scene: The compromised contract (0x29958E8E4d8a9899CF1a0aba5883DBc7699a5E1F) is a proxy contract that held users' staked funds.

Detailed View of a Transaction on a Blockchain Explorer

We can see that the attacker invoked the unlock function of the staking contract, passed all permission checks, and transferred all the ETH in the contract to Attacker Address 1 (0x6E8836F050A315611208A5CD7e228701563D09c5).

Transaction Flow Analysis with Function Calls and Events Highlighted

It appears that the attacker invoked an unlock function, similar to a withdraw action, and withdrew most of the ETH from the compromised contract (0x29..1F).

The unlock function in the compromised contract (0x29..1F) has two relevant checks. Let's examine them one by one.

First, we found that in the process of verifying permissions, the isRegistered method of contract (0x16..A0) was called to check whether the current msg.sender, which in this case is Hacker Address 1 (0x6E8836F050A315611208A5CD7e228701563D09c5), has already been registered:

Detailed Breakdown of a Smart Contract Call Sequence

Smart Contract Function Detailing Security Check

The answer is: True.

Transaction Trace Analysis Highlighting Security Verification Steps

This involves contract (0x16..A0) and its corresponding latest logic contract (0xe74..f1).

At March 24, 2024, at 08:39 [UTC+0] (two days before the attack), the Implementation contract corresponding to contract (0x16..A0) was upgraded.

Smart Contract Upgrade Process Visualized in Transaction Trace

The implementation contract was updated to 0xe7..f1.

The original implementation contract address can be seen here, which is 0x9e..CD.

Event Notification and Delegate Call in Smart Contract Operation

At this point, we suspect that the hacker updated the implementation contract of the proxy contract, changing it from the original 0x9e..CD to the malicious 0xe7..f1, thereby bypassing the permission verification.

Luckily, in Web3, there is no need for guesswork or relying on others' words. If you have the technical skills, you can verify the answers yourself.

By comparing the two contracts (which are not open-sourced), we can observe some obvious differences between the original 0x9e..CD contract and the updated 0xe7..f1 contract.

The implementation of the initialize function in the 0xe7..f1 contract is as follows:

Complex Smart Contract Code Detailing Functionality and Logic

The implementation of the initialize function in the 0x9e..CD contract is as follows:

Smart Contract Code Showing Registration Timestamps

As we can see, in the original implementation contract (0x9e..CD), the attacker's address (0x6e..c5) was registered, along with two other attacker addresses 0xc5..0d and 0xbf..87. Additionally, their field0 was set to the block time at initialization. The use of field0 will be explained later.

Contrary to our initial speculation, the implementation contract with the backdoor was actually the original one, and the later updated contract turned out to be normal!

Wait, this update occurred on [UTC+0] March 24, 2024, at 08:39 (two days before the attack), which means that before this incident, the implementation contract had already been changed to one without a backdoor. So why was the attacker still able to carry out the attack afterward?

This is because of the delegatecall, which means that the actual state storage update is in contract (0x16..A0). This also means that even after the implementation contract was updated to the logic contract 0xe7..f1 without the backdoor, the slot changed in contract (0x16..A0) would not be restored.

Let's verify this:

Smart Contract Storage Query Command in Terminal

As we can see, the slot corresponding to contract (0x16..A0) does have a value.

This allows the attacker to pass the verification in the isRegistered method:

Solidity Function to Check Account Registration

The attacker later replaced the backdoor contract with a normal contract to cover their tracks. However, by that time, the backdoor had already been planted.

Additionally, in the unlock process, there is a second verification: a check for the lock duration is performed to ensure that the locked assets cannot be transferred before the lock period expires.

Smart Contract Code for Token Locking and Time Validation

The attacker needs to ensure that the block time when unlock is called is greater than the required lock expiration time (field3).

This verification involves the compromised contract (0x29..1F) and its corresponding implementation contract 0xf563Ce437E3aB8e0B79585dF5122700FBc42aFcd.

In a transaction on March 21, 2024, at 11:54 [UTC+0] (five days before the attack), we see that the original implementation contract for the compromised contract (0x29..1F) was 0x91..11.

Smart Contract Upgrade Event in Blockchain Explorer

However, just four minutes later, it was upgraded to 0xf5..cd.

Proxy Contract Upgrade Transaction in Blockchain Interface

Let's compare the two contracts. We can see that, similarly to before, the attacker tampered with the initialize function in both contracts. The implementation of the initialize function in the 0xf5...cd contract is as follows:

Complex Smart Contract Functionality with Memory Management

The implementation of the initialize function in the 0x91...11 contract is as follows:

Advanced Solidity Contract Logic for Time and Address Management

The attacker manipulated the ETH amount and unlock time in the contract, then reverted it to its original form to obscure their actions. This made it difficult for the project team and us as security researchers to identify the breach, especially since the contracts were not open-source, adding another layer of complexity to uncovering the core issue.

We've delved into how the attacker conducted a transaction with 17,413 ETH. Our analysis highlighted three embedded addresses within the contract.

  • 0x6e...c5 (Attacker Address 1)
  • 0xc5...0d (Attacker Address 2)
  • 0xbf...87 (Attacker Address 3)

While we initially focused on the first, the roles and activities of the latter two addresses remain undisclosed. Moreover, the functions of the address(0), _dodoApproveAddress, and _uniswapV3Factory parameters within the contract's code are still unclear, suggesting there's more to uncover regarding the contract's inner workings and the full scope of the attack.

The Second Crime Scene: Let's take a look at what Attacker Address 3 (0xbf...87) did. They used the same method to steal 73.49 WETH.

Furthermore, the source address for the attack gas (0x97...de) provided fees to both 0xc5...0d (Attacker Address 2) and 0xbf...87 (Attacker Address 3).

Ethereum Wallet Address Overview and Recent Transactions

The source of the 0.1 ETH from the attack gas source address (0x97..de) can be traced back to owlto.finance (a cross-chain bridge).

After receiving fees, the second attacker address didn't launch an attack, yet played their part in the operation, as we’ll soon see.

Post-event analysis revealed the compromised contract (0x29..1F) held substantial assets beyond the initial theft, including over 7,000 WETH and more than 7 million USDB.

And here’s the rescue transaction.

Decentralized Application (DApp) Contract Interaction

Originally, the attacker intended to steal these assets. We can see that the address 0xc5...0d (Attacker Address 2) originally intended to steal USDB.

Smart Contract Invocation and Transaction Details

The _dodoApproveAddress here is 0x0000000000000000000000004300000000000000000000000000000000000003:

unnamed - 2024-03-27T120047.740

Which is the address for USDB:

unnamed - 2024-03-27T120120.425

Address 0xbf..87 (Attacker Address 3) was used to steal WETH:

unnamed - 2024-03-27T120154.027

The _uniswapV3Factory here is 0x0000000000000000000000004300000000000000000000000000000000000004

unnamed - 2024-03-27T120234.501

Which is the address for WETH:

unnamed - 2024-03-27T120309.773

Address 0x6e...c5 (Attacker Address 1) was responsible for stealing address(0), which is the native asset ETH.

The attacker could steal the corresponding assets through the following logic by setting field0:

unnamed - 2024-03-27T120339.977

unnamed - 2024-03-27T120354.217

Why Didn't They Steal Everything?

In theory, the attacker could have stolen all the remaining assets, including the remaining WETH and USDB.

Address 0xbf..87 (Attacker Address 3) only stole 73.49 WETH, but they could have taken all 7,350 WETH. They could also have utilized address 0xc5..0d (Attacker Address 2) to take all 7,758,267 USDB. Why they stopped after taking just a small amount of WETH is unclear.

unnamed - 2024-03-27T120440.093

Why Didn't They Transfer the 17,413 ETH to the Ethereum Mainnet?

As is well-known, Blast has the ability to intercept these ETH through a centralized mechanism, ensuring they remain permanently within the network and avoiding any substantial user losses. However, once these ETH enter the Ethereum mainnet, there is no way to intercept them.

While the Blast's official bridge imposes no transfer limits but enforces a 14-day withdrawal period, third-party bridges facilitate quicker transactions, raising questions about the attacker's initial hesitancy to transfer assets.

In fact, the attacker initiated cross-chain transfers within two minutes of the attack:

unnamed - 2024-03-27T120535.226

The funds arrived on the Ethereum mainnet within 20 seconds. In theory, the attacker could continuously carry out cross-chain transfers, moving a large amount of ETH across before any manual intervention by the bridge operators.

unnamed - 2024-03-27T120621.537

The restriction to transferring only 3 ETH at a time is attributed to the liquidity limitations set by the cross-chain bridge, affecting the volume that can be moved between networks. Transferring from Blast to Ethereum involves:

unnamed - 2024-03-27T120646.364

Another cross-chain bridge supporting Blast offers even less:

unnamed - 2024-03-27T120726.247

After this transaction, the attacker did not continue with any further cross-chain operations. The reason for this is unknown. It appears that they may not have been adequately prepared for withdrawing funds from Blast.

Following the attack, the community rallied.

unnamed - 2024-03-27T120805.440

Ultimately, due to collective efforts from the broader community, the attackers, potentially fearing exposure, returned all stolen assets by providing the Munchables team with the private keys for the associated addresses. Subsequently, the team executed a rescue operation, securely transferring the retrieved funds to a multi-signature contract.

Screenshot 2024-03-27 at 12.25.01 PM

 

Original Link

Disclaimer
I confirm that I have read and understood the following: The information contained in this article is strictly the opinions of the author(s). This article was authored free from any form of coercion or undue influence. The content represents the author's own views and does not represent the official position or opinions of CrossAngle. This article is intended for informational purposes only and should not be construed as investment advice or solicitation. Unless otherwise specified, all users are solely responsible and liable for their own decisions about investments, investment strategies, or the use of products or services. Investment decisions should be made based on the user’s personal investment objectives, circumstances, and financial situation. Please consult a professional financial advisor for more information and guidance. Past returns or projections do not guarantee future results. This article is provided by CrossAngle’s third-party research partners. CrossAngle does not have any editorial control over this article and does not warrant the accuracy and timeliness of the information contained herein. This article may contain links to third-party websites, over which CrossAngle disclaims any control or responsibility.
Xangle or its affiliated partners own all copyrights of the written or otherwise produced materials and content provided on the platform. Any illegal reproduction of such content, including, but not limited to, unauthorized editing, copying, reprinting, or redistribution will result in immediate legal actions without prior notice.