Repository navigation
fix: close share-credit duplicate-detection bypass via string aliasing - #9
Merged
Merged
Conversation
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>
1 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RegisterSubmit(BitcoinJob.cs) built its dedup key from the raw submittedextraNonce2/nTime/nonce/versionBitsstrings, but the block header is built from parsed values. Many different strings parse to the same bytes —extraNonce2had no length check at all (an odd-length string drops the trailing nibble,"0x"is stripped, non-hex characters are tolerated), andversionBitsis only masked when applied to the header but stored raw in the key.review-miningcore-positive.mdC1,review-miningcore-negative.mdF1).Fix
extraNonce2/nTime/nonce/versionBitsas strict hex of their exact expected length before anything else runs.nTime/nonceintegers and the masked "effective" version bits actually mixed into the header — not the raw strings.extraNonce2is lower-cased before being used in the key.BitcoinJob.csonly.RegisterSubmitthere is not virtual and not called from any other coin family.AdventurecoinJobandProgpowJobextendBitcoinJobwithout overridingProcessShare, so they inherit the fix automatically.Test plan
dotnet build, 0 errors)0x-prefixed replay is now rejected with "incorrect size of extranonce2" rather than credited🤖 Generated with Claude Code