We recently announced that an independent team of experts from Solidified audited the Hermez protocol smart contracts and that we're doing more audits to ensure that our network is secure from day one. A second audit is currently underway. A team of experts from Trail of Bits is looking at our smart contracts and checking that the code is solid and safe to use.
We have published our contracts, and soon we'll launch a bug bounty program. We want many people looking at our code to ensure that our product is fast and secure. Let's dive a bit deeper into our security mechanisms.
Low-Fees Transactions for Everyone
One of the main advantages of using the Hermez Network as a L2 solution is the fast finality of the transactions: as soon as the zero knowledge validity proof of the transaction is submitted to the Ethereum chain, the transaction is as final as a L1 transaction.
This is a great feature that returns amazing user experience benefits: users can deposit and withdraw tokens into L2 without additional delays. This benefit implies proper risk management in the early stages of a L2 network.
Enter the Withdrawals Security Mechanism
Hermez will be covering an initial phase of network bootstrapping where some additional security measures are deployed as a good practice for risk management. The main one is the withdrawal security mechanism. You can read the code here.
It's an automated volume limitation on withdrawals that is implemented in the smart contracts as an additional checkpoint to identify the network's anomalous behavior.
This limitation will kick in automatically only when a sudden high volume of funds withdrawal is detected, and the objective is to give the developer team some time to verify the system and determine whether the funds are being withdrawn legitimately, or if the normal behavior has evolved and parameters need to be readjusted.
Users will be prompted to try again after some time or decide to use this delayed withdrawal alternative with a guaranteed time. Hence, tokens will be held by the smart contract for a given period, and only afterward, tokens could be withdrawn.
How Does This Security Mechanism Work?
As explained in our documentation, the Hermez protocol splits time into 5 buckets for transactions of different sizes, and there is a threshold monitoring the amount of funds that can be withdrawn within one given bucket for a period of time. This guarantees that a malicious actor wouldn't be able to illegitimately drain funds quickly.
Let's assume that each bucket represents 1 minute, and you can only withdraw 10 HEZ per bucket. There's Alice, a legit Hermez user, and Bob, a black hat hacker who wants to illegitimately withdraw funds from the smart contract. Alice uses the Hermez app to withdraw 8 HEZ, and she gets her funds instantly.
Bob manages to get hold of some funds and tries to withdraw them, but because the bucket is almost full, those funds are optionally sent to the WithdrawalDelayer contract if the user decides to do so when prompted by the UI. Once there, Hermez devs can check the system and validate that the activity is correct, increasing the threshold limits for the normal operation of the network in a scenario of activity growth.
If the developer team suspects of a malicious activity, the SAFE_MODE can be enabled, which provides more time to analyse the issue, increasing the time of the delayed withdrawal contract. This mode can be reverted.
If it comes to the case when a security breach is confirmed, the next step is the activation of the EMERGENCY_MODE on the withdrawal delayer contract (which acts as an escape hutch) and work on the eventual security fix and upgrade of the code. It is important to notice that Hermez governance would not, at any point, have control over these funds.
After the eventual activation of the EMERGENCY_MODE, the developer team will work in parallel in the fix, and the custody of the funds inside the delayer contract will go to a specific external group of reputed community members, the Emergency Council.
These members (some of them White Hat hackers) will own the custodial multisig in temporary control of the funds. They will have the responsibility to start a process of redirection of funds to their rightful owners.
The Road to Decentralization
Our network has been developed with security in mind and externally audited. For this reason, we hope we don't ever have to activate the EMERGENCY_MODE. In any case, this is a mechanism that will be disabled once the network has been bootstrapped and passed the initial battle-testing.
The objective of the Hermez network is to follow a gradual path towards becoming fully decentralized to provide stability and security to the system.
Some of the technologies developed and implemented are experimental, and there is a learning curve that needs to be managed, as this kind of high throughput network has never been deployed before.
Hermez has a responsible approach, learning from past experiences, and getting our product ready for the market from day one. We aim to find the right balance between security and decentralization, and we want to invite everyone to help us in this adventure.
You can help by auditing the smart contracts yourself. Soon we'll publish the conditions of the bug bounty rewards.