@apedeveloper ChartEx Github Private Key Extraction
Notice: This page is a freshly imported case study from the original repository. The original content was in a different format, and may not have relevant information for all sections. Please help restructure the content by moving information from the 'About' and 'General Prevention' sections to other sections, and add any missing information or sources you can find. If you are new here, please read General Tutorial on Wikis or Anatomy of a Case Study for help getting started.
Notice: This page contains sources which are not attributed to any text. The unattributed sources follow the initial description. Please assist by visiting each source, reviewing the content, and placing that reference next to any text it can be used to support. Feel free to add any information that you come across which isn't present already. Sources which don't contain any relevant information can be removed. Broken links can be replaced with versions from the Internet Archive. See General Tutorial on Wikis, Anatomy of a Case Study, and/or Citing Your Sources Guide for additional information. Thanks for your help!
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.
This is a global/international case not involving a specific country.[1][2][3][4][5]
About None
"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...??"
This is a global/international case not involving a specific country.
The background of the exchange platform, service, or individuals involved, as it would have been seen or understood at the time of the events.
Include:
- Known history of when and how the service was started.
- What problems does the company or service claim to solve?
- What marketing materials were used by the firm or business?
- Audits performed, and excerpts that may have been included.
- Business registration documents shown (fake or legitimate).
- How were people recruited to participate?
- Public warnings and announcements prior to the event.
Don't Include:
- Any wording which directly states or implies that the business is/was illegitimate, or that a vulnerability existed.
- Anything that wasn't reasonably knowable at the time of the event.
There could be more than one section here. If the same platform is involved with multiple incidents, then it can be linked to a main article page.
The Reality
This sections is included if a case involved deception or information that was unknown at the time. Examples include:
- When the service was actually started (if different than the "official story").
- Who actually ran a service and their own personal history.
- How the service was structured behind the scenes. (For example, there was no "trading bot".)
- Details of what audits reported and how vulnerabilities were missed during auditing.
What Happened
The specific events of the loss and how it came about. What actually happened to cause the loss and some of the events leading up to it.
| Date | Event | Description |
|---|---|---|
| February 19th, 2021 6:09:00 PM MST | Main Event | Expand this into a brief description of what happened and the impact. If multiple lines are necessary, add them here. |
Technical Details
This section includes specific detailed technical analysis of any security breaches which happened. What specific software vulnerabilities contributed to the problem and how were they exploited?
Total Amount Lost
The total amount lost is unknown.
How much was lost and how was it calculated? If there are conflicting reports, which are accurate and where does the discrepancy lie?
Immediate Reactions
How did the various parties involved (firm, platform, management, and/or affected individual(s)) deal with the events? Were services shut down? Were announcements made? Were groups formed?
Ultimate Outcome
What was the end result? Was any investigation done? Were any individuals prosecuted? Was there a lawsuit? Was any tracing done?
Total Amount Recovered
The total amount recovered is unknown.
What funds were recovered? What funds were reimbursed for those affected users?
Ongoing Developments
What parts of this case are still remaining to be concluded?
General Prevention Policies
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.
Individual Prevention Policies
No specific policies for individual prevention have yet been identified in this case.
For the full list of how to protect your funds as an individual, check our Prevention Policies for Individuals guide.
Platform Prevention Policies
Policies for platforms to take to prevent this situation have not yet been selected in this case.
For the full list of how to protect your funds as a financial service, check our Prevention Policies for Platforms guide.
Regulatory Prevention Policies
No specific regulatory policies have yet been identified in this case.
For the full list of regulatory policies that can prevent loss, check our Prevention Policies for Regulators guide.
References
- ↑ Flashbots Transparency Report March 2021 (Jul 23, 2022)
- ↑ Enter the Dark Forest: the terrifying world of MEV and Flash bots - YouTube (Dec 13, 2022)
- ↑ Ethereum is a Dark Forest - Dan Robinson - Medium (Dec 13, 2022)
- ↑ apedeveloper · GitHub (Dec 13, 2022)
- ↑ Address 0x4469ae0312a05e334198bacfd38fda3d4e6c87af | Etherscan (Dec 13, 2022)