Hashly / research · NOTE 02
Rebasing upstream safely: consensus regressions in PoW forks.
Why fork maintainers learn about upstream security fixes late by design, four public cases where forks inherited a consensus bug, and a method to diff your fork against upstream.
Late by design
Most proof-of-work chains are forks of Bitcoin Core, Monero, Zcash or one of their descendants. They inherit consensus code, and with it the bugs that upstream finds later. The difficulty is timing: upstream projects deliberately disclose security fixes after the fact, so that users can upgrade before attackers learn what changed.
Bitcoin Core’s published policy makes this explicit. Low-severity issues are disclosed two weeks after the release that fixes them; medium and high severity issues two weeks after the last affected release reaches end of life, roughly a year after the fix. Critical issues are handled case by case. A fork maintainer who reads only the advisory page learns about a medium-severity fix about a year after it shipped upstream.
The fix itself is in public code from day one, often under a neutral commit message. The defence is to track upstream commits, not announcements.
Four public cases
An optimization removed a consensus check (CVE-2018-17144)
In Bitcoin Core 0.14 an optimization skipped a costly check, during initial block validation, that a transaction does not spend the same input twice; the UTXO logic was expected to catch it with an assertion. In 0.15 a redesign of UTXO tracking changed that assertion subtly. The disclosure explains the result: in 0.14 a duplicated input crashed the node, and from 0.15.0 to 0.16.2 a miner could, in some conditions, spend the same output twice and inflate the supply. The fix shipped in 0.16.3 in September 2018, and the issue was reported in parallel to projects supporting other cryptocurrencies.
For forks the lesson is direct: a performance pull request in validation is a consensus change. Any fork that pulled 0.14–0.16 validation code inherited both halves of the bug.
A fix in one fork, the bug in all of them (CryptoNote key images)
In February 2017 the Monero Research Lab found that a CryptoNote key image could be modified with a small-subgroup point so that one output could be spent several times, creating coins in a way an observer could not detect. Monero patched it within days, describing the point release as a fix for a different denial-of-service issue, and published the details in May 2017 after notifying the affected CryptoNote coins. At disclosure, the post listed coins that had not yet updated.
The fix was a one-line validity check on key images. A fork that tracked only its own direct parent, and not its siblings, had no way to see it.
A fix that only works if you activate it (CVE-2019-7167)
In March 2018 a cryptographer at the Zcash Company found a flaw in the zk-SNARK parameter setup of the original Zcash launch that allowed counterfeiting shielded value. Zcash remediated it with the Sapling network upgrade in October 2018 and disclosed it in February 2019, publishing its correspondence with downstream forks. The fix was not a patch that could be cherry-picked: it depended on a network upgrade moving transactions to a new proving system. A fork that carried the code but did not activate the upgrade was still exposed.
A structure that every reimplementation must copy (CVE-2012-2459)
Bitcoin’s Merkle tree duplicates the last hash on odd levels, so two different transaction lists can produce the same Merkle root. A node that marked such a mutated block as invalid by its hash could be made to reject the valid block with the same hash. The check lives in Bitcoin Core’s validation, and any fork that rewrites block validation, or any second client and pool software that builds blocks, has to reproduce it.
What a rebase quietly moves
Beyond named vulnerabilities, a rebase changes code that forks rarely re-read because it looks like configuration:
- Activation heights. Upstream buries old soft forks as fixed heights. If the fork’s parameters still carry the parent’s heights, or zero, rules can be active from genesis or never.
- Minimum chain work and assumed-valid blocks. Bitcoin Core 24.0.1 (December 2022) added header pre-synchronization against low-difficulty header spam; the issue was disclosed as CVE-2019-25220 in September 2024, after the last vulnerable release reached end of life. The defence relies on a minimum chain work that is meaningful for your chain; a value left at zero or copied from another chain weakens it.
- P2P limits. Message sizes, inventory and address limits, orphan pools and eviction logic are tuned upstream against attacks that were disclosed later. A fork that changed block size or block time should check that each limit still holds.
- Serialization. Fork-specific header fields and transaction versions interact with upstream mutation checks and witness serialization.
- RPC and wallet defaults. What binds to which interface and which RPC calls exist changes between releases.
A diff method
The method we use before a fork release is mechanical first, then manual on the paths that matter.
git remote add upstream <upstream repository>
git fetch upstream --tags
git merge-base fork/main upstream/<release-branch>
# upstream commits not present in the fork, by patch content
git log --oneline --cherry-pick --right-only \
fork/main...upstream/<release-branch> -- \
src/validation.cpp src/consensus/ src/script/ \
src/pow.cpp src/net_processing.cpp src/primitives/- Classify every commit in that list as carried, not applicable or pending, with a reason. Patch-identical commits drop out automatically; rewritten ones do not, so the list is a starting point, not an answer.
- Map upstream release notes and published advisories to commits in the list, so that each disclosed fix has a known state in the fork.
- Diff consensus-critical files between the fork and its merge base with renames and whitespace ignored, and read every hunk in validation, script, proof of work and net processing.
- Check chain parameters line by line against the fork’s own history: heights, minimum chain work, assumed-valid block, checkpoints, message start bytes and seeds.
- Run upstream functional and fuzz tests against the fork’s parameters and list what had to be skipped.
Rebase checklist
You know your merge base for every upstream file you carryRB-01Consensus / fundsRecord the upstream tag and commit your fork last synced, per component if you mixed sources (node, wallet, crypto libraries).
Upstream fixes are tracked by commit, not by advisoryRB-02Consensus / fundsList upstream commits since the merge base that touch validation, consensus, script, proof of work and net processing, and mark each one as carried, not applicable or pending. Do not wait for the advisory.
Every compiled-in soft fork is active on your chainRB-03Consensus / fundsFor each deployment upstream treats as buried, check its height or state in your chain parameters. A rule that is compiled but never activated leaves its checks off.
Chain parameters were set for your chain, not copiedRB-04Liveness / DoSMinimum chain work, assumed-valid block, checkpoints, message start bytes, ports, seeds and address prefixes are updated for your chain each release.
Performance changes in validation got a consensus reviewRB-05Consensus / fundsCaching, parallel validation and UTXO refactors are where CVE-2018-17144 came from. Read them as consensus changes, with tests for the checks they could skip.
Serialization and header fields round-tripRB-06Consensus / fundsFork-specific header fields (solutions, extra nonces, version bits) and transaction formats are tested for round-trip serialization and for the mutation checks upstream applies.
Upstream tests and fuzzers run against your parametersRB-07Liveness / DoSFunctional and fuzz tests carried over from upstream actually run in CI on your chain parameters; skipped tests are listed with a reason.
Sources
Public documents only, checked on 3 Dec 2026. No client work, private report or undisclosed issue is used or referred to on this page.
- Bitcoin Core security advisories and disclosure policy
- Bitcoin Core: CVE-2018-17144 full disclosure
- Bitcoin Core: disclosure of CVE-2019-25220, headers memory DoS (18 Sep 2024)
- Monero: Disclosure of a major bug in CryptoNote based currencies (17 May 2017)
- Electric Coin Co.: Zcash counterfeiting vulnerability successfully remediated (CVE-2019-7167)
- Bitcoin Wiki: Common Vulnerabilities and Exposures (CVE-2012-2459 and others)
- Git documentation: git cherry and git log --cherry-pick