The rapidly evolving landscape of decentralized finance (DeFi) is full of innovation and promise, yet it continues to pose serious security threats. A couple of weeks ago, ZKsync—one of the most popular Layer-2 scaling solutions on Ethereum—suffered a security exploit. The ramifications of this incident resulted in the loss of about $5 million. This unfortunate incident serves as a cautionary tale that even the best laid protocols can be undermined through vulnerabilities. It underscores the importance of robust security protections. MetaBlock X was created to provide more clarity and direction in the crypto space. This deep dive on the ZKsync hack is full of practical lessons that will help developers and funders alike come out ahead.
This article will analyse the mechanics of the zkSync hack from a technical perspective. It will examine its immediate, market-defining effect and predict what it means for the future of DeFi security at large. Most importantly, it will do so with a practical advice focus. Better guidance will allow DeFi projects to improve their security practices and keep similar incidents from happening in the future. Recognizing these vulnerabilities and taking proactive steps to combat them is key to cultivating a more safe and secure DeFi landscape.
Understanding the ZKsync Hack
The ZKsync hack focused on the exploitation of a function named “sweepUnclaimed” found in three airdrop-related smart contracts. This feature allows the protocol to return any unclaimed tokens after a certain amount of time. Then it gathers these tokens to be used elsewhere. The attacker was able to blatantly abuse this function to their benefit.
The Technical Vulnerability: sweepUnclaimed()
The underlying reason is insufficient access controls around the “sweepUnclaimed” function. The attacker was able to obtain an admin account that had the permissions needed to activate this function. They exploited their access to drain tokens from the misuse contracts. This essentially drained capital that could have gone to actual users or future protocol development. The attacker proactively used this access to mint an additional 111 million ZK tokens.
How the Attack Unfolded
- Compromised Admin Account: The attacker successfully gained control of an administrative account within the ZKsync ecosystem. The specific method of compromise is still under investigation, but it highlights the critical importance of securing administrative privileges.
- Exploitation of sweepUnclaimed(): The attacker leveraged the compromised admin account to call the "sweepUnclaimed" function on the vulnerable airdrop contracts. This allowed them to transfer unclaimed tokens to their own addresses.
- Token Minting: The attacker used the compromised admin account to mint 111 million extra ZK tokens.
Market Impact and Recovery
As shown in the chart below, the short-term result of the ZKsync exploit made for a rather deep dive for ZK token prices. At first, investor confidence was severely shaken, precipitating a general sell-off that caused BitCoin to plummet in value. The token has shown great strength and is recovering from recent all-time highs.
Price Drop and Volume Surge
In fact, right after the breach was made public, the price of ZK tokens fell by about 80%. It dropped from about $0.047 to $0.039. The price decline demonstrates just how fast the market is able to adjust to the announcement. Investors are spooked by the prospect of additional losses and the loss of confidence in the project. At the same time, trading volume skyrocketed as investors scrambled to sell their assets, increasing the downward pressure on prices. Currently, ZKsync is 1.05% higher in the past 24 hours.
Signs of Recovery
Although this news came as a shock to many investors, the ZKsync token quickly began to bounce back. The ZKsync team took immediate action to address the incident. Their commitment to plugging security vulnerabilities and the outstanding power of ZKsync technology made a huge difference in this case. It has not yet fully rebounded to pre-attack levels. Its stabilization and subsequent upward trend is indicative of investors beginning to regain confidence in the longevity of the project.
Lessons for DeFi Security: Strengthening Your Defenses
The ZKsync hack is a reminder of the growing importance and dire consequences that a lack of security can have on the DeFi ecosystem. This section will highlight some concrete steps DeFi projects can take to reduce the risk of exploitation and avoid events like this one.
Enhancing Security Audits and Code Review
Security audits are an invaluable aspect of any DeFi project’s security posture. They must not be considered as discrete events, but instead as part of a continuous process. Continuous code review is essential.
- Implement Continuous Code Review: Regularly conduct internal peer reviews for all code changes before they even reach auditors.
- Use Secure SDLC & Deployment: Strengthen DORA’s requirements for secure system development and resilience testing, and align with ISO 27001 (A.14 — System acquisition, development and maintenance).
Strengthening Administrative Controls
The recent ZKsync hack is a great reminder of the need to secure administrative access. As shown in this major breach, compromised admin accounts can lead to ruinous effects.
- Principle of Least Privilege: Implement the principle of least privilege, granting users only the minimum level of access required to perform their duties.
- Multi-Factor Authentication (MFA): Enforce MFA for all administrative accounts to add an extra layer of security.
- Regular Audits of Access Controls: Conduct regular audits of access controls to identify and address any potential vulnerabilities.
Improving Incident Response Plans
Even if all security measures are perfected, something will happen. Having a well-defined incident response plan is crucial for minimizing the impact of a breach and ensuring a swift recovery.
- Conduct Regular Tabletop Exercises: Simulate realistic DeFi exploit scenarios (e.g., oracle manipulation, governance attack, large flash loan exploit) to test incident response plans.
- Integrate Standard Infrastructure Monitoring Tools: Use tools like Grafana, Prometheus, Datadog, and integrate them with security event information management (SIEM) systems.
- Utilize Secure Secret Management Solutions: Use solutions like HashiCorp Vault, AWS Secrets Manager, or Azure Key Vault, and integrate them into your deployment process.
- Establish Key Partnerships: Engage two critical partners: an incident response firm with deep expertise in blockchain forensics, digital investigations, and crisis management, as well as external legal counsel already familiar with your protocol’s governance and inner workings.
MetaBlock X believes that by implementing these recommendations, DeFi projects can significantly enhance their security posture and protect themselves and their users from potential attacks. The ZKsync hack serves as a valuable lesson, reminding us that security is an ongoing process that requires constant vigilance and adaptation.