GHSA-cwxv-4866-5gq2: Shamir backup recovery accepts a share at x = 0, so a supplied share can substitute the recovered private key
KeyShares::frombackupformat (the Shamir backup share reader, public since 0.2.0, the crate's first release) accepted a share whose x coordinate is 0, and KeyShares::recoverprivatekey interpolates the shares at x = 0 to recover the key. At an x of 0 the interpolation answers that share's y value alone, so an attacker who supplies one share in that form — with the share's integrity tag ground to match the honest set's — chooses the recovered key outright. The non-canonical zero x = p works the same way, and a repeated x past the threshold window also passed.
An application that recovers a Shamir backup from shares it did not produce — a custodian's medium, a share pasted by hand, a set restored from another writer — could be handed the attacker's key as the recovered one. A set the crate's own writer produces never carries such a share; the door is the reader.
0.8.7 refuses such a set before interpolating (the 0.9 line's next prerelease carries the same refusal). Where upgrading is not possible, before recovering split each share on . into four fields, base58-decode the x field, and refuse the set if it decodes to zero (the one-character field 1, or a value at or above the field prime) or if two shares carry the same x.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
rust/bsv-rsto a version that resolves this vulnerability.Fixed in 0.8.7 - Upgrade
Upgrade
rust/bsv-rsto a version that resolves this vulnerability.Fixed in 0.9.0-beta.7.0 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 0.8.7 - Compensating control
Before recovering a Shamir backup, have the share reader split each share on '.', Base58-decode the x field, and refuse the set if any x decodes to zero, is at or above the field prime, or is duplicated by another share.
Event History
Frequently Asked Questions
Which backup-recovery workflows are exposed?
Applications are exposed when they recover a Shamir backup from shares they did not produce, such as shares from a custodian's medium, pasted manually, or restored from another writer. Shares produced by the crate's own writer do not contain the malformed coordinates; the affected entry point is the reader.
What must an attacker provide to control the recovered private key?
The attacker must supply a share with x equal to zero, or the non-canonical zero representation x = p, and make its integrity tag match the honest share set. When recovery interpolates at x = 0, that share's y value becomes the recovered key.
What versions address the issue?
Version 0.8.7 rejects these share sets before interpolation. The next prerelease in the 0.9 line includes the same rejection.
What can be done if upgrading is not immediately possible?
Before recovery, split each share on periods into four fields, base58-decode the x field, and reject the set if x decodes to zero, including the one-character field "1", or if the value is at or above the applicable threshold described for validation. Repeated x values past the threshold window should also be treated as invalid.