GHSA-8986-V76Q-8VR2

Vulnerability from github – Published: 2026-03-02 22:09 – Updated: 2026-03-02 22:09
VLAI
Summary
@keep-network/tbtc-v2 revealing P2PKH deposit with a wrapped P2SH script
Details

Overview

P2PKH has 20 bytes just like P2SH. We protect against revealing P2PKH deposits by manually assembling the expected P2SH script in the smart contract and comparing hashes. However, we missed the case when the attacker embeds a valid P2SH inside of P2PKH as an output script. bitcoin-spv library extracts the P2SH from P2PKH and we treat it as a valid P2SH output.

This does not lead to stealing funds but can lead to protocol insolvency.

The off-chain client handles this case correctly, but the problem is in the optimistic minting bot. The bot assumes that if the funding TX exists on Bitcoin with the right amount and it was successfully revealed, the transaction is valid.

https://bugs.immunefi.com/magnus/672/projects/502/bug-bounty/reports/55982

Steps

Since there is a 24-hour governance delay on upgrading the Bridge smart contract, we are going to pause optimistic minting.

  1. Pause optimistic minting.
  2. Deploy new Bridge implementation with Deposit library containing a fix, WITHOUT VERIFYING THE CODE on Etherscan.
  3. Schedule upgrade transaction.
  4. After 24 hours, finalize upgrade.
  5. Unpause optimistic minting.
Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 1.8.1"
      },
      "package": {
        "ecosystem": "npm",
        "name": "@keep-network/tbtc-v2"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "1.8.2"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [],
  "database_specific": {
    "cwe_ids": [
      "CWE-328"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-03-02T22:09:19Z",
    "nvd_published_at": null,
    "severity": "HIGH"
  },
  "details": "# Overview\n\nP2PKH has 20 bytes just like P2SH. We protect against revealing P2PKH deposits by manually assembling the expected P2SH script in the smart contract and comparing hashes. However, we missed the case when the attacker embeds a valid P2SH inside of P2PKH as an output script. bitcoin-spv library [extracts the P2SH from P2PKH](https://github.com/keep-network/bitcoin-spv/blob/856849612ef49114af18c0f407eaa74afc2ee4be/solidity/contracts/BTCUtils.sol#L610-L612) and we treat it as a valid P2SH output.\n\nThis does not lead to stealing funds but can lead to protocol insolvency.\n\nThe off-chain client handles this case correctly, but the problem is in the optimistic minting bot. The bot assumes that if the funding TX exists on Bitcoin with the right amount and it was successfully revealed, the transaction is valid.\n\nhttps://bugs.immunefi.com/magnus/672/projects/502/bug-bounty/reports/55982\n\n# Steps\n\nSince there is a 24-hour governance delay on upgrading the Bridge smart contract, we are going to pause optimistic minting.\n\n1. Pause optimistic minting.\n2. Deploy new Bridge implementation with Deposit library containing a fix, WITHOUT VERIFYING THE CODE on Etherscan.\n3. Schedule upgrade transaction.\n4. After 24 hours, finalize upgrade.\n5. Unpause optimistic minting.",
  "id": "GHSA-8986-v76q-8vr2",
  "modified": "2026-03-02T22:09:19Z",
  "published": "2026-03-02T22:09:19Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/threshold-network/tbtc-v2/security/advisories/GHSA-8986-v76q-8vr2"
    },
    {
      "type": "WEB",
      "url": "https://bugs.immunefi.com/magnus/672/projects/502/bug-bounty/reports/55982"
    },
    {
      "type": "WEB",
      "url": "https://github.com/keep-network/bitcoin-spv/blob/856849612ef49114af18c0f407eaa74afc2ee4be/solidity/contracts/BTCUtils.sol#L610-L612"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/threshold-network/tbtc-v2"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "@keep-network/tbtc-v2 revealing P2PKH deposit with a wrapped P2SH script"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.

Loading…

Detection rules are retrieved from Rulezet.

Loading…

Loading…