Get a Demo

Let's Patch It!

Book a short call with one our specialists, we'll walk you through how Endor Patches work, and ask you a few questions about your environment (like your primary programming languages and repository management). We'll also send you an email right after you fill out the form, feel free to reply with any questions you have in advance!

CVE

GHSA-8986-v76q-8vr2

@keep-network/tbtc-v2 revealing P2PKH deposit with a wrapped P2SH script
Back to all
CVE

GHSA-8986-v76q-8vr2

@keep-network/tbtc-v2 revealing P2PKH deposit with a wrapped P2SH script

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.

Package Versions Affected

Package Version
patch Availability
No items found.

Automatically patch vulnerabilities without upgrading

Fix Without Upgrading
Detect compatible fix
Apply safe remediation
Fix with a single pull request

CVSS Version

Severity
Base Score
CVSS Version
Score Vector
C
H
U
-
C
H
U
0
-
3.1
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
C
H
U
-

Related Resources

No items found.

References

https://github.com/threshold-network/tbtc-v2/security/advisories/GHSA-8986-v76q-8vr2, https://bugs.immunefi.com/magnus/672/projects/502/bug-bounty/reports/55982, https://github.com/keep-network/bitcoin-spv/blob/856849612ef49114af18c0f407eaa74afc2ee4be/solidity/contracts/BTCUtils.sol#L610-L612, https://github.com/threshold-network/tbtc-v2

Severity

7.5

CVSS Score
0
10

Basic Information

Ecosystem
Base CVSS
7.5
EPSS Probability
0%
EPSS Percentile
0%
Introduced Version
0
Fix Available
1.8.2

Fix Critical Vulnerabilities Instantly

Secure your app without upgrading.
Fix Without Upgrading