7 ms·
Finding a Creature in Ethereum's Dark Forest
- thmorriss 5y agoThis was fun
- pcthrowaway 5y agoIf you enjoyed this, you might also like the (much more technical) writeup of the Ethereum pinball machine - https://medium.com/@kanewallmann_71759/an-untrustworthy-pinball-machine-d9dcd07882c https://medium.com/@kanewallmann_71759/an-untrustworthy-pinb... It may assume some knowledge of things like etherscan and the EVM though.
- stavros 5y agoThis is very interesting, thanks! It reminds me of a friend's adventure, he found a contract containing some ETH that could be called with some more ETH and would send the entire sum back to the caller. He analyzed it a bunch of ways to make sure it wasn't a scam, and then sent some ETH to it. It was a scam. I wonder how it was done, Etherscan didn't show anything and compiling it led to a few bytes of difference between what was compiled and what was deployed.
- leppr 5y agoInteresting, it might use a flaw in the Etherescan contract verification[1]. But in any case, when you expect a honeypot you can and should execute the contract off-chain[2] and examine the resulting state (specifically your account balances) before committing a real transaction. Wallets should really do this by default, but unfortunately there doesn't seem to be a lot of resources available for common goods projects like wallets, so we are stuck with primitive tools. [1]: Like this Unicode RLO exploit for instance: https://krebsonsecurity.com/2021/11/trojan-source-bug-threatens-the-security-of-all-code https://krebsonsecurity.com/2021/11/trojan-source-bug-threat... [2]: https://tenderly.co https://tenderly.co or mainnet forking using hardhat are convenient ways to achieve this.
- stavros 5y agoThat's a great tip, thanks! I will relay it, as I don't know much about Ethereum. Can you download and redeploy the compiled contract?
- leppr 5y agoYes, you can always clone and redeploy any contract with its raw EVM code.
- stavros 5y agoThank you for this tip, which is very concretely worth 1 ETH.
- pcthrowaway 5y agoThis might be the same bug reported and fixed in the Ethereum pinball article I shared
- stavros 5y agoYeah, definitely sounds very similar, at least.
- Aramgutang 5y agoThere are so many clever ways to code honeypots using obscure peculiarities of Solidity and/or Etherscan that there's little hope of being sure that it isn't a scam just by looking at the code and transaction history. Fortunately, there are tools like Ganache, which you can run with `ganache-cli --fork` to reliably emulate locally what will happen when transactions are sent to mainnet. I would accept no substitute approach when dealing with suspect contracts.
- stavros 5y agoOh huh, I didn't know Ganache could do that, thank you!
- geek_at 5y agoGood read, thanks! This just reinforces the saying "all crypto currencies have built-in bug bounty programs"
- andygmb 5y agoBug bounties paid for by the users :(
- pjc50 5y agoWell, yes. If you're not willing to lose 100% of your investment to any security hole that may be discovered anywhere in the entire stack of software running on any machine from which you access your crypto account, you shouldn't invest in crypto.
- tlholaday 5y agoArguably, bug bounties are always paid for by users. A vendor might write the bounty-winner’s check, but the source of the vendor’s funds is the vendor’s customers.
- BobbyJo 5y ago'The users' vs 'A user'. The difference between everyone recognizing a 0.05% loss, and 20 people jumping off buildings every year.
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]
- Jerrrry 5y agoThis was a brilliant read on a technically taboo subject
- gerikson 5y agoWhy is this subject "technically taboo"?
- yob28 5y ago
- zwkrt 5y agoSaying things about blockchain technologies that paint them in a bad light is taboo for people making money (or imagining making money) on them.
- MildlySerious 5y agoI mined Bitcoin in 2012, worked in crypto and mostly stopped doing other stuff a few years ago. I mostly don't touch, like or welcome meme shitcoins. I think NFTs are as much a grift as ICOs were in 2017, etc. etc. I still love the tech. I still love the mindsets of the people I got to meet through crypto and while there is a lot of BS, there are also a lot of very smart people working to build things that give us a fighting chance to take back some of the control and privacy that we have surrendered to FAANG and co. So, criticize away. Or just shit on it if you want, which is what some of HN is really doing. It changes nothing. I for one am grateful for everything constructive being said, because it paves the way to a future I and many others are hopeful and excited about.
- kubb 5y agoTo me the crypto anarchists seem a bit like gun enthusiasts in claiming that their passion will allow them to resist a corrupt government or powerful corporations. It doesn't end up happening, but I bet it makes your subculture feel more important than others.
- wcoenen 5y agoCrypto wallet vulnerabilities related to ECDSA nonce reuse were already a thing in 2013 [1], so it's not surprising that there are bots waiting for this. [1] https://bitcoin.org/en/alert/2013-08-11-android https://bitcoin.org/en/alert/2013-08-11-android
- tromp 5y ago> After investigation I discovered that 20 different accounts had sent a transaction to the attacker’s address, but only 9 were accounts which previously reused a nonce. What about the other 11? How did the attacker get their money? I’m not sure. Perhaps a transaction reusing a nonce made it to the mempool, but the attacker, watching the mempool, immediately submitted (or even cooperated with a mining pool to) a transaction emptying the sending account, using a much larger fee to push out the other transaction. That would leave no trace of the nonce reuse on chain.
- Aramgutang 5y agoThat is a viable possibility, yes. You wouldn't need a "much larger fee" though, just 120% of the other transaction's fee would be enough to secure prioritisation over it.
- ulrikrasmussen 5y agoI thought Ethereum used something like EdDSA where the nonce is deterministically derived from the secret key and message hash using a one-way function
- TacticalCoder 5y agoYup, this. I don't understand either. The transaction (amount / gas fee / max gas / to / from / code if any / nonce) is hashed using Keccak, then that hash is signed. The transaction also contains the data in the clear. Nodes take the data in the clear, recompute the Keccak hash, recover the signing address from the keccak hash + r,s,v then, if there are enough funds on that signing address, the transaction goes on. How could reusing a nonce once lead to a full compromise? Or is it only if the nonce is reused, but for the exact same transaction, with all the parameters identical, then signed using the same private key but some other random point?
- ulrikrasmussen 5y agoIt's an inherent property of Schnorr-style signature schemes commonly used for elliptic curves. These rely on the signer generating a random nonce for each generated signature. The nonce is used as a blinding factor, and is necessary to avoid leaking secrets in the generated signature. If the same nonce is used for signing two different messages with the same private key, then anyone can trivially derive the private key. See https://en.m.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm https://en.m.wikipedia.org/wiki/Elliptic_Curve_Digital_Signa... for details - this was famously how Sony accidently revealed the private key used to sign Playstation 3 releases, because they had just used a hardcoded nonce. Anyone could then derive the key without use of brute force via a few modular arithmetic computations. Modern signature schemes such as EdDSA do not have this footgun as they specify a completely deterministic procedure for deriving a fresh nonce for each pair of (message, private key), simply by applying a cryptographic hash function to their concatenation. This is MUCH safer for the implementor, and also simpler to implement because one doesn't have to bother with maintaining a stateful PRNG
- saurik 5y agoThere is no way for someone who receives the signature to know you used deterministic k, so the system can't enforce it; I guess the assumption is that once in a blue moon you find someone with a bespoke implementation of the signature algorithm that failed to implement deterministic signatures.
- guillem_lefait 5y agoThe address in question: https://etherscan.io/address/0x9997D91A31AA0Ed1F619e025b65E92c39fa4B968 https://etherscan.io/address/0x9997D91A31AA0Ed1F619e025b65E9...
- scottmsul 5y agoOne thing I would point out is that when calculating r, the equation r=k*G mod N is somewhat misleading. G is not a number, but rather an (X,Y) point on an elliptic curve. There is a way to "add" two points on an elliptic curve but it is a group operation which is very unlike normal addition. "Multiplication" still exists between a scalar and a point but refers to a number of point self-additions. So really R=k*G generates a new point R, where k is the nonce and G is a point that is part of the ECDSA standard. Then r is taken as the x-coordinate of R. It is easy to derive k in b=k*a mod N if you know a and b, but nearly impossible to derive k in B=k*A if B is k self additions of A on an elliptic curve.
- TacticalCoder 5y agoNot to take anything from cryptocurrencies but... Is there some proof-of-stake chain which copies, for free or nearly free (nearly free as in, for only the price of a normal transaction on that chain), all the "valuable" NFTs from Ethereum? For example something where everybody could have has many "yacht apes" (or whatever they're called)? I'd like myself a copy of everything, but without paying anything for it (I'm not talking about the copies where you still have to send valuable ETHs to get a cheaper price: I'm talking 100% free stuff). I know I could do it myself, but that's not the question: my question is if it already exist. I think it'd only be fair game. Pirate's life, aye!
- thinkmassive 5y agoTheNFTBay.org was covered here a few weeks back: https://news.ycombinator.com/item?id=29265064 https://news.ycombinator.com/item?id=29265064
- zemptime 5y agoThis could be interesting. Value is assigned by people, so the fact the credentials for a given work reside somewhere else with 'less legitimacy' would mean yes - you could copy it. However this other chain would be entirely illiquid. But...the interesting part. What happens when cross-chain asset movement is much simplified? I don't see there being any issue with legitimacy (original owners could still verify ownership, you couldn't). But if you flooded original chain with fakes, uh... Talked myself out of it. nevermind
- saurik 5y agoFlooding the original chain with fakes doesn't make them look real: they are different tokens. It isn't like computers are squinting at the hashes and timestamps and public keys and getting confused as to their identity.
- miracle2k 5y agoThis idea has been floated. Scammer Richard Heart is trying to this with Pulsechain, and somewhat more seriously, Avalanche wanted to run such a forked Ethereum as a subchain, but this appears to have been abandoned. It is an interesting scenario to think through, in particular what happens with stablecoins etc. which would not be redeemable. Ultimately, I predict such efforts to fail badly. The fact that e.g. Ethereum NFTs are copied will in fact work against such a fork getting traction.
- 38leinad 5y agoSorry for maybe asking a stupid question, but if i understand correctly, the nounce is just a secret as the private key. But the nounce is not needed for the signature check? So, it can be choosen random and then simply forgotten after signature generation? After first quick google search, it looks like there is also the term nounce use here but it is deterministic and just counted up which does not seem to fit with the article: https://developpaper.com/the-nonce-of-ethereum/ https://developpaper.com/the-nonce-of-ethereum/ Am I missing something?
- saurik 5y agoThe nonce used for ECDSA signatures is not the same as the nonce used for Ethereum signature. The term "nonce" is a general term that is used in any number of systems to mean a value which should only be used once, and might apply to any number of layers or protocols in a given system. There are various techniques people use for them: a careful counter, a precise timestamp, a hash of the rest of the data, or a random number. Often you can choose as the user... as long as you don't use the same value twice; alternatively, your choice of nonce might be verified by your counter-party (as with Ethereum's account nonces). The consequences of using the same value twice will also differ: your request might be rejected/ignored, you might be penalized or cause an error, it might expose your identity to a system where you were otherwise anonymous, or it might allow someone to calculate your private key. The high-level idea is what matters, not the specifics.
- TacticalCoder 5y agoWait, how does it work? What is signed is hashed, including the nonce. People use some kind of "replace by fee" transactions all the time, as far as I know these broadcasted transactions, typically with higher fees, have the exact same nonce as the previous one. If simply reusing the same nonce allowed someone to crack the private key, it'd be a much bigger issue than a few wallet emptied. It'd be a tremendous amount of wallets emptied, daily. Can someone explain in more details?
- TacticalCoder 5y agoRe-reading the article it's not when the nonce is reused, but when in the (r,s) of the signature the 'r' is reused. To end up with the same 'r' twice you must reuse the nonce but, I think, not only that. If you reuse the nonce but change any other parameter (for example putting slightly higher gas fee), then I'm pretty sure the 'r' changes (I'll go test that now out of curiosity).
- saurik 5y agoYou are thinking of the nonce at the Ethereum account level, not the nonce used as the ECDSA signature level. This has nothing to do with Ethereum other than that Ethereum uses ECDSA signatures for security. Search for "ECDSA nonce" on Google and most of the articles and videos you will find will be explaining nonce reuse issues.
- ChrisClark 5y agoThe Ethereum transaction nonce you are talking about is not the same nonce in the article. It is talking about the cryptography signing process, not the transaction ordering one.
- beervirus 5y ago
- vmception 5y agoIts interesting that wallets have gotten so good that these kinds of user errors have practically evaporated That bot is doing pretty bad in such an active year One thing to check about the other addresses is if they compromised themselves on other networks like public testnets or other blockchains
- adamgordonbell 5y agoIf you enjoyed this, you might enjoy "Smart Contract Rescue" where Dan Robinson describes the original 'Ethereum is a Dark Forest' problem. https://corecursive.com/064-ethereum-rescue-with-dan-robinson/ https://corecursive.com/064-ethereum-rescue-with-dan-robinso... Dan: Maybe I’m like a predator in this environment where… In this case, I was a white hat hacker, but maybe I’m a black hat hacker. Maybe I’m trying to take money from a smart contract. And I think I’m so smart. Like I put a bunch of effort into figuring out this way to steal this money from it. And as soon as I go to do that, just this whale comes up from the deep and just devours me whole. I think I’m actually at the top of the food chain and I’m not even close.
- yonixw 5y agoAmazing read! whished he included link to the relevant ethscan..
- plank 5y agoThe author is wondering why the creature is waiting. If it was my creature (just for the record: it is not!) I would perhaps try* the following: set up a few transfers so that IF someone tries to empty their account, immediately make a two-three or four competing transfer. As it is longer, it may win the other (just one transaction). So if e.g. account A is compromised (private key found), perpetrator sets up transaction from A to B, from B to C, from C to D. If the original owner tries to do a transaction from A to Z, immediately throw the A->B->C->D transactions. *Would this actually work? Not a Ethereum/Bloclkchain guy myself.
- yonixw 5y ago1) Why multiple transactions? you can give higher fees for a single transaction which will still give it higher priority 2) Unless you are a malicious BTC\ETH mining node that got the future transaction (which uses the nonce again), it will be too late. You will learn about the re-use only after the blockchain update propagates.