Skip to content

fix: Verify DAO lock size before tx-pool script execution#5236

Open
Officeyutong wants to merge 2 commits into
nervosnetwork:developfrom
Officeyutong:fix-security-advisory-script-verify-cpu-consumption
Open

fix: Verify DAO lock size before tx-pool script execution#5236
Officeyutong wants to merge 2 commits into
nervosnetwork:developfrom
Officeyutong:fix-security-advisory-script-verify-cpu-consumption

Conversation

@Officeyutong

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Queued tx-pool verification could execute transaction scripts before running DaoScriptSizeVerifier. For remote transactions, the script execution limit comes from the peer-declared cycle count, bounded by max_block_cycles. This allowed a peer to relay a resolved DAO transaction with a lock-size mismatch and an otherwise expensive script, causing the verify worker to spend cycles before the transaction was rejected by the DAO lock-size rule.

What is changed and how it works?

Run the cheap contextual checks without script execution first, then run DaoScriptSizeVerifier, and only execute scripts after the DAO lock-size rule passes. This keeps the existing verification behavior while rejecting malformed DAO withdrawal transactions before they can consume script verification cycles.

Related changes

  • PR to update owner/repo:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression
  • Breaking backward compatibility

@Officeyutong Officeyutong marked this pull request as ready for review June 10, 2026 08:45
@Officeyutong Officeyutong requested a review from a team as a code owner June 10, 2026 08:45
@Officeyutong Officeyutong requested review from quake and removed request for a team June 10, 2026 08:45
Comment thread tx-pool/src/util.rs Outdated
Comment on lines +124 to +139
let verifier = ContextualTransactionVerifier::new(
Arc::clone(&rtx),
consensus,
data_loader,
tx_env,
);
verifier
.verify(max_tx_verify_cycles, true)
.and_then(|_| {
DaoScriptSizeVerifier::new(
rtx,
Arc::clone(&rtx),
snapshot.cloned_consensus(),
snapshot.as_data_loader(),
)
.verify()?;
Ok(result)
verifier.verify(max_tx_verify_cycles, false)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't realy need to make these changes?

@eval-exec

Copy link
Copy Markdown
Collaborator

I think the ideal shape would be move DaoScriptSizeVerifier into ContextualTransactionVerifier , What do you think? @zhangsoledad

@Officeyutong Officeyutong force-pushed the fix-security-advisory-script-verify-cpu-consumption branch from 3124892 to 7f01972 Compare June 10, 2026 12:59
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