September 15, 2023

Security assessment update | The importance of being random

What’s happening?

An automated security assessment by Security Research Labs found two vulnerabilities in peaq’s design, which the team at EoT Labs has mitigated.

Why is it important? 

As a go-to blockchain for real-world apps, peaq must be as secure as it gets — and regular security assessments are a great help in keeping it this way.

What does it mean for the community?

That peaq is pretty secure and reliable, and you won’t have to worry about your tokens disappearing overnight due to a bug or a malicious actor attack.

How often do you flip a coin when facing a tough decision? Heads, you spend your 10,000 Bitcoin on pizza, tails, you get sushi. Heads or tails, it’s yum either way, and you don’t have to sweat the details — the randomness takes the wheel. Or does it?

Here's the thing: One could argue that the outcome of the coin flip is anything but random. After all, it is the product of a force being applied to an object. From the coin’s starting position and trajectory to the effort you put in the throw, dozens of variables converge to produce a process that is ultimately deterministic. You just don’t know how to calculate the outcome with these variables, that’s why it seems random. 

What’s all of this about? Well, if true randomness is tricky to produce for a human, a computer, which is very much a deterministic machine, struggles with it even more. This problem is at the foundation of an issue that Security Research Labs has found in peaq’s design in its latest automated security assessment. Let’s dig in. 

Tackling the randomness

Security Research Labs is a leading consultancy providing IT security services to a wide array of organizations across multiple industries. For quite some time, they have been conducting regular automated audits of peaq to help make the network as secure as possible. You can find an overview of the previous assessment here.

For the sake of clarity, all of the assessments released so far focus on peaq’s testnet agung. On June 1, 2023, a new assessment came in, zooming in on two potential vulnerabilities:

  1. The use of pallet_randomness_collective_flip function as a source of randomness for the contracts pallet in the runtime.
  2. An existential deposit — the minimal amount of funds on an account to warrant keeping it alive — set at 0.

The latter problem was the easier one to fix. With existential funds set at 0, an adversary can hypothetically bloat the network by creating millions of accounts with no tokens. With a new runtime upgrade, coming very soon, this value will be set at a new threshold of 0.0000000000000005 $KREST/AGUNG. If the number of tokens in your wallet dips below that, the wallet gets destroyed, and the tokens go to the Treasury. This amps up the price of an attack like that without causing trouble to token holders. 

The former problem is harder to tackle. The function in question leverages the hashes of the past 81 blocks, which makes its output quite predictable. Hypothetically, an adversary could use it to calculate its outputs, which would enable them to estimate specific outcomes that are supposed to be… Well, random.

As stated earlier, when it comes to a deterministic machine like a computer, generating true randomness is a complicated task. For the time being, the collective flip is still the source of randomness, along with the rand_chacha library improving the randomness in smart contracts. The team is looking into alternatives to implement in the future, including using relay chain randomness.

Join the Economy of Things

Latest

All blogposts