DeFi’s Composability: More Possibility, More Risk (2024)

Decentralized Finance (DeFi) is quite possibly the strongest and most obvious use case for the Ethereum blockchain. It's reinventing the traditional financial system, making sophisticated financial products accessible to anyone with an internet connection.

DeFi is only possible thanks to smart contract technology. However, their very nature means that smart contracts are irreversible and immutable after deployment. And one of their key features—composability—means that DeFi's seemingly endless potential comes with a myriad of risks.

In the Ethereum world, smart contract bugs could be thought of as the original risk—many people will remember the infamous DAO Hack in 2016, ultimately due to a reentrancy vulnerability. Yet, as the space evolves and interactions become increasingly complex, even more risk vectors have emerged.

DeFi’s composability is often described as a “double-edged sword.” Smart contracts and pools of capital frequently interact with many others to compound their functionality: much more can be accomplished by integrating multiple smart contracts, creating endless combinations with these “money legos”. Unfortunately, this increase in possibility also opens the door to new, unknown attack vectors.

In 2020 and 2021, Ethereum’s decentralized finance sector lost over $150 million to economic attacks. In 2021, this number has already surpassed $200 million. These hacks and exploits have involved rug pulls, malicious use of admin keys, phishing, smart contract vulnerabilities, and more.

The open nature of smart contracts means that loopholes and vulnerabilities are visible to everyone. And, with billions of dollars in value locked in DeFi protocols, they are an increasingly lucrative target for hackers.

Increasing Complexity

Added to the temptation of billions in value to potentially be exploited, a recurring challenge in DeFi is its increasingly complex interactions. While DeFi’s money legos facilitate more sophisticated transactions, this also increases the number of interactions with external—and possibly untrusted—code. Smart contracts rely on external transactions to trigger their functions. Any transaction on the Ethereum blockchain—other than simply sending ETH—will interact with one or more smart contracts, commonly referred to as a “contract call”. In 2019, the average number of smart contract calls triggered by each transaction was 1.19. As of April 2021, this number had risen to 2.40.

Decentralized apps often involve multiple smart contracts interacting across multiple protocols. While this is an incredible feature, each new link presents new complexity and new attack vectors. A vulnerability with one smart contract could have far-reaching consequences for multiple protocols across the DeFi space. The total number of external contract calls has risen dramatically as the sector grows, and with each additional smart contract, the chance of a bug increases. In addition to increasing numbers of external smart contract calls, internal calls are increasing as well, indicating the increasing complexity of smart contracts themselves. And, a big picture view is becoming an essential skill: understanding how various protocols or pools could be used together to orchestrate an attack is key in identifying vulnerabilities.

Flash Loans and Price Manipulation

In addition to the increased complexity of internal and external calls across a myriad of different protocols, another frequent risk within the DeFi space is price manipulation attacks. Smart contracts rely on oracles, which provide an interface between the contracts and an external source to pull the required data. For example, lending protocols rely on on-chain oracle price data to properly price assets. With flash loans, anyone can take advantage of arbitrage opportunities in the market. Unfortunately, bad actors may use flash loans to manipulate or corrupt prices.

By manipulating the price of an asset, someone can arb the difference and take advantage of bugs in a protocol. Hundreds of millions have been lost in flash loan exploits.

Avoiding the Dangers in DeFi

While most people may understand the importance of a proper security audit, there is still a lot of nuance around what this means. The first thing to understand is that getting an audit in no way guarantees that a protocol is secure. Some projects have been through an external audit yet have poor documentation or unresolved vulnerabilities. Teams may make code changes without getting another audit done, opening the door to previously out-of-scope attack vectors. Or, in some cases, exploits occur due to code that wasn’t part of the initial audit at all.

While getting an audit is an essential part of mitigating risk, there are steps that teams can take—both before and after the audit—to stack the odds in their favor:

1) Information Security and Communication

Often, DeFi protocols use admin keys, which allow certain individuals—often the core team—to upgrade contracts or otherwise make moves in the case of an emergency. Having this access can let a founding team stay agile in the case of an emergency. However, it also introduces operational risk—if these keys are compromised, malicious third parties (or even rogue team members) could gain control of the smart contracts. Teams can mitigate these risks through features such as multisig and timelocks.

2) Documentation Quality

Conduct proper requirements engineering and write a good technical specification, including all use cases. While some people may feel writing is an onerous task that gets in the way of a more agile approach, it is crucial to security. A proper technical specification ensures everyone is on the same page and that all the bases are covered. By taking the time to think through complex issues and potential obstacles, you’ll end up further ahead. Another factor to consider is that clear, high-quality documentation will ensure that external auditors can audit your project in an effective and timely manner.

3) Quality Testing

Quality testing is crucial. In addition to getting an audit, teams should make sure to write complex functional tests that involve multiple users and long interaction scenarios. After conducting over 300 audits, our team has found functional tests to be a continuously undervalued security practice. In addition to decreasing risks, testing will also save your team hassle down the road in terms of maintaining code or adding new functionality. And, prioritizing testing can make an impact in other areas: helping your team develop a more security-focused mindset and even improving code quality.

4) Continuous Evolution

The best projects are continuously evolving. Be sure to update documentation as the code changes. Keep in mind that the work doesn’t end at the completion of the audit. Ensure a bounty program is in place, and continue monitoring. Identifying vulnerabilities and bugs is an ongoing process, rather than a one-time occurrence.

