GHSA-wg2x-rv86-mmpx: @keep network/tbtc v2 SPV Merkle Proof Malleability Allows Vulnerability

HIGH
Published
Advisory Summary

GHSA-wg2x-rv86-mmpx is a HIGH spv merkle proof malleability allows vulnerability (General Security Weakness) affecting @keep network/tbtc v2 libraries in the npm ecosystem. The issue involves spv merkle proof malleability allows the maintainer to prove invalid transactions. Remediation is available by upgrading affected packages to version 1.5.2.

GHSA-wg2x-rv86-mmpx at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-wg2x-rv86-mmpx
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification General Security Weakness
Affected Product @keep network/tbtc v2
Package Ecosystem npm
Published Date
Last Updated

How to Fix GHSA-wg2x-rv86-mmpx

To remediate this vulnerability, upgrade all affected @keep network/tbtc v2 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@keep-network/tbtc-v2 fixed: 1.5.2
npm install @keep-network/tbtc-v2@1.5.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @keep-network/tbtc-v2

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-wg2x-rv86-mmpx, inspect your project dependencies using npm:

npm ls @keep-network/tbtc-v2

Analyze the terminal output to locate any version of @keep network/tbtc v2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.5.2), your application is affected.

Note: The npm ls @keep-network/tbtc-v2 command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under General Security Weakness. In @keep network/tbtc v2, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary By publishing specially crafted transactions on the Bitcoin blockchain, the SPV maintainer can produce seemingly valid SPV proofs for fraudulent transactions. The issue was originally identified by Least Authority in the tBTC Bridge V2 Security Audit Report as _Issue B: Bitcoin SPV Merkle Proofs Can Be Faked_. A mitigation was believed to have been in place, but this turned out to contain an error, and the issue had not been effectively mitigated. ### Details This is achieved by creating a 64-byte transaction that the fraudulent transaction treats as a node in its merkle proof: The attacker creates the malicious transaction `E` and calculates an unusual but valid transaction `D`, so that the last 32 bytes of `D` are a part of the merkle proof of `E`: ``` D = foo | hash256(E') E' = bar | hash256(E) ``` `foo` and `bar` are arbitrary 32-byte values selected to facilitate this attack. The attacker can then publish `D` and wait for it to be mined. A valid SPV proof for `D` can then be transformed into a proof for `E` by prepending `bar` and `foo` to the merkle proof, and changing the transaction index into one matching `E`'s implied position in the merkle tree. Calculating a suitable value for `E'` has been estimated to require between 2\^60 to 2\^81 operations. By contrast, the current Bitcoin hashrate is approximately 2\^69. Thus the cost of performing the requisite brute-force is at most similar to, or possibly up to 1,000,000 times lower than, the cost of mining 6 Bitcoin blocks at the current difficulty. ### Impact The vulnerability does not enable the SPV maintainer to do anything they would not have been able to do otherwise. However, the ability to bypass the need to mine 6 blocks at the current difficulty makes abusing the SPV maintainer position significantly cheaper. ### Patches Adding the coinbase transaction and its merkle proof into the SPV proofs prevents this issue, by increasing the brute-force required to 2\^224. If the length of the coinbase proof matches the length of the transaction proof, and both proofs are valid for the same header, we can trust that the exploit has not been abused for the transaction. ### Workarounds The trusted SPV maintainer position prevents this issue ### References [Weaknesses in Bitcoin’s Merkle Root Construction](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20190225/a27d8837/attachment-0001.pdf) [Leaf-Node weakness in Bitcoin Merkle Tree Design](https://bitslog.com/2018/06/09/leaf-node-weakness-in-bitcoin-merkle-tree-design/) [SPV proof verification vulnerable to potential (but expensive to exploit) Merkle tree problem \#192](https://github.com/summa-tx/bitcoin-spv/issues/192) [tBTC Bridge V2 Security Audit Report](https://leastauthority.com/static/publications/LeastAuthority_KeepNetwork_tBTC_Bridge_v2_Updated_Final_Audit_Report.pdf)

GHSA-wg2x-rv86-mmpx Affected @keep network/tbtc v2 Versions

1 component(s)
Fixed Versions:
1.5.2
Product / Package Ecosystem Affected Versions Fixed Version
@keep-network/tbtc-v2
npm
< 1.5.2
1.5.2

References

Frequently Asked Questions

