Security Analysis of DKG Threshold Raising Vulnerability

02/21/2024

By Max

Background

Trail of Bits recently disclosed a vulnerability in the MPC threshold signature scheme that affects the DKG (Distributed Key Generation) protocol. “The vulnerability allows a single malicious participant to surreptitiously raise the threshold required to reconstruct the shared key, which could cause signatures generated using the shared key to be invalid”, according to Trail of Bits [11]. In extreme cases, it may even result in the private key being unable to be reconstructed.

For example, suppose the expected outcome of the DKG protocol is {2,3}\{2, 3\}, generating three shards in total, with any two parties capable of executing MPC signature or private key reconstruction. However, exploiting this vulnerability could result in {3,3}\{3, 3\} shards, where three shards are generated, but any two parties cannot execute MPC signature or private key reconstruction, requiring the participation of all three parties. In the worst case, if the DKG protocol implementation lacks comprehensive checks, it could even generate {3,4}\{3, 4\} shards. Since only three shards are actually saved, MPC signature or private key reconstruction can never be executed, leading directly to asset loss.

On January 3, 2024, Trail of Bits disclosed a security vulnerability to Safeheron via email. After analysis and research, Safeheron patched the vulnerability on January 4, 2024, and publicly released a fix patch (see the "Remediation" section of this article). With permission from Trail of Bits, Safeheron also promptly informed security partners and other vendors about this vulnerability.

Safeheron's SaaS product is not affected by this vulnerability.

DKG (Distributed Key Generation) Protocol

In Secure Multi-Party Computation, there is no trusted third-party dealer, and multiple parties jointly generate the secret. At no time and no place does the complete secret appear.

To achieve this goal, in 1991, a distributed key generation (DKG) protocol was proposed [5], an extension based on Shamir's secret sharing scheme [1] [2] [3] [4]. The protocol achieves the following objective:

Participants P1,P2,,PnP_1, P_2, \dots , P_n jointly generate a set of key shards under a {t,n}\{t, n\} threshold scheme, where any fewer thantparticipants have no knowledge of the actual private key.

Typical MPC multisignature protocols, such as GG18[6], GG20[7], CMP[8] based on threshold schemes, Frost[10], and DMZ21[9] all define the distributed key generation (DKG, Distributed Key Generation) sub-protocol. The shard generation principles of those protocols are similar. Now, let's introduce the core idea.

Given an elliptic curve group G=(g,q)\mathbb{G} = (g, q), each participant (Pi)(P_i) executes the following algorithm:

  1. PiP_i randomly generates a key uiZqu_i \in Z_q;

  2. PiP_i randomly selects a polynomial of degree t1t-1;

    • Choose t1t-1 random numbers a1Zqa_1 \in Z_q;

    • Construct the polynomial fi(ν)=ui+a1ν+...+at1νt1(modq)f_i(\nu) = u_i + a_1\nu + ... + a_{t-1}\nu^{t-1} \pmod q, noting that uiu_i is the secret value.

    • Calculate the commitment of VSSS (Verifiable Secret Sharing Scheme):

ci=(gui,ga1,,gat1)c_i = (g^{u_i}, g^{a_1}, \dots, g^{a^{t-1}})

  1. PiP_i distributes shards fi(1),fi(2),...,fi(n)f_i(1), f_i(2), ... , f_i(n) to participants P1,P2,,PnP_1, P_2, \dots , P_n, and broadcasts cic_i

  2. PiP_i, upon receiving fj(i)f_j(i) from others,

    • Verifies the validity of the shard; if the following equation holds, the shard is valid; otherwise, it is invalid:

gfj(i)=kci,kikg^{f_j(i)} = \prod_k {c_{i, k}^{i^k}}

  • Calculates their own shard:

xi=jifj(i)(modq).x_i = \sum_{j \ne i} f_j(i) \pmod q.

Taking {2,3}\{2, 3\} as an example, P1,P2,P3P_1, P_2, P_3 execute the DKG protocol and generate their respective shards x1,x2,x3x_1, x_2, x_3, as shown in the following diagram:

The private key xx (the actual private key) can be recovered with a threshold of 2, satisfying not only

xx1λ1+x2λ2+x3λ3(modq)x \equiv x_1 \cdot \lambda_1 + x_2 \cdot \lambda_2 + x_3 \cdot \lambda_3 \pmod q

but also the following equations, meaning any two key shards can reconstruct the private key:

