Repository navigation
fix: close High/Medium findings from both deep-review reports (batch 2) - #10
Merged
Merged
Conversation
Addresses the remaining High/Medium findings from review-miningcore-positive.md and review-miningcore-negative.md, after the Critical share-dedup bypass (#9) and the PoolEffort perf fix (#8): - ShareRecorder.cs: sanitize Worker/UserAgent (strip control chars incl. NUL, cap length) once at the single choke point before any persistence. A NUL byte previously made Postgres reject an entire shares+blocks batch - spanning every pool, not just the attacker's - tripping the circuit breaker and losing block candidates to the recovery file. [F2/H1] - IPAccessWhitelistMiddleware.cs: whitelist prefix match is now case-insensitive. ASP.NET Core routing is case-insensitive, so "/API/admin/..." reached AdminApiController without matching the case-sensitive "/api/admin" prefix check. [H2] - BitcoinJobManagerBase.cs: pool startup now fails if the daemon reports the pool address as a script (P2SH) address, instead of silently falling back to a P2PKH decode of the script hash - an unspendable coinbase output. Also stops treating BIP22 "duplicate"/"duplicate-inconclusive"/ "inconclusive" submitblock responses as hard rejections; they mean the block is already known or valid-but-not-yet-connected, not rejected, so a block that later confirms no longer risks never getting a DB row. [F3b/F4] - BlockRepository.cs + createdb.sql + add_block_dedup_index.sql: unique partial index on (poolid, blockheight, hash) with ON CONFLICT DO NOTHING, so a retried commit or a replayed recovery file can no longer insert - and credit - the same block twice. [F5] - ClusterConfigValidation.cs: reject pool configs whose RewardRecipients percentages sum above 100, which otherwise overpays recipients straight out of the wallet's float. [F11] - PoolApiController.cs: the miner-settings "proof of ownership" check now uses the caller's real connection IP instead of one supplied in the request body, and clamps the payment threshold's upper bound. [M5/F9] - PayoutManager.cs: per-pool Postgres advisory lock (held on one connection for the whole payout pass) so a second process against the same database skips a pool instead of paying it out alongside the first. [F10] - BitcoinPayoutHandler.cs: the insufficient-funds notice throttle is now keyed per-pool in a static dictionary instead of an instance field, which reset every cycle because handlers are resolved fresh per payout run. [L1] - BitcoinJobManager.cs: auxDiff1 is now a ConcurrentDictionary; it was written from up to 8 concurrent aux-submit tasks. [L2] - BitcoinPool.cs: guard banManager.Ban() against pool-level banning being disabled (banManager null) while the cluster-level BanOnLoginFailure default still says to ban - previously an NRE. Also moved the share publish before the stratum response, since RespondAsync can throw on a backed-up send queue; previously that could happen after the daemon accepted a block but before it was ever published. [L4/F3a] - PayoutErrorClassifier.cs: treat RPC -4 "Transaction commit failed" as outcome-unknown. 0.10-0.13-derived wallets (several supported legacy daemons) record the transaction in the wallet before broadcasting, so this error does not mean nothing was sent. [F6] - PPLNSPaymentScheme.cs / PPLNSBFPaymentScheme.cs: skip shares with NetworkDifficulty <= 0 instead of dividing by it, which throws OverflowException and aborts every other block queued in the same UpdatePoolBalancesAsync pass. [M1] - EquihashPayoutHandler.cs: bound the z_sendmany/sendcurrency operation-wait loops to 10 minutes. z_getoperationresult can return an empty array forever once the daemon has already handed out and forgotten a result, and PayoutManager processes pools sequentially, so this previously halted every other pool too. [M2] - AuxPowSerializer.cs: bound FindNonce's treeSize doubling and throw instead of spinning forever when chains collide at every tree size (equal daemon-reported chainids, or two SlotByNonce chains) - this runs inside BuildCoinbase, in UpdateJob's pipeline, so an infinite loop here freezes job updates for the whole parent pool. [F7] - RpcClient.cs: redact walletpassphrase RPC calls from Trace-level logging. The log level can be raised to Trace at runtime via the admin API, which would otherwise write the wallet passphrase to disk. [M4] Not included in this batch (larger, separately scoped): non-Bitcoin payout handler idempotency (Kaspa et al., H3), the shutdown-buffer-flush gap in ShareRecorder (F3c), and permanent orphan reclassification (F3d/M3). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
Follow-up to #8 (perf) and #9 (Critical share-dedup bypass). Closes the remaining High/Medium findings from both independent deep-review reports run against this repo (
review-miningcore-positive.md,review-miningcore-negative.md):ShareRecorder.csbefore any persistence. Previously a single NUL byte could fail an entire shares+blocks batch across every pool and trip the circuit breaker.inconclusive/duplicatemisclassified as rejection (High) — no longer treated as a hard submission failure.blocksrows double-crediting a reward (Medium) — unique partial index +ON CONFLICT DO NOTHING(with a migration script).PayoutManager.-4"commit failed" treated as nothing-sent (Medium) — now outcome-unknown, matching how these wallets actually behave.networkdifficulty = 0aborts a pool's whole payout pass (Medium) — guarded in PPLNS/PPLNSBF.z_sendmany/sendcurrencywait loop can spin forever, halting every pool (Medium) — bounded to 10 minutes.FindNonceinfinite loop on a chain-id collision (Medium, latent) — bounded, throws instead of hanging job updates.NoticeThrottlereset every payout cycle, unsynchronizedauxDiff1dictionary,banManagerNRE when pool-level banning is off, publish-before-respond reorder (block candidate could be lost on a backed-up send queue).Not included (larger, separately scoped): non-Bitcoin payout-handler idempotency (Kaspa et al.), the shutdown-buffer-flush gap in
ShareRecorder, permanent orphan reclassification.Test plan
dotnet build, 0 errors, pre-existing warnings only)add_block_dedup_index.sqlmigration against the production DB before/at deploy🤖 Generated with Claude Code