What is GHSA-wg2x-rv86-mmpx?
GHSA-wg2x-rv86-mmpx is a security vulnerability in @keep network/tbtc v2 involving SPV Merkle proof malleability allows the maintainer to prove invalid transactions under General Security Weakness.
Which @keep network/tbtc v2 versions are affected?
Affected versions include releases prior to 1.5.2 across affected packages: @keep-network/tbtc-v2.
What version fixes GHSA-wg2x-rv86-mmpx?
Upgrading to 1.5.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @keep-network/tbtc-v2 affected?
Yes, @keep-network/tbtc-v2 is affected in releases prior to 1.5.2. Upgrade your dependency to 1.5.2 or later.
What CWE is associated with GHSA-wg2x-rv86-mmpx?
GHSA-wg2x-rv86-mmpx is classified under General Security Weakness.
How can I check npm dependencies for GHSA-wg2x-rv86-mmpx?
Run the dependency tree command: 'npm ls @keep-network/tbtc-v2'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-wg2x-rv86-mmpx",
  "modified" : "2024-01-19T22:07:47Z",
  "published" : "2024-01-19T22:07:47Z",
  "aliases" : [ ],
  "summary" : "SPV Merkle proof malleability allows the maintainer to prove invalid transactions",
  "details" : "## Summary\nBy publishing specially crafted transactions on the Bitcoin blockchain, the SPV maintainer can produce seemingly valid SPV proofs for fraudulent transactions.\n\nThe issue was originally identified by Least Authority in the tBTC Bridge V2 Security Audit Report as _Issue B: Bitcoin SPV Merkle Proofs Can Be Faked_. A mitigation was believed to have been in place, but this turned out to contain an error, and the issue had not been effectively mitigated.\n\n### Details\nThis is achieved by creating a 64-byte transaction that the fraudulent transaction treats as a node in its merkle proof:\n\nThe attacker creates the malicious transaction `E` and calculates an unusual but valid transaction `D`, so that the last 32 bytes of `D` are a part of the merkle proof of `E`:\n\n```\nD = foo | hash256(E')\nE' = bar | hash256(E)\n```\n\n`foo` and `bar` are arbitrary 32-byte values selected to facilitate this attack.\n\nThe attacker can then publish `D` and wait for it to be mined. A valid SPV proof for `D` can then be transformed into a proof for `E` by prepending `bar` and `foo` to the merkle proof, and changing the transaction index into one matching `E`'s implied position in the merkle tree.\n\nCalculating a suitable value for `E'` has been estimated to require between 2\\^60 to 2\\^81 operations. By contrast, the current Bitcoin hashrate is approximately 2\\^69. Thus the cost of performing the requisite brute-force is at most similar to, or possibly up to 1,000,000 times lower than, the cost of mining 6 Bitcoin blocks at the current difficulty.\n\n### Impact\nThe vulnerability does not enable the SPV maintainer to do anything they would not have been able to do otherwise. However, the ability to bypass the need to mine 6 blocks at the current difficulty makes abusing the SPV maintainer position significantly cheaper.\n\n### Patches\nAdding the coinbase transaction and its merkle proof into the SPV proofs prevents this issue, by increasing the brute-force required to 2\\^224. If the length of the coinbase proof matches the length of the transaction proof, and both proofs are valid for the same header, we can trust that the exploit has not been abused for the transaction.\n\n### Workarounds\nThe trusted SPV maintainer position prevents this issue\n\n### References\n[Weaknesses in Bitcoin’s Merkle Root Construction](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20190225/a27d8837/attachment-0001.pdf)\n\n[Leaf-Node weakness in Bitcoin Merkle Tree Design](https://bitslog.com/2018/06/09/leaf-node-weakness-in-bitcoin-merkle-tree-design/)\n\n[SPV proof verification vulnerable to potential (but expensive to exploit) Merkle tree problem \\#192](https://github.com/summa-tx/bitcoin-spv/issues/192)\n\n[tBTC Bridge V2 Security Audit Report](https://leastauthority.com/static/publications/LeastAuthority_KeepNetwork_tBTC_Bridge_v2_Updated_Final_Audit_Report.pdf)",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@keep-network/tbtc-v2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.5.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.5.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/keep-network/tbtc-v2/security/advisories/GHSA-wg2x-rv86-mmpx"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/summa-tx/bitcoin-spv/issues/192"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/keep-network/tbtc-v2/commit/20a6fb1bfb23d4a3d5b90e00eaa7cc2abc9a2871"
  }, {
    "type" : "WEB",
    "url" : "https://bitslog.com/2018/06/09/leaf-node-weakness-in-bitcoin-merkle-tree-design"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/keep-network/tbtc-v2"
  }, {
    "type" : "WEB",
    "url" : "https://leastauthority.com/static/publications/LeastAuthority_KeepNetwork_tBTC_Bridge_v2_Updated_Final_Audit_Report.pdf"
  }, {
    "type" : "WEB",
    "url" : "https://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20190225/a27d8837/attachment-0001.pdf"
  } ],
  "database_specific" : {
    "cwe_ids" : [ ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-01-19T22:07:47Z",
    "nvd_published_at" : null
  }
}