{"id":"XE-0096","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"160","source_url":"https://github.com/xeprotocol/xe/issues/160","reporter_id":32,"title":"Unguarded pk[:12] slice in VerifyMultisig panics the verifying node","area":"node-api","claimed_tier":"high","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":null,"status":"triaging","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:26.056158+00:00","updated_at":"2026-11-10T00:11:46.445612+00:00","source_created_at":"2026-10-29T02:46:12+00:00","told_at":"2026-11-08T09:32:08+00:00","status_changed_at":"2026-11-08T09:31:52.177494+00:00","url":"https://bounty.xe.network/XE-0096","body":"# Unguarded pk[:12] slice in VerifyMultisig panics the verifying node\n\n## Summary\n\n`VerifyMultisig` formats error strings with unguarded `pk[:12]` slices. A\ncrafted multisig block carrying a short signer public key panics the\nverifying goroutine. What that panic does to the node depends on the\ndelivery path, and the paths were tested separately (see Proof of concept):\nthe HTTP path recovers per connection, the gossip path filters this block\nshape before it reaches verification, and the sync path has no recover at\nall.\n\n## Impact\n\nAn unauthenticated, crafted `multisig_open` block (no victim account needed\nfor the open variant; the block is never stored) panics verification. Via\nHTTP the panic kills only that connection — the node survives. Via sync,\nwhich a node triggers automatically when it peers with anyone, the panic\nruns in an unrecovered goroutine and would kill the process; that path is\ntraced through the code, not live-executed (see Caveats). This is targeted\ndenial of service, not a compromise, which is why it is filed as High\nrather than Severe.\n\nSuggested program tier: **High** (targeted DoS).\n\n## Root cause\n\n- `core/multisig.go` `VerifyMultisig`: `pk[:12]` appears in three error\n  paths — duplicate signer, signer not in keyset, and bad signature. Any\n  signer public key shorter than 12 characters panics with a slice-bounds\n  error instead of returning an error.\n- `net/gossip_validate.go` never checks signature-entry public key length,\n  and the block hash does not cover signatures, so a short key reaches\n  verification intact.\n- Path-by-path recover status, all read from the code: the HTTP path\n  (`api/handler.go` `submitBlock` → `node.SubmitBlock` → `AddBlock`) has no\n  recover of its own, but the standard library HTTP server recovers panics\n  per connection, so an HTTP-delivered panic kills the connection, not the\n  process (proven live, below). The gossip subscribe loop\n  (`net/gossip.go`) drops blocks whose single `Signature` field is not 128\n  characters before they reach `handleIncoming`, so this multisig block\n  shape — which carries only the `Signatures` list — never reaches\n  verification over gossip. The sync path (`net/sync.go`: `ConnectedF` →\n  `spawnGate.spawn` → `requestSync` → `AddSyncedBlock`) has no recover\n  anywhere on it; the only `recover()` in `net/` is the Messenger handler,\n  which is not on this path.\n- The sibling code is safe, which confirms this is an oversight rather than a\n  pattern: `VerifyMultisigAny` and the statechain verifier use a\n  length-safe short-key helper.\n\n## Proof of concept\n\nTarget: `xeprotocol/xe` @ `978785929bc17a2f4ab30c383e5fc9cf4d634512`\n(2026-10-15). Two harnesses, both against the real `core` package; the\nrepository itself is not modified.\n\nAttached PoCs: `pocs/harness-slice1-main.go.txt` (the `C5` sections, unit\nplus subprocess `AddBlock` crash) and `pocs/slice3-poc-main.go.txt`\n(independent second harness), both byte-identical copies of the runnable\nsources.\n\nRun (Go 1.25.14):\n\n```\nexport PATH=\"$HOME/.local/go/bin:$PATH\"\ncd harness-slice1\nGOPROXY=off go run .\n```\n\nObserved output (verbatim):\n\n```\n1-char pubkey: PANIC: runtime error: slice bounds out of range [:12] with length 1\n11-char pubkey: PANIC: runtime error: slice bounds out of range [:12] with length 11\ncontrol full-length unknown pubkey: returned err=signer cdcdcdcdcdcd not in keyset (no panic)\nsubprocess exit err=exit status 2\nRESULT: process crashed with slice-bounds panic as predicted\n```\n\nThe boundary is exact: 11 characters panic, 12 characters error cleanly.\nA subprocess running a crafted `multisig_open` through `Ledger.AddBlock`\ndied with exit status 2 on the slice-bounds panic.\n\n### Live local node, HTTP path (executed 2026-10-29)\n\nA node built from the same HEAD was run locally and isolated (no bootstrap\npeers, no discovery, loopback API only — no testnet traffic). A control\nblock with a full-length unknown signer key was rejected cleanly\n(`signer cdcdcdcdcdcd not in keyset`, node unaffected). The 1-character-key\nblock then produced this in the node's log (verbatim excerpt):\n\n```\nhttp: panic serving 127.0.0.1:35394: runtime error: slice bounds out of range [:12] with length 1\ngithub.com/xeprotocol/xe/core.VerifyMultisig(...)\n    /home/hatch/workspace/xe/repo/core/multisig.go:99\ngithub.com/xeprotocol/xe/core.(*Ledger).verifyBlockCredential(...)\n    /home/hatch/workspace/xe/repo/core/ledger.go:1436\ngithub.com/xeprotocol/xe/core.(*Ledger).addBlock(...)\n    /home/hatch/workspace/xe/repo/core/ledger.go:801\ngithub.com/xeprotocol/xe/node.(*Node).SubmitBlock(...)\n    /home/hatch/workspace/xe/repo/node/node.go:1283\ngithub.com/xeprotocol/xe/api.(*Handler).submitBlock(...)\n    /home/hatch/workspace/xe/repo/api/handler.go:507\ngithub.com/xeprotocol/xe/api.(*Handler).handleSubmitMultisigOpen(...)\n```\n\nThe node process survived: its API answered afterwards. So over HTTP the\npanic is real but recovered per connection — it kills the connection, not\nthe node. The process-kill claim rests on the sync path, traced above and\nnot live-executed.\n\n## Reproduction steps\n\n1. Craft a `multisig_open` block with a keyset and a signature entry whose\n   public key is a single character, with a correct block hash (the hash\n   must be computed with the target network's network-ID prefix).\n2. Submit via `POST /blocks/multisig_open`: the verifying goroutine panics\n   (visible in the node log); the connection dies; the node survives.\n3. For the process-kill variant, deliver the same block over sync (a peer\n   connection triggers `requestSync` automatically): the panic runs in an\n   unrecovered goroutine. This variant is traced through the code, not\n   executed against a live node in this report.\n\n## Recommended fix\n\nUse a length-safe short-key helper (as the statechain verifier already does)\nat all three sites, and add length validation for signature entries at\ningestion.\n\n## Severity\n\n- CVSS 3.1: 7.5 — `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`\n- CWE-248 (Uncaught Exception)\n\n## Caveats\n\n- Proof status, stated per path: the in-process panic is executed and\n  reproduced (exit status 2); the live HTTP panic is executed against a\n  local isolated node and shown to be recovered per connection (node\n  survived); the gossip path is traced and shown to filter this block\n  shape before verification; the sync-path process kill is traced through\n  the code (`spawnGate.spawn` has no recover) but NOT executed against a\n  live node — a live sync-delivery attempt was blocked by tooling during\n  this audit and was not retried, so it is claimed as traced, not proven.\n  A triager who credits only the executed paths should weigh this as\n  connection-kill denial of service, not process kill.\n- The same slicing shape was noted at two other sites (`core/vote.go` and\n  `core/ledger.go`); they are not claimed here and would need their own\n  verification.\n- No public prior report of the `pk[:12]` panic mechanism was found (dedup\n  queries recorded in the audit's DEDUP-BASELINE.md).\n- This reproduction runs against the repository code at the stated HEAD. No\n  testnet transactions were sent as part of this report.\n\nPayout address (XE): eff2c51dd8457df740b919226cd9b37a2944e5abea7501094db80234f87f010e\n\nBest,\nChaplin\n\n[harness-slice1-main.go.txt](https://github.com/user-attachments/files/34109946/harness-slice1-main.go.txt)\n[slice3-poc-main.go.txt](https://github.com/user-attachments/files/34109947/slice3-poc-main.go.txt)","patch_refs":[{"id":170,"repo":"xeprotocol/xe","kind":"pr","ref":"164","title":"core/multisig: use shortKey helper to prevent slice bounds panic on short signer pubkeys (#160)","url":"https://github.com/xeprotocol/xe/pull/164","note":"","state":"open","author":"fangjian-bit","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"}],"thread":[{"id":45,"source":"github","source_ref":"6487240971","author":"fangjian-bit","team":false,"body":"I have submitted a clean fix in PR #164 (https://github.com/xeprotocol/xe/pull/164).\n\n### Summary of Fix\n- Introduced a length-safe `shortKey(s string) string` helper in `core/multisig.go` aligned with the existing implementation in `statechain/chain.go:shortKey`.\n- Replaced the three unguarded `pk[:12]` slice sites in `VerifyMultisig` with `shortKey(pk)`.\n- 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.","created_at":"2026-10-29T03:39:37+00:00"},{"id":805,"source":"github","source_ref":"6719848876","author":"Joseph Denne","team":true,"body":"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.","created_at":"2026-11-08T09:32:08+00:00"}]}