Skip to content

Reject blocks and transactions with the wrong number of authorizations - #36

Merged
Ash-L2L merged 2 commits into
LayerTwo-Labs:masterfrom
1440000bytes:fix/auth-count-check
Jun 16, 2026
Merged

Reject blocks and transactions with the wrong number of authorizations#36
Ash-L2L merged 2 commits into
LayerTwo-Labs:masterfrom
1440000bytes:fix/auth-count-check

Conversation

@1440000bytes

Copy link
Copy Markdown
Contributor

Authorizations were paired with inputs positionally via zip, with no check that the two counts match. Because zip stops at the shorter iterator, supplying fewer authorizations than there are inputs requiring one left the surplus inputs completely unverified, both the address check and the signature check simply skipped them.

This allowed any UTXO to be spent without a valid signature. In the extreme case, a transaction (or whole block body) with zero authorizations passes validation: the address-check zip and the batch signature verification both run over empty input sets and succeed. Since the block Header commits only to the merkle root (which does not cover authorizations), a single crafted block could spend arbitrary UTXOs i.e. steal any funds on the chain.

Fix

Enforce an exact authorization count at all three validation entry points, before the existing zip-based address/signature checks:

  • block::validate — block validation
  • block::prevalidate — the path apply_block actually uses when connecting
  • State::validate_transaction — mempool admission

The required count is computed from spent_utxos_requiring_auth() rather than the raw input count, so legitimate batch-ICANN transactions which intentionally carry fewer authorizations than inputs still validate. A new Error::WrongNumberOfAuthorizations { expected, received } variant is returned on mismatch.

Test

Adds validate_transaction_rejects_missing_authorization, which funds an address, then attempts to spend the UTXO with an empty authorization list and asserts it is rejected with WrongNumberOfAuthorizations { expected: 1, received: 0 }. It also confirms the same transaction validates once a correct
authorization is supplied.

Verified the test fails against the unpatched code (the unauthorized spend is accepted and returns a fee of 100 sat) and passes with the fix applied.

@Ash-L2L
Ash-L2L force-pushed the fix/auth-count-check branch from 1f2d8a6 to dacd927 Compare June 16, 2026 17:32
@Ash-L2L
Ash-L2L merged commit ce3fd8a into LayerTwo-Labs:master Jun 16, 2026
8 of 9 checks passed
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.

2 participants