xx1λ1+x2λ2(modq)x \equiv x_1 \cdot \lambda_1' + x_2 \cdot \lambda_2' \pmod q

xx1λ1+x3λ3(modq)x \equiv x_1 \cdot \lambda_1'' + x_3 \cdot \lambda_3'' \pmod q

xx2λ2+x3λ3(modq)x \equiv x_2 \cdot \lambda_2'''+ x_3 \cdot \lambda_3''' \pmod q

Here, each λ\lambda denotes a Lagrange interpolation coefficient, which is public as it can be calculated from the publicly known index data, as follows:

λi=ΠjSubSet,jiiij(modq)\lambda_i = \Pi_{j \in SubSet, j \ne i}{\frac{i}{i - j}} \pmod qiSubSeti \in SubSet, SubSet={1,2,3}SubSet = \{1,2,3\}

λi=ΠjSubSet,jiiij(modq)\lambda_i' = \Pi_{j \in SubSet, j \ne i}{\frac{i}{i - j}} \pmod q, iSubSeti \in SubSet, SubSet={1,2}SubSet = \{1,2\}

λi=ΠjSubSet,jiiij(modq)\lambda_i'' = \Pi_{j \in SubSet, j \ne i}{\frac{i}{i - j}} \pmod q, iSubSeti \in SubSet, SubSet={1,3}SubSet = \{1,3\}