While DeFi’s risks cannot be completely eliminated, adhering to best practices and doing your due diligence as a team can help mitigate risk and reduce the likelihood of your protocol being compromised. Being on the bleeding edge of new technology will always come with heightened risks, and as the DeFi space continues to eat traditional finance, auditors and builders alike will need to be vigilant in prioritizing security. A strong offense is the best defense, so taking a proactive approach and staying ahead of the curve will undoubtedly pay off.

DeFi’s Composability: More Possibility, More Risk (2024)

FAQs

What is composability risk? ›

Risks associated with DeFi composability

This is potentially dangerous as the exploitation of a vulnerability within a single smart contract can have a devastating impact on multiple DeFi protocols in the space and your cryptocurrencies. Take the 2021 yearn. finance's DAI vault attack, for instance.

What are the key risks with DeFi? ›

  • 1 Smart contract bugs. One of the main risks of DeFi is that smart contracts may contain bugs or vulnerabilities that can be exploited by malicious actors or cause unintended consequences. ...
  • 2 Protocol changes. ...
  • 3 Liquidity issues. ...
  • 4 Regulatory uncertainty. ...
  • 5 User error. ...
  • 6 Here's what else to consider.
Nov 9, 2023

What is the biggest problem in DeFi? ›

Impermanent loss. Impermanent loss is one of the most common and misunderstood DeFi market risks. When a user provides liquidity, they must deposit two types of assets. As other users buy and sell tokens from the pool, the asset ratios shift, increasing the value of one while lowering the value of the other.

How is composability stacking of innovation affecting the growth of DeFi? ›

The benefits of composability are numerous, driving the development and growth of DeFi: Unleashing Innovation: Composability empowers developers to build new and sophisticated financial products, services, and tools, rapidly expanding the DeFi ecosystem.

What is composable in DeFi? ›

In decentralized finance (DeFi), composability refers to the ability of various apps and protocols to seamlessly communicate with each other, allowing their building blocks to be combined and integrated to create new functionalities or financial services.

Why is composability important? ›

Composability is a design approach that improves application development. It reuses and assembles existing components depending on your business and user's unique needs, making your system more adaptable, agile and reliable. The concept of composable infrastructure is like Lego blocks.

What is the weakness of DeFi? ›

Another major disadvantage of DeFi is the high number of risks associated with it. These include market volatility, smart contract failures, and hacking threats. Moreover, unlike traditional banking systems which offer insurance and consumer protection mechanisms, such safeguards are typically absent in the DeFi space.

Is DeFi worth the risk? ›

Most financial experts categorize DeFi as speculative, recommending only to invest 3-5% of your net worth into crypto.

Is DeFi risk free? ›

DeFi lending is subject to counterparty risk and credit risk, but because lending is automated through the DeFi protocol, rather than individual decisions made by an adviser on behalf of an investor, such risks may be exacerbated, particularly if there are flaws in DeFi protocol's code or operation.

Is DeFi failing? ›

DeFi is still a very new, yet rapidly evolving tech. The industry learned a lot of lessons during the 2020–2023 boom and bust cycles, and the future looks bright for DeFi. Yet, there are still many screaming problems in this space that can hamstring DeFi's short and mid-term growth.

Is DeFi really decentralized? ›

Although a DeFi network cannot be manipulated by a minority of participants, it still remains possible for a majority to 'band together' In fact, far from being decentralised, consensus mechanisms rely on validators (PDF 543KB) who must be incentivised to maintain the transaction ledger.

Why did DeFi fail? ›

The biggest risk in the current DeFi market is not based on mechanistic failures such as those that caused the collapse of Terra, but rather on three key factors: scale, complexity, and interconnectivity.

What is the difference between composability and interoperability? ›

Composability is different from interoperability. Composability is the consistent representation of truth in all participating systems [1]. It extends the ideas of interoperability by adding the pragmatic level to cover what happens within the receiving system based on the received information.

What is composability in Web3? ›

Composability in Web3 refers to the interoperability and integration of various Web3 technologies, including blockchain, decentralized applications (dapps), and decentralized protocols. It enables developers to combine different components to create interconnected systems and services.

What are the risks of DeFi liquidity? ›

Liquidity Provider Risks: Liquidity providers may be exposed to risks like slippage, asset depreciation, and impermanent loss, which can affect their overall returns. Understanding these risks is important before providing liquidity to a pool.

What is an example of composability? ›

Imagine you are building an e-commerce application, for example. A composable architecture would allow you to create reusable components for different parts of the application, such as a product catalogue component, a shopping cart component, and a checkout component.

What are the different types of composability? ›

Composability exists in two forms, syntactic and semantic (also known as engineering and modeling). Syntactic composability is the implementation of components so that they can be eonnected. Semantic composability answers the question of whether the models implemented in the composition can be meaningfully composed.

What is the difference between composability and modularity? ›

The what. The principles of composability and modularity are often interlinked. Modular systems consist of subcomponents with well-defined interfaces and functions that can be consumed independently of each other. Composability is the degree to which these subcomponents can be combined to form more complex systems.

Top Articles
Latest Posts
Article information

Author: Lakeisha Bayer VM

Last Updated:

Views: 6253

Rating: 4.9 / 5 (69 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Lakeisha Bayer VM

Birthday: 1997-10-17

Address: Suite 835 34136 Adrian Mountains, Floydton, UT 81036

Phone: +3571527672278

Job: Manufacturing Agent

Hobby: Skimboarding, Photography, Roller skating, Knife making, Paintball, Embroidery, Gunsmithing

Introduction: My name is Lakeisha Bayer VM, I am a brainy, kind, enchanting, healthy, lovely, clean, witty person who loves writing and wants to share my knowledge and understanding with you.