Security Analysis of BitForge Vulnerability in GG18/GG20 Protocol
08/14/2023
Last updated
08/14/2023
Last updated
By Max
Recently, the Fireblocks cryptography research team has uncovered BitForge vulnerability in the GG18, GG20, and Lindel 17 protocols. This vulnerability allows attackers to extract the full private key from a set of MPC key shards.
Before this disclosure, the Fireblocks team had connected with Safeheron and engaged in proactive communication. Safeheron's open-source GG18/GG20 MPC protocol was implemented strictly according to the content of their papers, meaning those using this version of the open-source algorithm might be vulnerable to similar attacks. Prior to the vulnerability disclosure, Safeheron had already fixed the issues in the open-source project, with the Fireblocks team assisting in verifying the effectiveness of the patch.
The Fireblocks team published a POC using Safeheron's open-source GG18/GG20 protocol in C++ to demonstrate and help the community understand this vulnerability.
In Safeheron's commercial version, we’ve additionally incorporated the zero-knowledge proofs from CMP20/CGGMP21 into GG18 and GG20 protocols, hence they are not affected by this vulnerability.
This article focuses on the impact of the vulnerability on GG18 and GG20. With respect to the GG18 and GG20 protocols, an attack can be stricken during the MPC signing by crafting the specific Paillier key. With several times of signing, the attacker can extract the key shards of other participants.
The impact of this vulnerability is quite extensive. Since it challenges the security assumptions of the MPC protocol, almost all popular open-source implementations of the GG18 and GG20 protocols are affected by this vulnerability.
How does one attack the MPC protocol? Common MPC protocols are provably secure under certain security assumptions. Therefore, attacks on MPC protocols often focus on the security assumptions they rely on. These security assumptions are like the foundation of a skyscraper. If the assumptions fail, the entire MPC protocol will be affected.
Taking GG18/GG20 as an example, these MPC protocols depend on the security of the Paillier homomorphic encryption algorithm which is designed based on the hard computational problems of composite residuosity and is a widely used homomorphic encryption algorithm that supports addition.
The core logic of the entire attack is as follows:
(1)In the KeyGen Subprotocol phase, the attacker constructs an insecure homomorphic key.
(2)During the Sign Subprotocol phase:
Using the properties of the insecure homomorphic key, the attacker constructs malicious zero-knowledge proofs, deceiving other participants to get verified;
(3)After iterating the Sign subprotocol multiple times, the attacker calculates the other participant's key shard using the Chinese Remainder Theorem.
In this chapter, we delve into the details of the attack. In a common MPC threshold signature scheme, there are multiple participants who can attack each other using identical attack methods.
The first attack occurs during the execution of the KeyGen subprotocol, which can be termed the "attack preparation phase". During this phase, the attacker, Party A, successfully constructs an insecure Paillier homomorphic key.
The standard process for constructing a homomorphic key is:
Compute:
The process used by Party A (attacker) to construct the homomorphic key is:
Compute:
The standard calculation is:
Execute the MPC Sign subprotocol as usual.
The attacker's computation process is:
Create a malicious zero-knowledge proof to deceive the other party.
Execute the MPC Sign subprotocol as usual.
Here are its specific operations:
Witness:$k_A' = 0 \ne k_A$, other random numbers.
Please note the above is an illegal statement:
Normally, the range proof of the GG18 protocol here is fully valid, making it difficult for the attacker to construct a zero-knowledge proof that allows the statement to get verified.
According to the description of zero-knowledge proof in GG18 and GG20 protocols:
In the Verifier's verification process, the most crucial aspect is ensuring the satisfaction of the equation for ciphertext constraints (highlighted in the red box):
As known:
Upon successfully executing the MPC Sign subprotocol 16 times, the attacker will obtain:
The ramifications of the attack depend on the specific implementation version of the GG18 paper. Let's analyze based on the different versions:
The revised paper of GG18 offers numerous security enhancement recommendations, thus it is advisable to implement this MPC protocol based on the revised version.
While the previous sections elaborated on the vulnerability’s theoretical underpinnings and algorithmic exploit method, how it plays out in a self-custodial MPC wallet? If the MPC protocol employed contains this vulnerability, how an attack exploit it?
The vulnerability impacts a t-of-n threshold, let’s take a simple example, 2 parties manage an MPC wallet, Party A and Party B. The signing threshold for this wallet is 2-of-2. The key shard for Party A is held by the user and is managed via a mobile App provided by the wallet service. Meanwhile, Party B's key shard is stored and utilized in the cloud by the wallet provider.
For a successful attack, the attacker would need:
Comprehensive understanding of the wallet provider's mechanism for wallet creation and transaction initiation.
The capability to simulate the provider's App to execute the MPC protocol for wallet creation and transaction signing.
Attack Execution (with the above capabilities):
In the described scenario, an attacker must initiate their attack right at the wallet creation phase. Subsequently, by conducting multiple signings using the wallet, the attacker can finally extract its private key.
Add two zero-knowledge proofs to fix:
Safeheron has already patched this vulnerability in our open-source algorithm. For details, you can refer to:
Safeheron offers an integer factorization tool, which facilitates swift batch testing. And, for the algorithm of integer factorization, please refer to Large Integer Factorization Algorithm and Its Practice.
Having delved deep into the intricacies of this vulnerability and its exploitation method, it's evident that exploiting this loophole requires a significant level of expertise. Nonetheless, in the security industry, as we traverse the challenging dark forest filled with unknowns, we must always maintain profound respect for security.
The responsible disclosure by the Fireblocks team epitomizes that "security is never a solo endeavor." At Safeheron, we're deeply committed to the principles of open-source, transparency, and prioritizing solid technical expertise. It's indeed an honor for us to be part of this disclosure process. In the future, Safeheron will aid other industry players in patching this vulnerability with our security partner SlowMist, ensuring the safety of user assets.
Achieving industry-wide security necessitates the dedication and efforts of every tech provider, every security professional, and every user.
[1] Fireblocks: Practical Key-Extraction Attacks in Leading MPC Wallets
[2] GG18: Fast Multiparty Threshold ECDSA with Fast Trustless Setup
[3] GG20: One Round Threshold ECDSA with Identifiable Abort
[4] CGGMP21: UC Non-Interactive, Proactive, Threshold ECDSA with Identifiable Aborts
This vulnerability specifically targets the construction of the Paillier homomorphic key, incrementally compromising the protocol and related zero-knowledge proof protocols, and then culminating in an effective attack.
In the pairwise-run protocols, such as and protocols, the attacker, based on the insecure homomorphic key, constructs the illegal ;
The attacker completes the signature with the attacked participant and records the in the process according to the MPC protocol.
To better explain the methods behind it, let's assume an MPC wallet is co-created and co-managed by three parties: Party A, Party B, and Party C. Each party manages their respective key shards , and . By exploiting this vulnerability, Party A can attack Party B and Party C to obtain their key shards.
In this section, taking Party A attempts to attack Party B as an example, we will illustrate how to extract Party B's key shard . (Using the same method, Party A can also extract Party C's key shard .)
Randomly select secure primes .
Randomly select primes , where each is a distinct small prime, and is a big prime.
where the length of is 2048 bits.
Paillier public key constructed by Party A contains a significant number of small factors. Then, can Party A's illegal Paillier key deceive Party B? Especially since a zero-knowledge proof needs to be constructed for Party B to verify.
From the protocol of GG18/GG20 in the above picture, it only requires a zero-knowledge proof. Given that the Paillier homomorphic public keyconstructed by the attacker only contains distinct prime factors, this construction method evidently can be verified by the zero-knowledge proof.
The attack needs to execute the Sign subprotocol 16 times. Let's assume we're discussing the -th execution.
In the Sign subprotocol, the initial rounds will execute the protocol as outlined in GG18 section 4.2.
Randomly select .
Compute .
Execute protocol:
Generate a zero-knowledge proof concerning the ciphertext of the random number . Refer to section A.1 - Range Proof in GG18.
Construct a special .
Use this specially-constructed to execute the protocol.
The attacker does not use random values. Instead, during the (i^{th}) execution of MPC Sign subprotocol, the attacker constructs a by:
Here, this specially-constructed . Under common circumstances, it cannot be verified by the expected zero-knowledge proof. Note, is the order of the elliptic curve.
The GG18 protocol requires the attacker to provide a valid zero-knowledge proof during the execution of protocol, referring to section A.1 - Range Proof in GG18. This proof must verify:
Statement: The ciphertext of $Enc_{N_A}(k_A)$ for $k_A'$ which satisfy
is not the ciphertext of .
So, if Party A (attacker) want to successfully exploit the vulnerability, the attacker needs to use the insecure Paillier key constructed by Party A during the KeyGen subprotocol phase. It is the presence of this insecure Paillier key that provides the opportunity to craft malicious a zero-knowledge proof.
The attack technique is to craft a plausible challenge value that satisfies the condition .
As ,
Here, "transformed" into the ciphertext of , thereby successfully constructing the zero-knowledge proof.
Please note that here, it is possible to iteratively brute-force during the construction process by continuously incrementing it by 1 and updating , thus satisfying the condition . Since the modulus is a small prime, a brute-force iteration can be successful.
The attacker and the victim successfully execute the Sign subprotocol together, additionally recording the from the protocol.
According to the latest , as ,
Record
Notably, all on the right of the equation are parameters known to the attacker; hence, the attacker can compute .
So, the result is .
Given that , and according to the Chinese Remainder Theorem (CRT), Party A can effectively compute Party B's key shard, thus, completing the attack.
In the revised version of GG18, the protocol constrains (equivalent to as mentioned previously). By using the attack method described above, an attacker would only need 16 signatures to successfully decipher the key shard of the victim.
In the original version of GG18, the protocol constrains (equivalent to as mentioned previously). To mount an attack against this version, a slightly-altered method is required (not further elaborated herein) which would require a substantial amount of trial operations and signing, at least 10^6 attempts, to potentially extract the target's key shard. To be precise, with a success probability of , it necessitates signatures.
Please note, . (There was a typo in this formula in the Fireblocks paper; the correct formula is presented here.)
Simulate the mobile App to create a wallet. When creating it (equivalent to subprotocol), crafts an insecure homomorphic key of the local Party A MPC protocol. Using this key, the attacker completes the wallet setup and consequently obtains the local key shard of Party A.
Simulate the App to initiate transaction signing 16 times (corresponding to the Sign subprotocol). During each signing, the attacker crafts a malicious and its corresponding malicious zero-knowledge proof for the MPC protocol. The attacker will then successfully execute the signing process 16 times, gathering the value each time.
Upon executing the above steps, the attacker can acquire the cloud-stored key shard associated with Party B for the created wallet. Given the 2-of-2 signing threshold, the attacker already possesses the key shard and, through the exploitation, has now obtained . Consequently, the attacker can use and to extract the full private key .
Upon analyzing the entire attack, it becomes evident that the crux of the vulnerability stems from the preparation phase. In this stage, the malicious Party A crafts an insecure homomorphic key , which comprises a significant number of small prime factors. These factors play a pivotal role in enabling the subsequent attack.
The remedial approach is to nip the issue in the bud. In the GG18 and GG20 protocols, additional zero-knowledge proofs are introduced to deter the presence of small factors in the homomorphic public key , thereby thwarting the attack from the root. When the patch for this vulnerability is applied, the security assumptions underpinning the GG18 and GG20 protocols are intact, ensuring the protocol's security.
Blum Modulus Proof for Paillier: Ensure that the homomorphic public key consists of at most two prime factors that adhere to specific characteristics.
No Small Prime Factors Proof: Ensure that there are no small prime factors in the homomorphic public key .
For implementations of these zero-knowledge proofs, you can refer to CMP20 and CGGMP21 (specifically sections 6.3 and C.5). These proofs guarantee that the Paillier public key does not contain factors smaller than .
After upgrading the security of the MPC protocol, we also suggest analyzing historical data to determine if there has been any exploitation of the said vulnerability. Given that the exploit hinges on creating an insecure Paillier key, the presence of small factors within the attacker's Paillier public key would indicate that a prior attack had occurred. Thus, by checking if there are any small factors within the Paillier public key of the MPC participants, you can infer potential past attacks.
A robust method to detect this is by utilizing an established integer factorization algorithm tool to check if the Paillier modulus has any small factors. If any small factors are detected, it points towards a probable attack. In such cases, it's recommended to promptly transfer assets and set up a new MPC wallet.