DeFi protocols must move beyond “patch-after-the-hack” security and hard-code safety guarantees into their software if the $168 billion sector is to mature, accordingDeFi protocols must move beyond “patch-after-the-hack” security and hard-code safety guarantees into their software if the $168 billion sector is to mature, according

A16z Crypto wants DeFi to ditch ‘code is law’ for ‘spec is law’ to combat $649m exploit problem

DeFi protocols must move beyond “patch-after-the-hack” security and hard-code safety guarantees into their software if the $168 billion sector is to mature, according to a16z Crypto.

In a January 11 post, Daejun Park, a senior security researcher at the firm, argued that DeFi developers should adopt a more principled approach to security instead of relying on trial and error.

At the core of that shift, Park said, is the use of standardised specifications that constrain what a protocol is allowed to do, and automatically revert any transaction that violates those predefined assumptions about correct behaviour.

“Almost every exploit to date would have tripped one of these checks during execution, potentially halting the hack,” Park said. “So the once-popular idea of ‘code is law’ evolves into ‘spec is law.’”

Such an idea, sometimes referred to as runtime enforcement or invariant checks, isn’t new. But it’s getting a fresh look as DeFi protocols struggle to defend against hackers exploiting bugs in their code.

Last year, hackers swiped over $649 million through code exploits according to a report from Slowmist, a blockchain security firm.

Even battle-tested protocols like Balancer, whose code had been live on the Ethereum blockchain since 2021, were not immune. It lost $128 million in November after a hacker exploited a code bug.

In recent months, DeFi developers fear hackers are increasingly using artificial intelligence to find DeFi protocol vulnerabilities and exploit them.

‘Not the silver bullet’

Park’s suggestions, if widely adopted, could go a long way in preventing exploits. But they’re not without downsides.

DeFi protocols often gain an edge over their competitors by having the cheapest fees. Adding extra checks on transactions would increase gas costs, potentially losing them users, Gonçalo Magalhães, head of security at Immunefi, told DL News.

Magalhães said invariant checks are a great security strategy, but they can’t account for everything — especially exploits that a protocol’s developers can’t reasonably anticipate. “It’s not the silver bullet,” he said.

It’s also tricky to get the checks to work properly, Felix Wilhelm, co-founder of Asymmetric Research, a crypto security firm, told DL News.

“For many vulnerabilities and real-life hacks, it is difficult or even impossible to write an invariant that detects the hack without also triggering under normal circumstances,” he said.

Wilhelm said runtime enforcement is an important part of protocol security. But it is typically used to detect anomalies, like an unusual flow of funds in a short timeframe.

“While helpful, this often serves only to limit impact or alert the team, rather than stopping the attack outright,” he said.

Many protocols are already adopting invariant checks.

Kamino, a Solana-based lending protocol, began checking for critical invariants using Certora Prover in March last year.

The XRP Ledger, the blockchain behind the $120 billion XRP token, has also implemented invariant checking. The blockchain’s developers said the checks are necessary because XRP Ledger is complicated, and there is a high potential for code to execute incorrectly.

“Invariants should not trigger, but they ensure the XRP Ledger’s integrity from bugs yet to be discovered or even created,” XRP Ledger developers said.

Tim Craig is DL News’ Edinburgh-based DeFi Correspondent. Reach out with tips at tim@dlnews.com.

Market Opportunity
DeFi Logo
DeFi Price(DEFI)
$0,0005
$0,0005$0,0005
-1,76%
USD
DeFi (DEFI) Live Price Chart
Disclaimer: The articles reposted on this site are sourced from public platforms and are provided for informational purposes only. They do not necessarily reflect the views of MEXC. All rights remain with the original authors. If you believe any content infringes on third-party rights, please contact service@support.mexc.com for removal. MEXC makes no guarantees regarding the accuracy, completeness, or timeliness of the content and is not responsible for any actions taken based on the information provided. The content does not constitute financial, legal, or other professional advice, nor should it be considered a recommendation or endorsement by MEXC.

You May Also Like

China Launches Cross-Border QR Code Payment Trial

China Launches Cross-Border QR Code Payment Trial

The post China Launches Cross-Border QR Code Payment Trial appeared on BitcoinEthereumNews.com. Key Points: Main event involves China initiating a cross-border QR code payment trial. Alipay and Ant International are key participants. Impact on financial security and regulatory focus on illicit finance. China’s central bank, led by Deputy Governor Lu Lei, initiated a trial of a unified cross-border QR code payment gateway with Alipay and Ant International as participants. This pilot addresses cross-border fund risks, aiming to enhance financial security amid rising money laundering through digital channels, despite muted crypto market reactions. China’s Cross-Border Payment Gateway Trial with Alipay The trial operation of a unified cross-border QR code payment gateway marks a milestone in China’s financial landscape. Prominent entities such as Alipay and Ant International are at the forefront, participating as the initial institutions in this venture. Lu Lei, Deputy Governor of the People’s Bank of China, highlighted the systemic risks posed by increased cross-border fund flows. Changes are expected in the dynamics of digital transactions, potentially enhancing transaction efficiency while tightening regulations around illicit finance. The initiative underscores China’s commitment to bolstering financial security amidst growing global fund movements. “The scale of cross-border fund flows is expanding, and the frequency is accelerating, providing opportunities for risks such as cross-border money laundering and terrorist financing. Some overseas illegal platforms transfer funds through channels such as virtual currencies and underground banks, creating a ‘resonance’ of risks at home and abroad, posing a challenge to China’s foreign exchange management and financial security.” — Lu Lei, Deputy Governor, People’s Bank of China Bitcoin and Impact of China’s Financial Initiatives Did you know? China’s latest initiative echoes the Payment Connect project of June 2025, furthering real-time cross-boundary remittances and expanding its influence on global financial systems. As of September 17, 2025, Bitcoin (BTC) stands at $115,748.72 with a market cap of $2.31 trillion, showing a 0.97%…
Share
BitcoinEthereumNews2025/09/18 05:28
Gold hits yet another new all-time high of $4,740 as Bitcoin crashes to $91,000

Gold hits yet another new all-time high of $4,740 as Bitcoin crashes to $91,000

The post Gold hits yet another new all-time high of $4,740 as Bitcoin crashes to $91,000 appeared on BitcoinEthereumNews.com. Gold futures pushed to a new all time
Share
BitcoinEthereumNews2026/01/20 14:04
Goddess of Wealth Jailed for $7.2 Billion Crypto Scam Targeting Thousands

Goddess of Wealth Jailed for $7.2 Billion Crypto Scam Targeting Thousands

Zhimin Qian jailed in UK for $7.2B crypto scam targeting 128,000 victims; 61,000 Bitcoin seized in record-breaking operation. Zhimin Qian, also known as Yadi Zhang
Share
LiveBitcoinNews2026/01/20 14:00