"I made a liquidation bot and it was a private, g- a private GitHub repo, and I was just cleaning up my GitHub, trying to make stuff public like "ahh, some other people might be able to use that". And, well, no one used it, except the hacker to get my private key from there. Because I didn't realize my private key was on there."


"I didn't know that, that, like there are multiple crawlers out there that just crawl GitHub and other - Stack Overflow, and other websites, where there might be code, including private keys. And just crawl and get the private keys."


"I was "hacked" [on February 19th]. A bot gained access of my private keys, because I was being [dumb]. The bot sniped my address for any ETH that came in and transferred tokens to his own address." "[H]ow I got hacked was pretty stupid. I just left my private key on GitHub. Some crawler found it, and he had had my private key so."


"Good thing we build the quickest listeners in the game at @ChartExPro." "I already lost like half of my tokens. But for some reason, it left also half of the tokens in."


"And then, the first thing that I tried was getting my, getting Ethereum into the wallet, to trying to get my tokens out. I didn't realize that it would instantly snipe the Ethereum." "[T]hose same bots are extremely quick in getting out the Ethereum. So, as soon as I send in Ethereum, the split second that it arrived, it was already out."


"You had your wallet compromised, and then by some kind of weird miracle of - I don't know what - you managed to front-run the hacker. So tell me, wh-what happened there, and how were you able to, to do that? Because it sounds like science fiction to me."


"I was able to build a frontrunner quite quickly. Unstaked and transferred all of my tokens to a sa[f]e address."


"I, basically I just just had Ethereum in one wallet. I sent a transaction to send the Ethereum to my hacked wallet. I sent a transaction right after that, from the hacked wallet, with a nonce that, like, was the next transaction basically, so it couldn't override the nonce. And then I used up all the Ethereum that was in my wallet so it could never override my gas price, meaning that my transaction was the most profitable for the miners. And that's why it would be included in the block, instead of an overwritten transaction from the hacker."


"I'm going to demonstrate how to get your tokens from a compromised wallet to an uncompromised wallet using this Flashbots GitHub repo right here. So, uh, I have this wallet right here, which holds 50 ChartEx tokens, and a bit of Ethereum, but not enough Ethereum to make a transaction to send away those ChartEx tokens. And a bot also has my private key, so it's been compromised. So if I would send in Ethereum, it would instantly get sniped to transfer all my ChartEx tokens. That would bew, lose both my ChartEx tokens and my Ethereum. So what I'm going to do instead is I'm going to send a transaction from here to transfer those tokens, that ChartEx tokens, to a different wallet. Then I'm going to send a second transaction from here, which will pay for the gas fees for the first transaction. And I'm going to bundle these two transactions together, and I'm going to send them to a FlashBots gethn-gasnet. And, once it's mined, it should, I should safely receive my ChartEx tokens in here. So, I've cloned this GitHub repo that takes care of all that to my local computer. And I am going to run it from here, and let's see what happens."


"And as you can see, it worked. So, the ChartEx tokens got transfered to this wallet, which is this one, our safe wallet. And we paid zero in gas fees. And then our second wallet, this one, paid everything, paid all the gas fees, also actually paid zero gas fees, but just bribed the node. It interacted with the Flashbots, uhh, smart contract, and we saved the ChartEx tokens. So, you can apply this technique to basically any crypto asset that's transferable. So you can save your ERC20s, you can save your NFTs, but you could also make custom code to save your tokens that are stored in a Yearn vault, or something else."


"[H]appens to the best of us right...??"

In early 2021, while cleaning up their Github repositories, "apedeveloper" publicized a repository which included their current private key to a wallet with funds. On February 19th, 2021, they were alerted that their wallet was emptying out through their own ChartEx tool they had developed. While all of their Ethereum and roughly half of their tokens were taken, some tokens were left in the wallet, but couldn't be moved due to there being no Ethereum left in the wallet. This was a stalemate because any Ethereum added to the wallet was being instantly removed by the attacker.


Their solution to recover those remaining tokens involved using Flashbots, a new technology at the time that allows running transactions without paying gas fees. In this way, they could bribe mining nodes on the Ethereum blockchain to run their transactions to move the assets out of the wallets, even though they didn't spend any gas fees. The miners were paid directly with Ethereum on the side, which never needed to enter the compromised wallet.


It is unclear how much was lost in the original attack or if any action was taken toward recovery of any additional funds.


The primary issue was publishing the private key on GitHub. Even if apedeveloper had left that repository private, storing a private key on a third party service is not secure and could allow the private key to be visible to GitHub staff or any third party that was able to compromise the GitHub account or the computer it was being used from.


The best practice when developing smart contracts is to use a testnet, a free version of the blockchain which uses cheap tokens with no market value. Since the tokens have no market value, there is little risk or impact if they get taken during the development process, and testnets can perform almost all functions of a full chain. Be sure to use a different wallet/private key for the testnet as compared to your normal wallet.


If interaction with smart contracts becomes necessary, for example during very late-stage development to test the final smart contract, it is recommended that a different wallet be used from the normal wallet, and that funds not remain in the wallet afterward. The majority of funds should be stored and remain fully offline whenever possible.


Check Our Framework For Safe Secure Exchange Platforms

Sources And Further Reading

 For questions or enquiries, email info@quadrigainitiative.com.

Get Social

  • email
  • reddit
  • telegram
  • Twitter

© 2021 Quadriga Initiative. Your use of this site/service accepts the Terms of Use and Privacy Policy. This site is not associated with Ernst & Young, Miller Thompson, or the Official Committee of Affected Users. Hosted in Canada by HosterBox.