<!-- XE-0096 · Unguarded pk[:12] slice in VerifyMultisig panics the verifying node · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0096>. The page is the record; this is the same page for reading.*

XE-0096 · Bounty

# Unguarded pk\[:12\] slice in VerifyMultisig panics the verifying node

Triaging
claimed High
[xe#160](https://github.com/xeprotocol/xe/issues/160)
filed 2026-10-29 02:46 UTC
by 0xMissy22

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   High

Area
:   Node / API

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-10 00:11 UTC

Told
:   2026-11-08 09:32 UTC

### Patches

- [xe#164](https://github.com/xeprotocol/xe/pull/164) open by fangjian-bit
  core/multisig: use shortKey helper to prevent slice bounds panic on short signer pubkeys (#160)

### History

- [23492](https://bounty.xe.network/log/23492) 2026-11-08 09:32 UTC github.labels
- [23468](https://bounty.xe.network/log/23468) 2026-11-08 09:32 UTC reply.mirrored
- [23361](https://bounty.xe.network/log/23361) 2026-11-08 09:31 UTC reply.sent
- [23351](https://bounty.xe.network/log/23351) 2026-11-08 09:31 UTC proposal.adopted
- [23310](https://bounty.xe.network/log/23310) 2026-11-08 09:31 UTC proposal.adopted
- [23309](https://bounty.xe.network/log/23309) 2026-11-08 09:31 UTC ticket.status new → triaging
- [23308](https://bounty.xe.network/log/23308) 2026-11-08 09:31 UTC proposal.adopted
- [23307](https://bounty.xe.network/log/23307) 2026-11-08 09:31 UTC ticket.award
- [23306](https://bounty.xe.network/log/23306) 2026-11-08 09:31 UTC proposal.adopted
- [23305](https://bounty.xe.network/log/23305) 2026-11-08 09:31 UTC ticket.facts
- [23304](https://bounty.xe.network/log/23304) 2026-11-08 09:31 UTC proposal.adopted
- [23303](https://bounty.xe.network/log/23303) 2026-11-08 09:31 UTC ticket.facts

[Full history](https://bounty.xe.network/log?ref=XE-0096) · [JSON](https://bounty.xe.network/v1/tickets/XE-0096) · [markdown](https://bounty.xe.network/XE-0096.md)

### Report

# Unguarded pk\[:12\] slice in VerifyMultisig panics the verifying node

## Summary

`VerifyMultisig` formats error strings with unguarded `pk[:12]` slices. A
crafted multisig block carrying a short signer public key panics the
verifying goroutine. What that panic does to the node depends on the
delivery path, and the paths were tested separately (see Proof of concept):
the HTTP path recovers per connection, the gossip path filters this block
shape before it reaches verification, and the sync path has no recover at
all.

## Impact

An unauthenticated, crafted `multisig_open` block (no victim account needed
for the open variant; the block is never stored) panics verification. Via
HTTP the panic kills only that connection — the node survives. Via sync,
which a node triggers automatically when it peers with anyone, the panic
runs in an unrecovered goroutine and would kill the process; that path is
traced through the code, not live-executed (see Caveats). This is targeted
denial of service, not a compromise, which is why it is filed as High
rather than Severe.

Suggested program tier: **High** (targeted DoS).

## Root cause

- `core/multisig.go` `VerifyMultisig`: `pk[:12]` appears in three error
  paths — duplicate signer, signer not in keyset, and bad signature. Any
  signer public key shorter than 12 characters panics with a slice-bounds
  error instead of returning an error.
- `net/gossip_validate.go` never checks signature-entry public key length,
  and the block hash does not cover signatures, so a short key reaches
  verification intact.
- Path-by-path recover status, all read from the code: the HTTP path
  (`api/handler.go` `submitBlock` → `node.SubmitBlock` → `AddBlock`) has no
  recover of its own, but the standard library HTTP server recovers panics
  per connection, so an HTTP-delivered panic kills the connection, not the
  process (proven live, below). The gossip subscribe loop
  (`net/gossip.go`) drops blocks whose single `Signature` field is not 128
  characters before they reach `handleIncoming`, so this multisig block
  shape — which carries only the `Signatures` list — never reaches
  verification over gossip. The sync path (`net/sync.go`: `ConnectedF` →
  `spawnGate.spawn` → `requestSync` → `AddSyncedBlock`) has no recover
  anywhere on it; the only `recover()` in `net/` is the Messenger handler,
  which is not on this path.
- The sibling code is safe, which confirms this is an oversight rather than a
  pattern: `VerifyMultisigAny` and the statechain verifier use a
  length-safe short-key helper.

## Proof of concept

Target: `xeprotocol/xe` @ `978785929bc17a2f4ab30c383e5fc9cf4d634512`
(2026-10-15). Two harnesses, both against the real `core` package; the
repository itself is not modified.

Attached PoCs: `pocs/harness-slice1-main.go.txt` (the `C5` sections, unit
plus subprocess `AddBlock` crash) and `pocs/slice3-poc-main.go.txt`
(independent second harness), both byte-identical copies of the runnable
sources.

Run (Go 1.25.14):

```
export PATH="$HOME/.local/go/bin:$PATH"
cd harness-slice1
GOPROXY=off go run .
```

Observed output (verbatim):

```
1-char pubkey: PANIC: runtime error: slice bounds out of range [:12] with length 1
11-char pubkey: PANIC: runtime error: slice bounds out of range [:12] with length 11
control full-length unknown pubkey: returned err=signer cdcdcdcdcdcd not in keyset (no panic)
subprocess exit err=exit status 2
RESULT: process crashed with slice-bounds panic as predicted
```

The boundary is exact: 11 characters panic, 12 characters error cleanly.
A subprocess running a crafted `multisig_open` through `Ledger.AddBlock`
died with exit status 2 on the slice-bounds panic.

### Live local node, HTTP path (executed 2026-10-29)

A node built from the same HEAD was run locally and isolated (no bootstrap
peers, no discovery, loopback API only — no testnet traffic). A control
block with a full-length unknown signer key was rejected cleanly
(`signer cdcdcdcdcdcd not in keyset`, node unaffected). The 1-character-key
block then produced this in the node's log (verbatim excerpt):

```
http: panic serving 127.0.0.1:35394: runtime error: slice bounds out of range [:12] with length 1
github.com/xeprotocol/xe/core.VerifyMultisig(...)
    /home/hatch/workspace/xe/repo/core/multisig.go:99
github.com/xeprotocol/xe/core.(*Ledger).verifyBlockCredential(...)
    /home/hatch/workspace/xe/repo/core/ledger.go:1436
github.com/xeprotocol/xe/core.(*Ledger).addBlock(...)
    /home/hatch/workspace/xe/repo/core/ledger.go:801
github.com/xeprotocol/xe/node.(*Node).SubmitBlock(...)
    /home/hatch/workspace/xe/repo/node/node.go:1283
github.com/xeprotocol/xe/api.(*Handler).submitBlock(...)
    /home/hatch/workspace/xe/repo/api/handler.go:507
github.com/xeprotocol/xe/api.(*Handler).handleSubmitMultisigOpen(...)
```

The node process survived: its API answered afterwards. So over HTTP the
panic is real but recovered per connection — it kills the connection, not
the node. The process-kill claim rests on the sync path, traced above and
not live-executed.

## Reproduction steps

1. Craft a `multisig_open` block with a keyset and a signature entry whose
   public key is a single character, with a correct block hash (the hash
   must be computed with the target network's network-ID prefix).
2. Submit via `POST /blocks/multisig_open`: the verifying goroutine panics
   (visible in the node log); the connection dies; the node survives.
3. For the process-kill variant, deliver the same block over sync (a peer
   connection triggers `requestSync` automatically): the panic runs in an
   unrecovered goroutine. This variant is traced through the code, not
   executed against a live node in this report.

## Recommended fix

Use a length-safe short-key helper (as the statechain verifier already does)
at all three sites, and add length validation for signature entries at
ingestion.

## Severity

- CVSS 3.1: 7.5 — `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`
- CWE-248 (Uncaught Exception)

## Caveats

- Proof status, stated per path: the in-process panic is executed and
  reproduced (exit status 2); the live HTTP panic is executed against a
  local isolated node and shown to be recovered per connection (node
  survived); the gossip path is traced and shown to filter this block
  shape before verification; the sync-path process kill is traced through
  the code (`spawnGate.spawn` has no recover) but NOT executed against a
  live node — a live sync-delivery attempt was blocked by tooling during
  this audit and was not retried, so it is claimed as traced, not proven.
  A triager who credits only the executed paths should weigh this as
  connection-kill denial of service, not process kill.
- The same slicing shape was noted at two other sites (`core/vote.go` and
  `core/ledger.go`); they are not claimed here and would need their own
  verification.
- No public prior report of the `pk[:12]` panic mechanism was found (dedup
  queries recorded in the audit's DEDUP-BASELINE.md).
- This reproduction runs against the repository code at the stated HEAD. No
  testnet transactions were sent as part of this report.

Payout address (XE): eff2c51dd8457df740b919226cd9b37a2944e5abea7501094db80234f87f010e

Best,
Chaplin

[harness-slice1-main.go.txt](https://github.com/user-attachments/files/34109946/harness-slice1-main.go.txt)
[slice3-poc-main.go.txt](https://github.com/user-attachments/files/34109947/slice3-poc-main.go.txt)

### Thread

**fangjian-bit**2026-10-29 03:39 UTCgithub

I have submitted a clean fix in PR #164 (https://github.com/xeprotocol/xe/pull/164).

### Summary of Fix

- Introduced a length-safe `shortKey(s string) string` helper in `core/multisig.go` aligned with the existing implementation in `statechain/chain.go:shortKey`.
- Replaced the three unguarded `pk[:12]` slice sites in `VerifyMultisig` with `shortKey(pk)`.
- Added unit tests in `core/multisig_test.go` covering 1-character, 11-character, 12-character boundary, and empty public key payloads, verifying that all scenarios return clear errors with 0 panics.

**Joseph Denne**team2026-11-08 09:32 UTCgithub

Thanks for the detailed report. We have confirmed the behaviour and it is being handled; we will update this ticket when there is more to share.
