Skip to content

fix: close share-credit duplicate-detection bypass via string aliasing - #9

Merged
colneech-dev merged 1 commit into
mainfrom
fix/share-dedup-aliasing
Nov 24, 2026
Merged

colneech-dev merged 1 commit into
mainfrom
fix/share-dedup-aliasing

Conversation

@colneech-dev

Copy link
Copy Markdown
Owner

Summary

  • RegisterSubmit (BitcoinJob.cs) built its dedup key from the raw submitted extraNonce2/nTime/nonce/versionBits strings, but the block header is built from parsed values. Many different strings parse to the same bytes — extraNonce2 had no length check at all (an odd-length string drops the trailing nibble, "0x" is stripped, non-hex characters are tolerated), and versionBits is only masked when applied to the header but stored raw in the key.
  • Either gap lets a miner replay a single valid share an unlimited number of times for full credit, taking reward from other miners on any PPLNS/PPLNSBF/PROP pool.
  • Independently confirmed by both deep-review reports run against this repo (review-miningcore-positive.md C1, review-miningcore-negative.md F1).

Fix

  • Validate extraNonce2/nTime/nonce/versionBits as strict hex of their exact expected length before anything else runs.
  • Build the dedup key from the parsed nTime/nonce integers and the masked "effective" version bits actually mixed into the header — not the raw strings. extraNonce2 is lower-cased before being used in the key.
  • Scoped to BitcoinJob.cs only. RegisterSubmit there is not virtual and not called from any other coin family. AdventurecoinJob and ProgpowJob extend BitcoinJob without overriding ProcessShare, so they inherit the fix automatically.

Test plan

  • Builds clean (dotnet build, 0 errors)
  • Deploy and confirm legitimate ASIC-boost / version-rolling miners still submit valid shares (no false duplicate-share rejections)
  • Confirm a crafted odd-length/0x-prefixed replay is now rejected with "incorrect size of extranonce2" rather than credited

🤖 Generated with Claude Code

RegisterSubmit built its dedup key from the raw submitted strings
(extraNonce2, nTime, nonce, versionBits), but the block header is built
from parsed values. Many different strings parse to the same bytes:

- extraNonce2 had no length check at all, so an odd-length string (the
  dropped trailing nibble), a "0x"-prefixed string, or one with
  non-hex characters could decode to the same bytes as an already-seen
  share while producing a new, distinct dedup key.
- versionBits was stored raw in the key, but only the masked bits are
  ever mixed into the header (SerializeHeader). Any value outside the
  negotiated mask - or simply not negotiating mining.configure at all -
  let a miner vary the key without changing the header.

Either one lets a miner replay a single valid share an unlimited
number of times for full credit on PPLNS/PPLNSBF/PROP pools, taking
reward from other miners. Confirmed independently by both deep-review
reports (review-miningcore-positive.md C1, review-miningcore-negative.md
F1).

Fix: validate extraNonce2/nTime/nonce/versionBits as strict hex of
their exact expected length before anything else runs, and build the
dedup key from the parsed nTime/nonce integers and the masked
"effective" version bits actually applied to the header - not the raw
strings. extraNonce2 is lower-cased before being used in the key.

Scoped to BitcoinJob.cs only (RegisterSubmit there is not virtual and
not called from any other coin family); AdventurecoinJob and ProgpowJob
extend BitcoinJob without overriding ProcessShare, so they inherit the
fix.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@colneech-dev
colneech-dev merged commit 87d67fa into main Nov 24, 2026
1 check passed
@colneech-dev
colneech-dev deleted the fix/share-dedup-aliasing branch November 24, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant