Most non trivial code will have a few bugs in it.

And the security audits are in

Of course there were bugs…

A couple of weeks ago we received the final security audit on our token sale smart contracts and, as is usual there were a few things to fix.

It was tricky getting an auditor for our contracts. We had seen a fantastic job that Loi Luu had done recently but his workload at Kyber Network and Smartpool meant that he had to turn us down.

Taking these reports as the “gold standard” we looked around for somebody who was able to do a similarly good job. It was not easy, but following a link to a smart contract analysis tool led us to find a new security audit team called ChainSecurity.

Why audit code?

Every programmer, faced with deadlines, specification changes that arise from user feedback and constant testing and refinement, gets too close to their code to be able to audit it. The programmer knows how the code should work and conducts tests to prove that it works. The more familiar you are with what the code should do, the harder it is to break it.

The security auditor, on the other hand, looks from the viewpoint of a naughty child, wondering what would happen if you did the wrong thing over here or put the wrong data in over there. They need a good eye for detail and a strong analytical mind.

Who are ChainSecurity?

ChainSecurity was spun out of the security labs at ETH Zurich. Discovering this alone was exciting. ETH Zurich could be described as the MIT of Europe, for many years being the home of Niklaus Wirth, the father of Pascal, Modula-2 and Oberon.

Our experience

Our excitement at finding them was well justified. We had a few video calls on Skype and many chats on Telegram to augment the notes and explain what we were were trying to achieve and they lived up to their promise, doing some highly detailed work and finding a few holes that we had overlooked. Not only did they review the code, but also the underlying logic.

Happily the code was deemed generally to be secure. A couple of serious things had crept in during a rewrite because a last minute test had shown that a certain part of the original code would fail after about sixteen years. Apart from that most things were pretty minor and a couple went as far as to recommend renaming variables for greater clarity.

A few days later we resubmitted the amended code and received a clean bill of health.

There is little point to going over the code line by line. You can read the audit report and find the code in the HelloGold github repository.

In conclusion, we had a great experience working with ChainSecurity. We will work with them again on future smart contract security audits and would highly recommend them.