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.
- 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
- Report ID: #38030
- Report Type: Blockchain/DLT
- Report severity: Insight
- Target: https://github.com/stacks-network/sbtc/tree/immunefi\\_attackaton\\_0.9/signer
- Impacts:
- Shutdown of greater than 10% or equal to but less than 30% of network processing nodes without brute force actions, but does not shut down the network
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:
wsts::fire.rs#L580wsts::fire.rs#L626wsts::fire.rs#L628
Further description:
- Here we index
dkg_public_shares[bad_signer_id]. If a signer manages to get a maliciousbad_signer_idto this point, we will crash. This is the least likely case of the here mentioned cases but if a signer manages to havebad_signer_idnot indkg_public_shares, it is possible. While this is not easy, I wanted to mention it anyways for completeness - Here we index
dkg_public_shares[src_party_id]where we getsrc_party_idby iterating overdkg_private_shares.sharesof which the integrity is NOT checked so this is directly exploitable by the attack described later - Here we index
key_shares[key_id]wherekey_sharesis also taken fromdkg_private_shares.sharesmaking 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_proofis 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.
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
- A malicious signer crafts a BadPrivateShare message containing malformed shares.
- The signer ensures the tuple proof in the message is valid.
- The signer sends the message to the coordinator during DKG.
- 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.