Repository navigation
Description
Summary
The full-block acceptance path can store an AuxPoW payload that is invalid under the height-specific commitment-order rule when the corresponding header is already known.
On mainnet, display-order commitments are required from genesis. A peer can first provide a valid display-order header, then provide a full block with the same pure header fields but a separately mined internal-order AuxPoW payload. The second payload passes the context-free EITHER check, bypasses the contextual header check because the block hash is already indexed, and is written to disk. A later height-aware disk read rejects the stored payload and can turn the poisoned block into a fatal read failure during reconnect or reorg.
This should be fixed before mainnet launch.
Verified on
origin/1.0.0 at 988756471aeecdf4463c04be49da2b7b89a98c21.
Source trace
- Mainnet activates display-order commitments at height 0:
src/kernel/chainparams.cpp#L139. auxpow::Validatedefaults toCommitmentValidation::EITHER:src/auxpow.h#L44.CheckBlockHeader, and thereforeCheckBlock, use that default:src/validation.cpp#L4283-L4287.- The height-specific check is in
ContextualCheckBlockHeader:src/validation.cpp#L4616-L4620. AcceptBlockHeaderreturns immediately for an already-known hash without checking the incoming header's AuxPoW payload:src/validation.cpp#L4705-L4719.ContextualCheckBlockhas no AuxPoW validation and the incoming full block is subsequently written to disk:src/validation.cpp#L4631-L4699,src/validation.cpp#L4867-L4898.CPureBlockHeader::GetHash()serializes only the pure header;CBlockHeader::auxpowis outside that base:src/primitives/block.cpp#L11-L14,src/primitives/block.h#L23-L42.- The low-level positional
ReadBlockagain usesEITHER, while the indexed overload revalidates with the height-specific mode:src/node/blockstorage.cpp#L1683-L1723,src/node/blockstorage.cpp#L1726-L1742. - Indexed read failure is fatal on the normal connect path:
src/validation.cpp#L3386-L3404.
Attack sequence
- Mine a valid display-order AuxPoW payload for block
Band relay its header. The node creates a block-index entry containing that payload. - Separately mine an internal-order AuxPoW payload for the same pure child header. This is possible because the AuxPoW payload is not part of
B's hash. - Send a full block for
Bcarrying the internal-order payload to a node that already has the first header. - The full block passes
CheckBlockunderEITHER; the known-header early return skips the height-specific display check;ContextualCheckBlockdoes not replace it; the payload is stored. - The in-memory block can connect immediately. A later indexed disk read rejects the payload under
DISPLAY, causing reconnect/reorg failure and potentiallyFatalError.
The attacker must produce parent proof of work for the substitute payload, but bootstrap difficulty makes this much cheaper at launch than after the network matures.
Expected behavior
Every full block must satisfy the commitment-order rule for its indexed height, regardless of whether its header hash was already known.
Recommended fix
Re-run auxpow::Validate with CommitmentValidationForHeight(..., pindex->nHeight) on the full-block path before relay or disk write. This is preferable to comparing the payload byte-for-byte with whichever valid header payload happened to arrive first, which would make block acceptance depend on arrival order when multiple display-valid AuxPoW proofs exist.
Do not loosen indexed disk reads to EITHER; that would remove the active display-order consensus rule.
Regression coverage
Add a validation test that:
- builds two valid AuxPoW payloads for the same pure child header, one display-order and one internal-order;
- accepts the display-order header first;
- submits the full block with the internal-order substitute;
- verifies rejection with the AuxPoW commitment error before disk write; and
- verifies a display-order substitute still follows the intended acceptance rule.
Also exercise direct ProcessNewBlock, headers-first download, and getblockfrompeer-equivalent requested-block paths.
Acceptance criteria
- A full block with a commitment order invalid at its height is rejected even when its hash is already in the block index.
- No height-invalid AuxPoW payload can be written to block storage through normal block acceptance.
- Indexed and full-block acceptance use the same height-specific commitment mode.
- Regression tests cover the known-header substitution case.
Activity