Skip to content
DoS Audit finding Advanced

Coordinator can be crashed by signers on DKG

The wsts library used unchecked array indexing when a coordinator processed DKG packets, so a malicious signer could send a crafted BadPrivateShare with malformed shares and a valid tuple proof to make the coordinator panic. This could shut down a portion of network processing nodes, though the text notes DKG is not triggered in the near future.

n4nika Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#38030 [BC-Insight] Coordinator can be crashed by signers on DKG

Submitted on Dec 22nd 2024 at 18:10:47 UTC by @n4nika for Attackathon | Stacks

Description

Summary

The wsts library uses insecure array accesses, making it possible for a malicious signer to send certain packets to a coordinator during a DKG which cause the coordinator to panic.

Finding Description

I will put multiple instances of this in one issue since they all are only triggerable on DKG (which will not be triggered in the near future but this was explicitly mentioned by the team to still be desireable).

Instances:

  1. wsts::fire.rs#L580
  2. wsts::fire.rs#L626
  3. wsts::fire.rs#L628

Further description:

  1. Here we index dkg_public_shares[bad_signer_id]. If a signer manages to get a malicious bad_signer_id to this point, we will crash. This is the least likely case of the here mentioned cases but if a signer manages to have bad_signer_id not in dkg_public_shares, it is possible. While this is not easy, I wanted to mention it anyways for completeness
  2. Here we index dkg_public_shares[src_party_id] where we get src_party_id by iterating over dkg_private_shares.shares of which the integrity is NOT checked so this is directly exploitable by the attack described later
  3. Here we index key_shares[key_id] where key_shares is also taken from dkg_private_shares.shares making it a direct target for exploitation

Exploiting 2) and 3)

In order to exploit this, a malicous signer needs to send a BadPrivateShare to the coordinator which contains malformed shares and adheres to the following restrictions:

  • tuple_proof is valid

Mitigation

Replace all array accesses in the whole wsts library using [] with .get or equivalent methods and handle errors accordingly.

Proof of Concept

PoC

@djordon mentioned on discord that I don't need to provide a PoC for these since this report is supposed to be marked as Insight anyways.

The original report as published on Immunefi, by n4nika. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The code indexes arrays directly with values taken from signer-supplied DKG shares whose integrity is not checked, so an out-of-range index causes a panic.

Impact

A malicious signer could crash the coordinator, potentially shutting down more than 10% but less than 30% of network processing nodes without shutting down the whole network; the text notes DKG is not triggered in the near future.

What the attacker needed

Malicious signer role in DKG; DKG must be running

The fix

All direct array accesses in the wsts library should be replaced with checked lookups such as .get and errors handled accordingly.

How it was found

  1. A malicious signer crafts a BadPrivateShare message containing malformed shares.
  2. The signer ensures the tuple proof in the message is valid.
  3. The signer sends the message to the coordinator during DKG.
  4. The coordinator indexes arrays with the unchecked share values and panics.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

During a distributed key generation (DKG), several parties work together to create shared cryptographic keys. The coordinator is the party that collects and processes the messages the others send. Here the coordinator trusted the contents of a message without checking them and used them to look up positions in a list, so a bad message could point outside the list and crash the program.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by n4nika

View all

13 more disclosed reports, best first.

More from Stacks

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.