{"answers":{"affected":"2 open source packages ship an affected version, including @keep-network/tbtc-v2.","exploited":"There is no known exploitation of GHSA-wg2x-rv86-mmpx in the wild and no public exploit code.","fix":"Upgrade @keep-network/tbtc-v2 to 1.5.2 or later.","what":"GHSA-wg2x-rv86-mmpx is a vulnerability in @keep-network/tbtc-v2, published on 19 Jan 2024. An attacker needs administrator access to exploit it, with no action from the victim."},"fix_prompt":"Check this codebase for GHSA-wg2x-rv86-mmpx and fix it if it is affected.\n\nWhat it is: GHSA-wg2x-rv86-mmpx is a vulnerability in @keep-network/tbtc-v2, published on 19 Jan 2024. An attacker needs administrator access to exploit it, with no action from the victim.\nExploitation: There is no known exploitation of GHSA-wg2x-rv86-mmpx in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- @keep-network/tbtc-v2 (npm): affected all versions; fixed in 1.5.2\n- @keep-network/tbtc-v2 (npm): affected all versions; fixed in 1.5.2\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/GHSA-wg2x-rv86-mmpx/ (Markdown: https://insights.sbomify.com/GHSA-wg2x-rv86-mmpx/index.md)","id":"GHSA-wg2x-rv86-mmpx","markdown":"https://insights.sbomify.com/GHSA-wg2x-rv86-mmpx/index.md","name":"GHSA-wg2x-rv86-mmpx","record":{"aliases":[],"analysis":{"component_type":"library","fix_type":"patch","impacts":["security_bypass"],"network_reachable":"yes","non_default_config":false,"product_category":"Bitcoin SPV library","requires_auth":"high_privilege","summary":"An SPV maintainer can forge valid proofs for invalid transactions by exploiting Merkle tree malleability, bypassing mining costs to commit fraud.","user_interaction":"not_required","vuln_class":"business_logic"},"analysis_generated_by":"qwen3.8-flash-next","assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"## 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)","ecosystems":["npm"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":true,"headline":"SPV Merkle proof malleability allows the maintainer to prove invalid transactions","id":"GHSA-wg2x-rv86-mmpx","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"npm","product":null,"products":[],"type":"business_logic","year":"2024"},"n_packages":2,"n_references":null,"packages":[{"ecosystem":"npm","fixed":["1.5.2"],"introduced":["0"],"last_affected":[],"package":"@keep-network/tbtc-v2","purl":null,"source":"GHSA-wg2x-rv86-mmpx"},{"ecosystem":"npm","fixed":["1.5.2"],"introduced":["0"],"last_affected":[],"package":"@keep-network/tbtc-v2","purl":"pkg:npm/%40keep-network/tbtc-v2","source":"GHSA-wg2x-rv86-mmpx"}],"products":null,"published":"2024-01-19","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":"An SPV maintainer can forge valid proofs for invalid transactions by exploiting Merkle tree malleability, bypassing mining costs to commit fraud.","url":"https://insights.sbomify.com/GHSA-wg2x-rv86-mmpx/"}