BlockApex (Auditor) was contracted by SONAR (Client) for the purpose of conducting a Smart Contract Audit/Code Review for Sonar Bridge V2. This document presents the findings of our analysis which took place on 28th September 2021.
“… it took only five hours to protect 350 million USD from falling into the wrong hands.”
Writes samczsun as he describes the infamous rescue of MISO protocol’s funds involving the historically perfect case study of such an attack that could have easily made it to the top 10 of the largest blockchain security hacks to date. In an almost poetic way, this case study covers the step-by-step story experienced first-hand by samczsun himself when he describes the “encounter, discovery, disclosure, preparation, rescue, and reflection” on the MISO fiasco. Write-ups and disclosures guide us towards the elegant handling of war-room cases and how to go through such situations following a standardized approach.
Let’s continue infiltrating the EVM
In our article series, we move on with the 4th part today, focusing on some of the writeups in the web3 security space that educate the readers on how to handle the situations that always inflict a 0-day attack. The list covers some well-known writeups, such as the paradigm’s write-ups of the MISO attack, Ethereum is a Dark Forrest, and the industrially standardized Yearn’s public disclosures (and others).
The emphasis will be on learning about situations and environments of how a bug discovery, rescue, and fix are deployed in a war room, some of which end up happily ever after, and others teach us more valuable lessons. This teaches us how strategies are created and practiced setting up standards throughout the industry.
Amidst the fascinating narratives of blockchain security challenges, one particular incident stands out as a testament to swift action and proactive auditing. Let's first delve into the gripping tale of the MISO rescue mission, where $350 million was at stake, and the clock…; the clock is always ticking.
On August 18, 2021, samczsun reported a critical vulnerability in SushiSwap’s MISO smart contracts, which put ~350 million USD (109 thousand ETH) at risk.
In the ever-evolving landscape of DeFi, where fortunes are made and the stakes run high, the tale of the MISO protocol's rescue mission stands as an epic saga of audacity and triumph. Picture this - $350 million hanging perilously on the edge, teetering between salvation and the abyss of the wrong hands. As the clock ticked, the guardians of MISO stepped forward, ready to shield their treasure from the clutches of lurking adversaries.
This gripping saga begins with samczsun, a keen-eyed auditor, stumbling upon a discussion about a raise on SushiSwap's MISO platform. Driven by curiosity, he delves deeper, scrutinizing the Dutch auction contract, hoping to ensure the system's integrity.
Drawing from past experiences with Opyn, samczsun realizes the eerie similarity between the vulnerabilities. Inside a delegatecall, msg.sender and msg.value persist, opening the door to reuse msg.value across multiple commitments, aka batchcalls.
The magnitude of what this bug could bring was a staggering amount of ~$350M.
In the fast-paced world of DeFi, where transactions occur rapidly, every moment counts, as opportunistic hackers could discover the vulnerability at any time. Hence, the team had to act swiftly and strategically to safeguard the funds and neutralize the immediate threat posed by the vulnerability before it could be exploited. The clock was ticking, and the safety of a substantial amount of funds hung in the balance, making it a race against time to protect the treasure from falling into the wrong hands.
The team precisely acts, finalizing the Dutch auction and neutralizing the immediate threat. Yet, challenges arise as they encounter an active batch auction. A quick decision is made to prioritize safeguarding the 350 million USD while mitigating the risks in the batch auction.
Creating a rescue strategy is paramount, as determined by the MISO Sentinels. To gain an advantageous position in a war room scenario, it is imperative to explore all possibilities, which is precisely what the MISO war room team is doing. To achieve this objective, the team reaches the conclusion of implementing a smart contract that utilizes one of the protocol’s features as a pause functionality. The team consisting of esteemed experts, namely Samczsun, Mudit, Dan, Georgios, Keno, and Omakase, with Joseph Delong from the Sushi protocol, plays a crucial role in the process.
Here we list down a couple of lessons learned, in the words of the sentinels, as the first-hand experience is the best of the teacher. samczsun states covering the Reflection of the whole fiasco as follows;
More importantly, samczsun mentions the one thing that is at the core focus of DeFi SRs at BlockApex as well, as below;
You can read how the whole scenario unfolded in this blog. (source: Two Rights Might Make A Wrong)
This incident also brings forth the depiction of Ethereum to mind the "Dark Forest" concept in the Ethereum mempool, where opportunistic arbitrage bots lie in wait to exploit profitable opportunities. The term was coined by Dan Robinson and Georgios Konstantopoulos in Aug 2020.
It all began when a user inquired about recovering Uniswap liquidity tokens mistakenly sent to the pair contract. Dan Robinson knows two things when he officially terms the Ethereum blockchain as a Dark Forest;
In mempool, arbitrage bots lurked like apex predators, ready to exploit any profitable opportunities they detected. Known as "generalized frontrunners," these bots could copy and manipulate transactions to their advantage. This created a challenging environment for the rescue mission, as any attempt to claim the tokens could be instantly targeted and stolen by these savvy predators. An intricate plan was crafted to recover the funds without drawing attention from the bots. Custom contracts were deployed to obfuscate the rescue transactions and make them less conspicuous.
The obfuscation looked like this, to veil the call as an internal transaction, the sentinels decided to break down the transaction into two pieces:
Quoting Dan below, the implementation detail need to be executed in the following order;
Getter
contract which, when called by its owner, would make the burn
call ONLY if activated, and otherwise revert.Setter
contract which, when called by its owner, would activate the Getter
contract.set
transaction and the get
transaction in the same block.”As the pressure mounted, a critical oversight proved costly. In their haste to execute the rescue, a key detail was missed—the get transaction slipped into a later block, providing a window of opportunity for the bots to strike.
As expected,
Bots struck… Bots won.
Readers are here for the lesson, which is what they shall get.
The entire scenario's account, written by Dan Robinson and Georgios Konstantopoulos, can be read in this blog.
While the rescue faced setbacks, it highlighted the need to address MEV and front-running attacks in DeFi. Promising solutions, such as Optimism's vision for redirecting MEV and StarkWare's verifiable delay function service, offer hope for a more secure future. As the DeFi landscape evolves, staying vigilant and proactive in securing the ecosystem becomes paramount.
Once hailed as an innovative DeFi protocol offering options and automated liquidity provision, Siren Markets was at the center of a high-stakes exploit that threatened its users' funds. The vulnerability lay hidden within the Automatic Market Maker (AMM), presenting attackers with a unique opportunity to game the system and profit at the expense of the protocol.
At the heart of the vulnerability were bTokens and wTokens, the twin tokens representing different sides of the options contracts. Armed with this knowledge, attackers devised a cunning plan. They strategically acquired equal amounts of bTokens and wTokens to neutralize their exposure to the underlying asset, laying the groundwork for their assault.
The attackers bided their time, waiting for the opportune moment: when the market was about to expire. As the countdown neared its end, two potential scenarios emerged. If the options expired from the money (OTM), the attackers swiftly exercised their wTokens, recuperating their losses.
However, the "in the money" (ITM) scenario showed their strategy's brilliance. Just before the bTokens' expiration, the attackers made a bold move: they sold these tokens back to the AMM. Unbeknownst to the AMM, the attackers cleverly exploited its lack of action. The AMM, unsuspectingly, bought the bTokens at their current valuation without exercising the option.
The plot thickened with the application of block stuffing!
Block stuffing is a type of attack in blockchains where an attacker submits transactions that deliberately fill up the block’s gas limit and stall other transactions. To ensure the inclusion of their transactions by miners, the attacker can choose to pay higher transaction fees. By controlling the amount of gas spent by their transactions, the attacker can influence the number of transactions that get to be included in the block.
Siren Market assumed that the bug fix was a transaction that would be handled gracefully, i.e., eliminate the ITM option, but this is the prime example we are trying to share with our readers. By setting higher gas fees than honest users, the adversary ensured miners would prioritize their transactions, creating a temporary denial-of-service (DoS) effect. This sneak attack made it challenging for the Siren team to execute their fix, ultimately forcing them to exercise ITM options.
In this series of articles, we explored a new attack vector revealed by the vulnerability in the Siren Market. Our goal is to educate Blockchain Sentinels on the surprises the blockchain has up its sleeves, even when it comes to something as important as a bug fix for a transaction. The key takeaway is considering how an attacker could bypass your vulnerability fix.
After covering a number of war room stories, we wrap up echoes of the past with Yearn’s public disclosures. Yearn Finance has worked on its small and large vulnerability identification and fixes for almost two years. The list on their GitHub repository covers the details of all hacks organized by date and time, with a template set as a standard for bug fixes. The template covers the segments of hacks or reported findings by including a description of the summary, background, details of the vulnerability, details of the fix, an attribute of the timeline of events, and important links relevant to the said hack.
The article "Infiltrating The EVM IV - Echoes of the Past, Visions for Tomorrow" takes readers on a captivating journey through real-life incidents in the realm of blockchain security. Three gripping narratives stand out: the MISO rescue mission, the Dark Forest of Ethereum, and the Siren Market exploit.
In each case, the common theme is the urgency of swift action and proactive auditing to protect massive sums of money at risk in DeFi protocols. These stories serve as powerful reminders of the high stakes involved and the ever-evolving challenges faced by auditors and security experts.
Key lessons emerge from these experiences. First, secure composability is crucial. Combining safe contract-level components does not always guarantee overall safety, as seen in the MISO case. Second, the DeFi ecosystem must address risks like MEV and front-running attacks, which can threaten funds at any moment.
Transparency and accountability are paramount. Protocols like Yearn Finance, with their public disclosures and standardized templates for bug fixes, set a commendable example for the industry. Sharing insights and vulnerabilities openly can foster trust and strengthen the community.
This is the Fourth part of the series Infiltrating the EVM.
BlockApex (Auditor) was contracted by SONAR (Client) for the purpose of conducting a Smart Contract Audit/Code Review for Sonar Bridge V2. This document presents the findings of our analysis which took place on 28th September 2021.
how do we keep the blockchain application safe? Let's walk through some security frameworks for blockchain applications in this blog
Yamato Protocol is a crypto-secured stablecoin generator DApp pegged to JPY. Yamato Protocol is a lending decentralized financial application (DeFi) that can generate Japanese Yen stablecoin "CJPY". It is being developed by DeFiGeek Community Japan, a decentralized autonomous organization.
This comprehensive threat analysis report provides an in-depth review of potential security vulnerabilities within the LightLink Token Transfer Bridge Architecture. Through rigorous application of both the STRIDE and ABC threat modeling frameworks, the report identifies key system weaknesses and offers strategic mitigation recommendations.
Illiquid Marketplaces is a common problem with various underlying factors. Information asymmetry, where one party has more knowledge than the other, makes it challenging to establish agreements and facilitate transactions. Complex market structures, with intricate trading rules or inadequate infrastructure, can hinder liquidity. Small marketplaces with fewer users naturally have less liquidity. Fragmented marketplaces, where sellers impose rigid terms, create barriers for potential buyers.
On the surface, the GameFi industry sounds revolutionary. However, digging a little deeper reveals several questions about its legitimacy. What are the risks associated with its play-to-earn model? Are all games which claim to be a part of GameFi credible? And, at the end of the day, is this a viable direction for gaming, or nothing more than a short-lived gimmick?
An off-chain transaction deals with values outside the blockchain and can be completed using a lot of methods. To carry out any kind of transaction, both functioning entities should first be in agreement, after that a third-party comes into the picture to validate it.
BlockApex (Auditor) was contracted by Sonar(Client) for the purpose of conducting a Smart Contract Audit/Code Review of Sonar bridge modeule. This document presents the findings of our analysis which took place on 8th September 2021.
Data breaches and consumer privacy are one of the most alarming security issues in IT space. About 45% of the world’s population uses social media which makes approximately 3.48 billion people to be interacting with any kind of social media network. These tremendous amounts of connections can lead to various kinds of vulnerabilities if the data is gone into the wrong hands creating pretty damaging consequences.