According to US Attorney Damian Williams, Shakeeb Ahmed was the first person that was ever convicted of hacking a smart contract.
In July 2022, Shakeeb Ahmed Nirvana hack, a former Amazon engineer, was sentenced to three years for hacking and exploiting smart contract flaws and stealing $12 million in cryptocurrency from the DeFi platform called Nirvana Finance, which collapsed following the hack. He was also associated with hacking Crema Finance, which was considered his first hack earlier in the same month, but he was not prosecuted for it.
The Hacks, Bug Bounty, and Flash Loans
The Shakeeb Ahmed Nirvana hack ended up on the Law Enforcement radar because Ahmed and Nirvana did not reach an agreement on the amount of “bug bounty,” but it was not his only hack in July 2022. The first hack against an unnamed DeFi exchange, rumored to be Crema Finance, was not part of the case against Ahmed because the victim agreed on the bug bounty.
What is a Bug Bounty?
A bug bounty is a monetary reward to ethical hackers for successfully discovering and reporting a vulnerability or bug to the application’s developer. Bug bounty programs allow companies to leverage the hacker community to improve their systems’ security. Occasionally, attackers use it as an excuse to convince the victim not to report a cybercrime to the police by offering to give back the money they took minus a ‘fee.’ It is an illegal practice only if the agreement does not predate the hack; in other words, the practice is not an excuse to profit from a criminal act in any shape or form.
How does it apply to Shakeeb Ahmed hacks?
In early July 2022, Shakeeb Ahmed an attack on a decentralized cryptocurrency exchange. The exchange was not named, but later, it was matched to an attack against Crema Finance roughly at the same time. He used fake pricing data to generate inflated fees worth about $9 million and withdrew those fees for cryptocurrency. Once he had completed the heist, he contacted the cryptocurrency exchange, offering to return most of the stolen funds, keeping $1.5 million, provided the exchange did not inform law enforcement. The exchange agreed.
Later the same month, Ahmed took out a flash loan for approximately USD 10 million and used those funds to purchase ANA from Nirvana, another decentralized cryptocurrency exchange. He exploited a vulnerability he discovered in Nirvana’s smart contracts to buy cryptocurrency from Nirvana at a price lower than the one Nirvana should have charged him in light of the size of his purchase. When the price of ANA was updated to reflect his large purchase, Ahmed resold the ANA to Nirvana at the higher price. Then, Ahmed used the tactic he had previously employed to negotiate a bug bounty to return the stolen funds. Nirvana offered $600,000, but he demanded $1.4 million. They did not reach an agreement, so he kept all the stolen funds. Shakeeb Ahmed Nirvana Hack netted him $3.6 million, forcing Nirvana to shut down shortly after the attack for lack of funds.
He laundered the millions that he stole from the Crypto Exchange and from Nirvana to conceal their source and ownership, using sophisticated techniques including token-swap transactions, “bridging” fraud proceeds from the Solana blockchain over to the Ethereum blockchain, exchanging fraud proceeds into Monero, an anonymized cryptocurrency that is particularly difficult to trace; using overseas cryptocurrency exchanges; and using cryptocurrency mixers, such as Samourai Whirlpool.
The legitimate and illegitimate use of Flash Loans.
A flash loan is a relatively new type of loan taken on a blockchain network such as Ethereum. It doesn’t use collateral upfront but charges a transaction fee when the borrowed assets are returned. A loan without collateral may not make much sense in a traditional financial system, but due to the atomic nature of blockchain transactions, these loans offer little risk to lenders. If the borrower does not repay the loan by the end of a transaction, the lender can revert the transaction thanks to the validation and consensus process that the blockchain network provides.
Flash Loans were introduced in 2018 by the Marble Protocol and became very popular with traders looking to profit from arbitrage opportunities between decentralized exchanges. Now, they are offered by many DeFi platforms supporting a wide range of different assets.
Unfortunately, access to extremely cheap liquidity isn’t only used by good-faith actors. The invention of flash loans also gave rise to flash loan “attacks”. Flash loan attacks use flash loans to exploit smart contract bugs or manipulate cryptocurrency asset prices on an exchange (for instance, “wash trading”). They are a bit of a misnomer since they aren’t attacks by themselves; they are used to augment the impact of another form of malicious behaviour and maximize profit for an attacker.
The First Flash Loan Attack
The first significant flash loan attack occurred in 2020 against the bZx lending pool. bZx had just announced Fulcrum the year prior, a new tokenized loan and margin platform powered by their existing protocol. Exploiting a vulnerability in one of bZx’s smart contracts allowed an attacker to open a significant under-collateralized short position on Fulcrum with a flash loan. The position was short ETH in favor of wrapped Bitcoin.
The contract should have calculated the actual value of the position’s collateral by taking into consideration price slippage and checking for a potential liquidation event; still, it never did due to a bug in the logic. Instead, the attacker’s actions forced bZx to purchase 112 wBTC on the Uniswap decentralized exchange, which triggered such a large slippage that the order ended up costing roughly 3x the market price. The price differential created an artificial arbitrage opportunity the attacker exploited within the same transaction. As a result, the attacker made a profit of $370,000, while bZx suffered a loss of $620,000.
Preventing Flash Loan Attacks
Flash loans have augmented the potential impact of smart contract hacks. The quality of the code is the first line of defence; it is essential to follow secure coding best practices and implement smart contract patterns such as upgradability and versioning, circuit breakers, and rate limiting. It is also crucial to test smart contracts thoroughly and regularly perform vulnerability assessments. What this looks like in practice is keeping up to date with vulnerability trends, maintaining detailed documentation, writing tests, performing static analysis and fuzzing, and formally verifying critical functionality. Last but not least, it is crucial to have security experts audit your smart contracts on a regular basis to identify possible critical vulnerabilities.
Legal case, sentencing, punishment
What were the consequences of the Shakeeb Ahmed Nirvana Hack?
The Office of Illicit Finance and Money Laundering Unit and Complex Frauds and Cybercrime Unit prosecuted the case.
At the time of both attacks, Ahmed, a US citizen, was a senior security engineer for an international technology company. Sources outside the official FBI documentation state he was working for Amazon. His resume reflected skills in, among other things, reverse engineering smart contracts and blockchain audits, which are some of the specialized skills he used to execute the hacks.
Ahmed, 34 at the time of the process against him, previously pled guilty to computer fraud. He was sentenced to three years in prison for hacking two separate decentralized cryptocurrency exchanges and stealing cryptocurrency worth over $12 million. He was also sentenced to three years of supervised release and ordered to surrender approximately $12.3 million and a significant quantity of cryptocurrency and pay restitution to the Crypto Exchange and Nirvana of over $5 million.
Other Smart Contract Hacks
The bZx hack was the first known flash loan attack, but it was not the first time somebody hacked a smart contract. In the past 10 years, there have been several smart contract hacks. Almost all of them did not lead to charges or indictments.
The Dao Hack
One of the goals of the Decentralized Autonomous Organization, or DAO, was to establish a community-managed investment fund to support projects within the cryptocurrency and decentralized technology sectors. One of the first application of a DAO was a venture capital fund; its decentralized architecture was designed to cut expenses while giving investors more power and access. They called the project “The DAO”, because they relied on the collective judgment of its investors to run it decentralized.
The DAO was a smart contract on the Ethereum blockchain; on June 17, 2016, a hacker found a flaw that allowed the attacker to ask the contract to send money to them repeatedly, leading to the theft of 3.6 million ETH, valued at about $70 million at the time. A mechanism that first transmitted the ETH and then modified the internal token balance was not designed to account for the possibility of repeated calls. The hacker exploited this flaw to steal the ETH.
The DAO hack remains a significant event in cryptocurrency history, raising important questions about the nature of smart contracts, developers’ responsibilities, and decentralized organizations’ legal status.
Was the hacker ever found?
In 2022, investigative journalist Laura Shin claimed to have uncovered the individual’s identity behind the 2016 DAO hack. She worked with the blockchain analytics company Chainanlysis and identified the alleged hacker as Toby Henish, a co-founder of the blockchain startup TenX. The hacker allegedly used the Wasabi privacy wallet to launder the proceedings of the hack, which were sent to four different exchanges and swapped for a privacy coin called Grin.
Henish denied involvement in the hack and refuted the accusations made in Forbes’ report. No formal charges have been filed, and the case remains in a legal grey area. While no formal indictment has been issued, the case continues to be studied and debated within the crypto community and legal circles.
The Veritaseum hack
A cryptocurrency called Veritaseum was introduced in 2017. A cyberattack at Veritaseum in April 2018 cost the company $8.4 million in cryptocurrencies.
A hacker siphoned money from the Veritaseum smart contract using a reentrancy attack, i.e., running a smart contract’s function repeatedly before the state of the contract is changed, therefore allowing the attacker to remove money from the contract before the state is updated to reflect the withdrawal.
The Veritaseum attack emphasized the necessity of rigorous testing and auditing of smart contracts to make sure they are safe and without flaws.
Was the hacker ever found?
The Security Exchange Committee investigated Veritaseum for alleged fraudulent activities in the token offering and manipulating token prices; no law enforcement agency investigated the hack.
The Bancor hack
Bancor network is a decentralized exchange that enables users to purchase and sell various cryptocurrencies; the network uses the Ethereum blockchain. The Bancor network was hacked in July 2018, and as a result, the attacker stole about $23.5million worth of cryptocurrency, including:
· 24,984 Ether (ETH) (~$12.5 million)
· 229,356,645 Pundi X (NPXS) tokens (~$1 million)
· 3,200,000 Bancor (BNT) tokens (~$10 million
The attacker exploited a vulnerability in the smart contract that controlled the Bancor network to steal money. The Bancor team reacted to the attack promptly and halted trading on the site to stop more losses.
The Bancor attack served as a reminder of the value of adequately protecting smart contracts and the possible dangers of employing them. It also emphasized the necessity of rigorous testing and auditing of smart contracts to make sure they are safe and without flaws.
Was the hacker ever found?
There are mentions of an investigation; however, there is no specific information about any indictments or arrests related to this hack. It’s possible that the investigation is ongoing or that no suspects have been formally charged.
The Harvest Finance hack
The Harvest Finance hack was a security issue that happened in October 2020. An attacker used a smart contract weakness to steal about $24 million in cryptocurrencies. A decentralized finance (DeFi) technology called Harvest Finance enables users to generate yield by supplying liquidity to various financial marketplaces.
The hack happened when a perpetrator drained funds from the Harvest Finance smart contract by exploiting a vulnerability. The attacker could alter the contract and withdraw money without setting off the security features. The Harvest Finance team was able to stop trading on the platform to stop more losses after the hack was identified many hours after it happened.
Some of the stolen funds, primarily in USDC and USDT, were traced to exchanges like Binance, Huobi, and Kraken, while others were sent to mixing services like Wasabi wallet
Was the hacker ever found?
Harvest Finance appealed directly to the attacker, asking them to return the funds and stating they had no interest in “doxxing” or taking legal action against the hacker. Shortly after the attack, the hacker voluntarily returned approximately $2.5 million to Harvest Finance, though the reason for this partial return remains unclear.
Despite the significant financial loss and the company’s claims of having information about the attacker, there is no indication that any formal legal action, indictment, or arrest has taken place in connection with this hack. The focus seems to have been on recovering the funds rather than pursuing criminal charges.
The Akropolis hack
The Akropolis decentralized finance (DeFi) platform was attacked on November 12, 2020, when a protocol flaw resulted in the loss of about 2,030,841.0177 DAI from the impacted YCurve and sUSD pools. The problem was caused by a bug in the platform’s SavingsModule smart contract’s handling of the deposit logic, which allowed the attacker to create a significant number of pool tokens without the support of valued assets because the protocol did not correctly impose reentrancy protection on the deposit logic and validate supported tokens. Users of the Akropolis platform experienced severe disruption and losses due to the Smart Contract Hacks.
Before the attack, Akropolis had undergone two security audits performed by two different security groups; however, they missed two attack vectors, and this oversight allowed the hack to occur
Was the hacker ever found?
The exact identity of the hacker remains unknown; the incident involved the Akropolis development team, security auditors, and the broader DeFi community in its aftermath and analysis.
Issues and complexities in investigating hacks.
The decentralized and often anonymous nature of smart contract hacks can make it challenging to pursue legal action, especially when the attacks exploit vulnerabilities or engage in market manipulation rather than traditional hacking methods.
Several factors complicate potential legal action:
· Jurisdictional issue – Often, even after the technical investigation has been completed and the attacker(s) identified, it is complicated to establish who has jurisdiction and which law enforcement agency should pursue the case, make the arrest, and take it to court. The Nirvana hack was taken to court because the perpetrator was in the US, and the law enforcement agencies were in the US.
· Legal ambiguity – Sometimes, there are questions about whether the attack was an actual hack or whether the perpetrator used a feature of the specific smart contract.
· Damages – Occasionally, victims of smart contract attacks recover the funds, or at least some of them. In some examples mentioned above, the funds were recovered using technology or because the attacker returned the bulk of the funds minus some form of ‘bug bounty’. Shakeeb Ahmed Nirvana hack was the first case that resulted in an arrest, prosecution, and sentence. The perpetrator pleaded guilty to computer fraud, but the court condemned him for the smart attack.
· Statute of limitations – The examples shown above show that sometimes the investigation lasts long enough to affect the ability to press charges.
Prevention is better than the cure.
Smart contracts are capable of handling large quantities of value and a variety of financial activities. If a smart contract is not adequately secured, it may cause consumers to suffer significant losses and jeopardize the project’s legitimacy and dependability.
Testing and auditing are essential to make smart contracts secure; they are a critical part of the creation process, but ensuring the smooth operation and safeguarding of the operation of a blockchain project should not be limited to the creation of the smart contract. It must be a continuous process; some vulnerabilities may not be detected during testing because testing scenarios may not have highlighted potential rogue behavior. Prevention is the best defense, but prevention implies periodical testing and auditing.
The Nirvana hack led to a conviction because investigators found the culprit reasonably quickly, and he was based in the same legal jurisdiction as the law enforcement agencies responsible for taking the case to court. The complexity reaffirms that prevention is better and easier than prosecution, where smart contract hacks are concerned.