λi=ΠjSubSet,jiiij(modq)\lambda_i''' = \Pi_{j \in SubSet, j \ne i}{\frac{i}{i - j}} \pmod q, iSubSeti \in SubSet, SubSet={2,3}SubSet = \{2,3\}

Note that for typical MPC multisignature protocols, like GG18 and GG20, the threshold for MPC multi-signature and private key reconstruction is the same. For better understanding, only private key reconstruction is mentioned here.

Generally, MPC multisignature can be completed only if the private key can be reconstructed or vice versa. It's worth emphasizing again that the private key will never be reconstructed during MPC multisignature, nor will it reveal any information about each other's private key shard.

The Attack

In the specific implementation of the DKG protocol, and other MPC signature protocols, if the verification of the commitment for VSSS only verifies the correctness of the shard but not the degree of the random polynomial, the following attack method can be used:

A single malicious participant (PiP_i), to modify the final shard threshold from tt to tt', where t>tt' > t, executes the following malicious protocol:

  1. PiP_i randomly generates a key uiZqu_i \in Z_q;

  2. PiP_i randomly selects a polynomial of degree t1t'-1, noting that this tt' is different from the expected tt, t>tt' > t;

    • Choose t1t'-1 random numbers a1Zqa_1 \in Z_q;

    • Construct the polynomial fi(ν)=ui+a1ν+...+at1νt1f_i(\nu) = u_i + a_1\nu + ... + a_{t-1}\nu^{t'-1}, noting that u_i is the secret value.

    • Calculate the commitment of VSSS (Verifiable Secret Sharing Scheme):

ci=(gui,ga1,,gat1)c_i = (g^{u_i}, g^{a_1}, \dots, g^{a^{t'-1}})

  1. PiP_i distributes shards fi(1),fi(2),...,fi(n)f_i(1), f_i(2), ... , f_i(n) to participants P1,P2,,PnP_1, P_2, \dots , P_n, and broadcasts cic_i to everyone.

  2. PiP_i, upon receiving fj(i)f_j(i) from others,

    • Verifies the legitimacy of the shard; if the following equation holds, the shard is valid; otherwise, it is invalid:

gfj(i)=kci,kikg^{f_j(i)} = \prod_k {c_{i, k}^{i^k}}

  • Calculates their own shard:

xi=jifj(i)(modq)x_i = \sum_{j \ne i} f_j(i) \pmod q

As a result, when the DKG protocol ends, the final shards x1,x2,,x3x_1, x_2, \dots, x_3 have the threshold modified to the malicious participant's tt', higher than the expected thresholdt. Taking {2,3}\{2, 3\} as an example, if P1P_1 is the malicious party, and P1,P2,P3P_1, P_2, P_3 execute the DKG protocol, they generate their respective shards x1,x2,x3x_1, x_2, x_3, as shown in the following diagram:

Note that the threshold of x1,x2,x3x_1, x_2, x_3 is maliciously modified to 3, not the expected 2. This means that xx cannot be reconstructed with a threshold of 2, and the attack is successful. The following equations do not hold:

xx1λ1+x2λ2(modq)x \equiv x_1 \cdot \lambda_1' + x_2 \cdot \lambda_2' \pmod q

xx1λ1+x3λ3(modq)x \equiv x_1 \cdot \lambda_1'' + x_3 \cdot \lambda_3'' \pmod q

xx2λ2+x3λ3(modq)x \equiv x_2 \cdot \lambda_2''' + x_3 \cdot \lambda_3''' \pmod q

Impact

Using the above attack method, a single malicious attacker can potentially raise the final threshold of shards. The DKG protocols in typical MPC multisignature protocols, such as GG18[6], GG20[7], CMP[8] based on threshold schemes, Frost[10], and DMZ21[9] are all affected.

Specifically, if the DKG protocol's expected threshold is (t,n)(t, n), meaning any tt parties can recover the private key/signature, then a single malicious attacker can potentially modify the threshold to (T,n)(T, n).

The specific impact analysis is as follows:

Scenario 1: nT>tn \ge T \gt t. Simply elevate the threshold for recovering the private key/signature. For instance, if three shards x1,x2,x3x_1, x_2, x_3 are generated with an expected threshold of 2, and it's maliciously modified to 3, all three shards must participate to successfully recover the private key/MPC signature.

Scenario 2: T>nT \gt n. There are 2 cases:

  • If the DKG protocol includes comprehensive checks, such as private key recoverability verification (refer to Safeheron implementation), then the DKG protocol will not complete successfully, and no further problems will occur.

  • If there are no additional checks in the DKG protocol, then the DKG protocol will complete normally, but the final shards generated will never be able to recover the private key or signature, leading directly to asset loss. It's worth noting that some open-source algorithm libraries lack such checks, leading to serious consequences.

Note: There is a special case where if n==tn == t (e.g., shard modes like {3,3}\{3,3\}, {5,5}\{5,5\}, {10,10}\{10,10\}, etc.) and necessary private key recoverability checks are in place, this scenario is not affected by the vulnerability.

Remediation

To fix the vulnerability, it is necessary to check the length of the commitment in the Feldman VSSS algorithm to ensure it matches the threshold.

Specifically: PiP_i, upon receiving fj(i)f_j(i) from others,

  • Verifies the validity of the shard:

    • Validate the equation. If the following equation does not hold, the shard is invalid.

gfj(i)=kci,kikg^{f_j(i)} = \prod_k {c_{i, k}^{i^k}}

  • Validate the equation. If the following equation does not hold, the shard is invalid.

len(ci)==tlen(c_i) == t

  • Calculate their own shard:

xi=jifj(i)(modq)x_i = \sum_{j \ne i} f_j(i) \pmod q

The essence of the remediation is to constrain the degree of the random polynomial to lock the shard threshold.

For specific fixes, refer to:

Conclusion

After understanding the vulneribility and its exploitation method, it is clear that this is a vulnerability at the protocol implementation level. The damage caused by exploiting this vulnerability varies depending on the situation and can lead to extremely serious consequences in extreme cases. Safeheron's SaaS products, using a {3,3}\{3,3\} threshold scheme and having necessary recoverability checks (based on zero-knowledge proof), is not affected by this vulnerability.

Achieving trustworthy security requires persistent meticulous refinement. "Rome wasn't built in a day." Stay humble, stay grounded, and let security truly serve the industry.

The responsible security disclosure by the Trail of Bits team demonstrates the openness and collaboration in the security industry. Safeheron also actively engages in communication with more security partners, and we are pleased to be part of this remediation and disclosure process.

Creating a secure industry environment requires dialogue with vendors, security practitioners, and users. Through collective dedication and effort from all sides, security can empower the industry.


References

[1] Secret sharing

[2] Verifiable secret sharing

[3] How to share a secret

[4] A Practical Scheme for Non-interactive Verifiable Secret Sharing

[5] Non-Interactive and Information-Theoretic Secure Verifiable Secret Sharing

[6] GG18: Fast Multiparty Threshold ECDSA with Fast Trustless Setup

[7] GG20: One Round Threshold ECDSA with Identifiable Abort

[8] CMP: UC Non-Interactive, Proactive, Threshold ECDSA with Identifiable Aborts

[9] DMZ21: Promise Sigma-protocol: How to Construct Efficient Threshold ECDSA from Encryptions Based on Class Groups

[10] FROST: Flexible Round-Optimized Schnorr Threshold Signatures

[11] Breaking the shared key in threshold signature schemes

Last updated