34252 - [BC - Critical] Bypass Certificate Signing Validation
Bypass Certificate Signing Validation
Submitted on Aug 7th 2024 at 21:12:49 UTC by @Blockian for Boost | Shardeum: Core
Report ID: #34252
Report type: Blockchain/DLT
Report severity: Critical
Target: https://github.com/shardeum/shardus-core/tree/dev
Impacts:
Network not being able to confirm new transactions (total network shutdown)
Direct loss of funds
Description
Bypass Certificate Signing Validation
Impact
Bypass stake certificate validation, allowing for non-staking nodes and network take-over
Bypass nodes removal validation, allowing to remove nodes from the network
Root Cause
The function validateClosestActiveNodeSignatures counts repeated signatures as different signatures, allowing for 1 valid signature to be counted as minRequired. In other words - signatures are counted, instead of signers.
Deep Dive
The functions validateClosestActiveNodeSignatures and validateActiveNodeSignatures receive a parameter minRequired that specify what is the minimal number of nodes need to sign the appData to make it valid.
https://github.com/shardeum/shardus-core/blob/4d75f797a9d67af7a94dec8860220c4e0f9ade3c/src/shardus/index.ts#L1780
https://github.com/shardeum/shardus-core/blob/4d75f797a9d67af7a94dec8860220c4e0f9ade3c/src/shardus/index.ts#L1746 It does so by looping over the signature list, and checking if the signature is valid. If it is, the counter is incremented.
https://github.com/shardeum/shardus-core/blob/4d75f797a9d67af7a94dec8860220c4e0f9ade3c/src/shardus/index.ts#L1763
https://github.com/shardeum/shardus-core/blob/4d75f797a9d67af7a94dec8860220c4e0f9ade3c/src/shardus/index.ts#L1763 If the amount is more than the min required,
trueis returnedhttps://github.com/shardeum/shardus-core/blob/4d75f797a9d67af7a94dec8860220c4e0f9ade3c/src/shardus/index.ts#L1769
https://github.com/shardeum/shardus-core/blob/4d75f797a9d67af7a94dec8860220c4e0f9ade3c/src/shardus/index.ts#L1815
Suggested Fix
Remove the public key from closestNodesByPubKey after counting it.
Flow
Malicious node generates a fake
JoinRequestwith a fakeStakingCertificateIt brute-forces
StakingCertificatefields to make sure its one of the closest nodes to the hash of the staking certificates. This is easy, as only 1 node is needed to be close.
It creates the full JoinRequest, with multiple copies of its signature, instead of signatures from many other nodes.
It calls gossip-join-request
Other nodes receive the join request, and validate it using
validateClosestActiveNodeSignatures.The validation bypasses, as they count the number of signatures and not the number of signers.
The new node joins the network without staking.
Severity
This allows to take over the network (by kicking nodes / adding nodes) and so it critical.
Proof of concept
POC
Set-up
Clone
shardeum(devbranch)Clone
json-rpc-server(devbranch)Clone
simple-network-test(devbranch)Run
npm iinside all three directoriesInstall
shardusaccording to the readme inshardeum:
Apply the
debug-10-nodes.patchwith a 5 nodes modification:
Apply the suggested local network changes from the docs:
Prepare the
shardeumproject by running
inside the shardeum directory.
Start a local network by running
inside the shardeum directory.
Run a local
json-rpc-serverby running
at the json-rpc-server directory.
Wait for the network to be ready, by looking at the output from the
json-rpc-server. We needCurrent number of good nodesto be 5.Apply the patch for package.json inside
simple-network-test
Create the poc file
Update
nodeKeyPairin the POC to contain the private and public keys of one of the nodes in the networkRun the POC by calling
Inside simple-network-test.
If the join fails because the cycle is post Q1, wait a few seconds and repeat, in a loop, until submitting in the first quarter of the next cycle.
All nodes should have
validateJoinRequest success!!!In their outpus
POC Limitations
As you can see, signatures can be re-used.
It is still required that the malicious node would be one of the 7 closest nodes of the staking certificate hash. This is easily done by brute-force, as only one malicious node need to be in the 7 closest from the network, which is very easily done with the 130K nodes currently on the network.
Last updated
Was this helpful?