Live data from Hacker News

Zcoin implementation bug enabled attacker to create over 500K Zcoins

makebitcoingreatagain.wordpress.com

51–60 of 223 posts

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#51
post #45

I always wonder how these "five conditions ANDed together in an if" make it past code review in general (i know thats not where the actual bug was). I don't care how brilliant a programmer you are, but mistakes in those are very difficult to grasp.

That's the equivalent of a 32 branch switch statement in one line.

So only 31 other cases to test for, now let's hope they did all those tests.

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#52

The error is here: https://github.com/zcoinofficial/zcoin/blob/81a667867b5d8489... and the line of code: zccoinSpend.denomination == libzerocoin::ZQ_LOVELACE; In other words, a statement with no effect. In D, such a line gives an error, not a warning: Error: == has no effect in expression You can force the statement to be accepted by casting it to void. It's really past time for languages to not accept such code any…

You're absolutely right (to my surprise), it gives:

    test.cpp: In function ‘int main()’:
    test.cpp:13:11: warning: statement has no effect [-Wunused-value]
             a == b;
               ^
But only after enabling a warning that is not on by default. -Wall and -Werror should be the default.

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#53
post #48

Earlier quoted context omitted.

You're right. My contention is that the language itself should no longer accept such code, it shouldn't be relegated to an ignorable warning or a 3rd party tool that isn't run.

Yes, major improvements could be made by changing the defaults of the tools that beginners use. I edited my original comment to be more clear on this as well.

I think we're going to have to disagree. It isn't just an issue for beginner code. Experts make such mistakes, too. Expecting them to not make mistakes is unrealistic, and sending them back for more training isn't going to work, either.

I can't think of a reason any modern language should accept such code.

If you're interested, I recommend the series "Air Disasters" on TV. Each episode analyzes one crash, where investigators determine the cause of the accident, and what the corrective action should be taken. Often, it comes down to "how could a pilot with 10,000 hours experience make such a mistake". While it would be easy for investigators to blame the pilot, often they find that the mistake was just too easy to make, and they recommend changing the design or procedures or both.

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#54
post #33
post #3

Note that this is unrelated to Zcash, the zk-SNARKS based cryptocurrency perhaps more known to HN.

yes but, shockingly , they have the same mastermind behind it: https://en.wikipedia.org/wiki/Zerocoin

No. Zcoin implementation != Zerocoin. Also, I wouldn't say that Green is a "mastermind behind Zcash". He is one of the team members. Zooko Wilcox is generally seen as the "main guy" in the Zcash team.

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#55
post #27

Earlier quoted context omitted.

You're never beyond the reach of a civil suit. If you identify yourself with the scheme and you're in the same country where there's adoption, you could be easily targeted. Plus, the language in 18 U.S.C. § 1030(e)(2) (courtesy of CFAA) refers specifically to "any computer, when [it affects] use by or for [a] financial institution." And later it mentions "...affecting interstate or foreign commerce or communication..…

I would really like to see this happen. Without an EULA, is it even possible? Perhaps the next generation of cryptocurrencies can have a simple EULA that prohibits exploitation and can be used to firewall off stolen coins.

You are getting attacked for poor wording. It's reasonable (and there is precedent) for something like a blockchain fork that voids the value of bad coins. You'd need some implementation of majority vote, though (a jury of your peers, weighted by hashrate?)

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#56
post #12

Earlier quoted context omitted.

People complained a lot for 10% of Zcash going to the founders (in the form of a 20% draw on the first half of mining). But that value and expertise are used to ensure bugs like this Zcoin attack do not occur.

> used to ensure bugs like this...do not occur Then compensate for that. Create a pool that pays out for each year without vulnerabilities.

This is an really interesting idea, but I'm genuinely curious if you have an idea as to how it might be implemented. I'm not an expert on cryptocurrencies, but I don't know how I would encode the condition "has a vulnerability been discovered this year" into the protocol.

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#57
post #34

Earlier quoted context omitted.

Do you think this is immoral? I am genuinely curious as to what the arguments would be one way or another. People are taking a risk with these things and they know they're risky. So it's not really stealing.

I believe it is a crime, both in spirit and on paper. In spirit, you took something that was not yours and not meant for you, and by selling the coins you decreased the value of everyone else's. On paper, let's say that the developers behind whatever coin you hack decide that they are going to take no action. You still run afoul of countless computer security laws designed, however poorly, to protect people from hack…

And with all that said, this type of activity is still attractive to some folk.

I'm content getting my kicks out of intentionally running the occasional red light.

But it takes all types. Imagine how boring the world would be without crime!

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#58

The error is here: https://github.com/zcoinofficial/zcoin/blob/81a667867b5d8489... and the line of code: zccoinSpend.denomination == libzerocoin::ZQ_LOVELACE; In other words, a statement with no effect. In D, such a line gives an error, not a warning: Error: == has no effect in expression You can force the statement to be accepted by casting it to void. It's really past time for languages to not accept such code any…

How is D holding up against newer upstarts like Go and Rust?

It seems that D never really got the love it deserved, perhaps because it didn't have a Google or Mozilla behind it.

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#59

The error is here: https://github.com/zcoinofficial/zcoin/blob/81a667867b5d8489... and the line of code: zccoinSpend.denomination == libzerocoin::ZQ_LOVELACE; In other words, a statement with no effect. In D, such a line gives an error, not a warning: Error: == has no effect in expression You can force the statement to be accepted by casting it to void. It's really past time for languages to not accept such code any…

You're absolutely right (to my surprise), it gives: test.cpp: In function ‘int main()’: test.cpp:13:11: warning: statement has no effect [-Wunused-value] a == b; ^ But only after enabling a warning that is not on by default. -Wall and -Werror should be the default.

It should be an error, not a warning (default or not). There are a number of things like this that should just not be accepted anymore. Here's another one:

    if (condition);
        dothis();
No compiler should accept that, regardless of switch settings.

Re: Zcoin implementation bug enabled attacker to create over 500K Zcoins

#60
post #46

Earlier quoted context omitted.

Any C++ static analyzer worth its salt would catch this. I don't think this is so much of a C++ language issue, but more of an issue with C++ environments/compilers not doing static analyzing by default, and/or the authors of this software not being aware of the fact that they need to use static analyzers.

You're right. My contention is that the language itself should no longer accept such code, it shouldn't be relegated to an ignorable warning or a 3rd party tool that isn't run.

Indeed, the next standard should ban such things, and modern compilers should reject these patterns by default, unless a --legacy_security_unsage flag is set.
Post reply on HN