Repository navigation
fix(drive-abci)!: refuse IdentityUpdate added key proof failures without charging the identity (PV15) - #5494
Conversation
…out charging the identity (PV15) An identity update is signed by one of the identity's master keys over its signable bytes, which leave out the proof-of-possession signature of each key it adds. An update whose added key's proof of possession failed was charged to the identity: a processing fee, the nonce used, no key added. From protocol version 15, identity update advanced structure validation 1 refuses such an update without a fee and without using the nonce, as a failed identity signature is, and a block holding one is rejected. A key whose public key data does not decode fails its proof too. A revision mismatch is still charged and is checked first. DRIVE_ABCI_VALIDATION_VERSIONS_V11, the first validation table of protocol version 15, selects it; protocol versions 1-14 keep advanced structure 0 and replay unchanged. check_tx now verifies the added keys' proofs of possession at every protocol version on the first check, after the identity signature and the minimum balance pre-check, and counts those verifications in its fee estimate. This decides mempool admission only; block execution never runs it. Red -> green: - With PLATFORM_V15 pointed back at V10 and the check_tx check removed, 7 of the 13 new or edited tests fail (the three unpaid tests, the three check_tx refusal tests and the check_tx fee estimate test); the six that pin unchanged behaviour pass. With the fix, all 13 pass. - With only the consensus half applied, the check_tx tests still fail. - identity_update_with_encryption_key_check_tx now signs its added key's proof over the transition's signable bytes; its previous version fails once check_tx verifies proofs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. Wait for the missing reviews, or a writer can post |
|
✅ Final review complete — no blockers (commit 07e51f1) · triage: critical |
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-10-19T20:07:55.219Z |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The change correctly isolates the unpaid proof-failure behavior in IdentityUpdate advanced-structure v1, activates it only for protocol version 15, and preserves earlier replay behavior. The check_tx validation and fee-operation accounting are consistent, and CI reports the Rust workspace checks passing. One non-blocking maintainability issue remains: the proof-verification loop is duplicated across the frozen v0 implementation and an unversioned helper used by v1 and check_tx.
🟡 1 suggestion(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The diff is large and changes consensus-critical IdentityUpdate validation, cryptographic proof-of-possession and key-handling behavior, fee charging, nonce use, and protocol-version dispatch in rs-drive-abci. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(lane failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/added_key_proofs_of_possession/mod.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/added_key_proofs_of_possession/mod.rs:33-49: Keep added-key proof verification behind the generation boundary
This helper now owns the proof predicate and signature-verification operation accounting used by advanced-structure v1 and check_tx, while advanced-structure v0 retains an independent copy of the same loop in `advanced_structure/v0/mod.rs`. Because the helper is unversioned, a future change to supported key types, proof semantics, error handling, or recorded operations can silently change protocol-v15 replay behavior and check_tx while leaving pre-v15 block replay on the old loop. The comment documents the need for a new generation, but the code does not enforce that boundary. Factor the common loop into an explicitly frozen, generation-specific helper and have each versioned implementation delegate to the appropriate helper; check_tx should use the intentionally selected admission generation rather than an implicitly mutable consensus helper.
…s generation 0 The verification of the proofs of possession of the keys an identity update adds is now generation 0 (IdentityUpdateAddedKeyProofsOfPossessionValidationV0, validate_added_key_proofs_of_possession_v0 in added_key_proofs_of_possession/v0), and both of its callers name that generation: identity update advanced structure validation 1 and check_tx verification 0. Its doc states that it is frozen once a released protocol version selects it, and that different behaviour belongs in a new generation selected only for the protocol versions that adopt it. This follows identity_create/identity_and_signatures/v0 and identity_create_from_addresses/public_key_signatures/v0, generation-named helpers called by name from each advanced structure generation. No version table field is added: check_tx runs the check at every protocol version, so the field would hold the same value in every table, and check_tx's own generation is already selected through state_transition_to_execution_event_for_check_tx. No behaviour change: the verification loop, its refusals, the order of checks and the recorded signature verification operations are unchanged. Advanced structure validation 0 is untouched. Tests: no new test, since nothing changes behaviour. The drive-abci identity_update and check_tx tests pass unchanged (127 passed, 1 already ignored), including all 11 in proofs_of_possession_of_added_keys. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Waiting for bot review — coderabbitai not yet · thepastaclaw requested changes — dismiss the review or push a fix, 1 thread unresolved — resolve it. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The protocol-version boundary is correctly isolated: pre-PV15 behavior remains unchanged, and the earlier generation-boundary finding is fixed. However, the new first-time check_tx path performs attacker-controlled added-key ECDSA/BLS proof verification without acquiring the existing node-local proof-verification permit, allowing concurrent mempool requests to exhaust validator CPU; CI has no reported failures, but several checks remain in progress.
🔴 1 blocking
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 13: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 14: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This is a large change to consensus-critical IdentityUpdate validation, cryptographic proof-of-possession and key-handling behavior, with protocol-version-gated fee and nonce semantics. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(lane failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs`:
- [BLOCKING] packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs:323-336: Bound added-key proof verification during check_tx
This newly added check performs potentially expensive ECDSA/BLS verification for every IdentityUpdate that reaches first-time admission, but it does not acquire `CheckTxProofVerifier` capacity. An attacker controlling a funded identity can produce valid outer identity signatures while varying only the added-key proof bytes, which are excluded from the signable bytes. Because invalid proofs are rejected before entering the mempool and do not consume the identity nonce, the attacker can repeatedly submit distinct requests and make the node perform the proof loop again. The existing limiter is specifically used to prevent public CheckTx proof work from consuming the capacity needed by consensus processing; the later permit at lines 522-527 only covers shielded proofs and does not protect this new path. Add a weighted permit for the number of added keys and return `CheckTxProofVerificationBusy` when admission capacity is unavailable.
…x proof capacity check_tx verifies the proofs of possession of the keys an identity update adds. That verification now holds the node-local CheckTxProofVerifier capacity, the limiter shielded proof verification in check_tx already uses, so concurrent admission work stays within the capacity reserved for it and does not take what block processing needs. The permit is weighted by the number of added keys (every added key is counted, hash keys included, to keep the weight simple and conservative) and is held only for the verification. When no capacity is free check_tx answers CheckTxProofVerificationBusy, which the handler returns as the same retriable ResourceExhausted status the shielded path gives. An update that adds no key verifies no proof and takes no capacity. The limiter clamps a permit's weight to its whole capacity, and basic structure validation caps an update at max_public_keys_in_creation added keys before this check, so an update adding the most keys allowed is admitted even by a node with the smallest capacity. Mempool admission only: block execution never runs check_tx verification, so there is no consensus or version table change. Tests (identity_update proofs_of_possession_of_added_keys), each mutation-checked against the fix: - busy while capacity is in use, admitted once it is free: fails with the permit removed - capacity given back after a refused and an admitted check: fails with the permit leaked - an update adding no key is admitted with all capacity in use: fails when the permit is taken unconditionally - an update adding max_public_keys_in_creation keys is admitted under a capacity of 1: fails with the weight clamp removed Test would have caught this in CI: busy test fails before the fix, passes after. drive-abci check_tx/identity_update/check_tx_proof_verifier lib tests (131) and the update_identities strategy tests pass; clippy -D warnings and fmt clean. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The reviewed changes correctly add protocol-versioned IdentityUpdate advanced-structure v1 behavior, preserve pre-v15 charging semantics, and bound check_tx proof verification with the existing weighted capacity limiter. The previously reported capacity and generation-boundary issues are fixed at this exact head. No new in-scope correctness, consensus, security, or architectural findings were identified; Rust, JavaScript, Kotlin, and PR Hygiene checks were still in progress in the supplied CI snapshot.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 13: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 14: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This is a large change to consensus-critical IdentityUpdate validation and protocol-version dispatch, directly affecting proof-of-possession cryptography, key handling, fee charging, nonce use, and block acceptance in rs-drive-abci. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(lane failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
Issue being fixed or feature implemented
An
IdentityUpdateis signed by one of the identity's master keys over the transition's signable bytes. Those bytes leave out the proof-of-possession signature of each key the update adds, because each such signature is made over those same bytes. Everything else is signed, including every added key's data, purpose, security level and bounds, the revision and the nonce.Until now an update whose added key's proof of possession failed was charged to the identity: a processing fee was taken, the nonce was used and the key was not added. check_tx did not verify those proofs for
IdentityUpdate, so such an update was admitted to the mempool.#5431 (
IdentityCreate) and #4968 (IdentityCreateFromAddresses) made the same change for the other transitions that register keys with a proof of possession.What was done?
Consensus, from protocol version 15: refuse without a fee
advanced_structurev1 (identity_update/advanced_structure/v1). It matches v0 except that an added key whose proof of possession fails is refused with no action. The block then refuses the update without a fee and without using the nonce, and no key is added. As with any unpaid result,prepare_proposaldrops it andprocess_proposalrejects a block that holds one.identity_update/added_key_proofs_of_possession. Advanced structure v1 and check_tx both call it. Its doc comment says that changing what it refuses, or the operations it records, needs a new advanced structure generation.DRIVE_ABCI_VALIDATION_VERSIONS_V11: V10 with onlyidentity_update_state_transition.advanced_structureset toSome(1). It is the first validation table of protocol version 15 and is referenced only byPLATFORM_V15. Before this,PLATFORM_V15shared V10 withPLATFORM_V14.v15.rsgets a module-doc entry and a// changed:note.DRIVE_ABCI_VALIDATION_VERSIONS_V10,v14.rsandadvanced_structurev0 are untouched.Admission, at every protocol version: refuse at check_tx
IdentityUpdate's added keys. It does this after the identity signature and the minimum balance pre-check, and before the transform, so the verifications count in its fee estimate.Docs
In-place changes to shipped generations
state_transition_to_execution_event_for_check_txv0 (check_tx_verification/v0/mod.rs)IdentityUpdate's added key proofs of possession on the first check.process_raw_state_transitions, whichprepare_proposalandprocess_proposalrun.transaction: None).process_state_transitionv0 (processor/v0/mod.rs): a comment-only edit.How Has This Been Tested?
Tests are in
identity_update/mod.rs, moduleproofs_of_possession_of_added_keys. They run throughPlatform::check_txand throughprocess_raw_state_transitions, whichprepare_proposalandprocess_proposalrun. The owner builds each faulty update and signs it with its master key. The faults are:Consensus:
should_refuse_unpaid_an_identity_update_whose_added_key_proof_of_possession_does_not_verify,..._adding_a_bls_key_whose_data_does_not_decodeand..._with_a_signature_on_an_added_hash_key, at the latest version. Each checks that:should_charge_an_identity_update_whose_added_key_proof_of_possession_does_not_verify_before_protocol_version_15, at protocol versions 1, 13 and 14 with every fault. It checks that the result is paid, the balance drops by exactly the fee, the nonce is used and no key is added. This pins that history replays unchanged.should_charge_an_identity_update_for_a_wrong_revision_whatever_its_added_keys: a wrong revision with a failing proof is charged for the revision.should_refuse_unpaid_an_identity_update_whose_identity_signature_does_not_verify_whatever_its_added_keys, at protocol versions 14 and latest. A bad identity signature is still reported first, both at check_tx and in a block.should_charge_a_signature_verification_for_each_key_a_valid_identity_update_adds, at protocol versions 14 and latest. It runs through the advanced structure dispatcher and asserts identical recorded operations, so valid-update fees are the same at both versions.check_tx, at protocol versions 1, 13, 14 and latest:
should_refuse_at_check_tx_...for each fault; the valid update is still admitted.should_count_the_added_keys_signature_verifications_in_the_check_tx_fee_estimate: the check_tx event carries one signature verification for the identity signature and one per added key.check_tx::v0::tests::identity_update_with_encryption_key_check_txused to leave its added key's proof empty. It now signs the proof over the transition's signable bytes, as a client does.Red → green:
PLATFORM_V15pointed back atDRIVE_ABCI_VALIDATION_VERSIONS_V10and the check_tx check removed, 7 of the 13 new or edited tests fail: the three unpaid tests (the block returnsPaidConsensusError), the three check_tx refusal tests (admitted at protocol version 1) and the check_tx fee estimate test (one signature verification instead of three). The six tests that pin unchanged behaviour pass both ways, by design. With the fix, all 13 pass.identity_update_with_encryption_key_check_txfails once check_tx verifies proofs.Runs:
cargo test -p drive-abci --lib: 4335 passed, 17 ignored (taken before the review-driven test additions; those 4 tests and the rest of the module were re-run below).cargo test -p drive-abci --lib -- identity_update check_tx advanced_structure_without_state: 128 passed, 1 ignored (verify_check_tx_on_data_contract_create, already ignored onv5.1-dev).cargo test -p platform-version: 27 passed.RUST_MIN_STACK=4194304 cargo test -p drive-abci --test strategy_tests -- update_identities identit comprehensive top_up: 38 passed.cargo clippy -p drive-abci -p platform-version --all-targets --all-features --locked -- --no-deps -D warnings: clean.cargo fmt --all -- --check: clean.Breaking Changes
IdentityUpdatewhose added key's proof of possession fails. Before, the identity was charged. Consensus at protocol versions 1–14 is unchanged.DRIVE_ABCI_VALIDATION_VERSIONS_V11for protocol version 15 must amend this table rather than add another, and keepidentity_update_state_transition.advanced_structure: Some(1).Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
07e51f1/skip-botsproceeds without the ones not yet reported/self-reviewedWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.