# GHSA-8986-v76q-8vr2: @keep-network/tbtc-v2 revealing P2PKH deposit with a wrapped P2SH script

> An attacker can cause protocol insolvency by embedding a valid P2SH script inside a P2PKH output, bypassing deposit validation checks in the optimistic minting bot.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 2 Mar 2026

## What is GHSA-8986-v76q-8vr2?

GHSA-8986-v76q-8vr2 is a vulnerability in @keep-network/tbtc-v2, published on 2 Mar 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

# 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](https://github.com/keep-network/bitcoin-spv/blob/856849612ef49114af18c0f407eaa74afc2ee4be/solidity/contracts/BTCUtils.sol#L610-L612) 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.

## Which versions are affected by GHSA-8986-v76q-8vr2?

2 open source packages ship an affected version, including @keep-network/tbtc-v2.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `@keep-network/tbtc-v2` | npm | All versions | 1.8.2 |
| `@keep-network/tbtc-v2` | npm | All versions | 1.8.2 |

## How do I fix GHSA-8986-v76q-8vr2?

Upgrade @keep-network/tbtc-v2 to 1.8.2 or later.

## Is GHSA-8986-v76q-8vr2 being exploited?

There is no known exploitation of GHSA-8986-v76q-8vr2 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-8986-v76q-8vr2 and fix it if it is affected.

What it is: GHSA-8986-v76q-8vr2 is a vulnerability in @keep-network/tbtc-v2, published on 2 Mar 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-8986-v76q-8vr2 in the wild and no public exploit code.

Affected packages and fixed versions:
- @keep-network/tbtc-v2 (npm): affected all versions; fixed in 1.8.2
- @keep-network/tbtc-v2 (npm): affected all versions; fixed in 1.8.2

Task:
1. 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.
2. 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.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-8986-v76q-8vr2/ (Markdown: https://insights.sbomify.com/GHSA-8986-v76q-8vr2/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-8986-v76q-8vr2

---
From sbomify Insights: https://insights.sbomify.com/GHSA-8986-v76q-8vr2/
Summaries are generated and may contain mistakes; the official description above is the record.
