[Twitter threads] DeFi hacks are rampant; how can you avoid becoming the next victim?

This article is machine translated
Show original

Chainfeeds Summary:

We must use the same tools as attackers, conduct red teaming tests on the protocol, continuously monitor it, and set hard limits on potential losses in order to survive in the worst-case scenario.

Article source:

https://x.com/systematicls/status/2048756004972855667

Article Author:

sysls


Opinion:

sysls: Once you identify invariants, elevate them to runtime checks. Carefully consider which invariants are actually executable. This is the FREI-PI (Function Requirements, Effects, Interactions, Protocol Invariants) pattern: at the end of every function involving value, re-verify the core invariants that the function is committed to maintaining. Many attacks that can pass CEI (Checks-Effects-Interactions) (such as flash loan pincer attacks, oracle-assisted liquidation attacks, and cross-function solvency draining) are caught in invariant checks at the end of functions. Stateful fuzzing constructs a randomized sequence of calls over the complete public interface of the protocol and asserts invariants at each step. Most attacks in production environments are multi-transaction, and stateful fuzzing is almost the only reliable way to discover these paths before attackers. Using invariant testing, verify that a property holds for any sequence of calls generated by the fuzzing. Combined with formal verification, it can prove that the property holds in all reachable states. Your core invariants should absolutely be verified at this level. Complexity is the enemy of security. Every external dependency expands the attack surface. If you're designing infrastructure, you should leave the choice of "who to trust" to the user. If dependencies cannot be removed, diversify them to prevent single points of failure from destroying the protocol. Extend your audit scope to simulate how these dependencies could fail and rate-limit the maximum damage they could cause. The recent KelpDAO attack is an example: they inherited LayerZero's default configuration requiredDVNCount=1, which existed outside the audit scope. Ultimately, the off-chain infrastructure outside the audit scope was compromised. Most attack surfaces in DeFi have already been enumerated. Examine each category one by one, ask yourself if it applies to your protocol, and implement corresponding controls. Build red team capabilities, allowing your AI agent to proactively find vulnerabilities in the protocol—this is already a basic requirement at this stage. In voting-based governance, power is initially concentrated in team multisignature and takes time to distribute. Even with widespread token distribution, delegation is often concentrated in a few wallets (sometimes even just one). Once these are compromised, it's over. Deploy "guardian wallets" with strictly limited permissions: they can only pause the protocol and, in extreme cases (≥4/7), replace compromised delegations with predefined wallets. Guardians can never execute governance proposals. This provides a rescue layer that can restore system stability without overturning governance. This layer can be gradually removed as governance matures and becomes decentralized.

Content source

https://chainfeeds.substack.com

Source
Disclaimer: The content above is only the author's opinion which does not represent any position of Followin, and is not intended as, and shall not be understood or construed as, investment advice from Followin.
Like
Add to Favorites
Comments