Repository navigation
Conversation
minyanyi
left a comment
There was a problem hiding this comment.
Reviewed the spend-input normalization changes and the new regression coverage. The shared _normalize_spend_inputs() helper closes the malformed input shape paths before both block application and mempool admission, preserves minting transactions with empty internal inputs, and keeps duplicate spend-input rejection centralized.
Local verification:
python -B node\test_utxo_db.py-> 73 passedpython -m py_compile node\utxo_db.py node\test_utxo_db.pygit diff --check origin/main...HEAD
No blocking issues found.
kekehanshujun
left a comment
There was a problem hiding this comment.
Reviewed the spend-input normalization path in both apply_transaction() and mempool_add().
The shared _normalize_spend_inputs() boundary rejects non-list inputs, non-dict entries, missing/blank box_id values, and duplicate box_ids before raw indexing or mempool input claims. I also checked the later mempool existence and conservation checks still run after normalization, so malformed inputs fail closed without locking the existing UTXO.
Verification run locally on the PR version:
python -B node\test_utxo_db.py-> 73 passedpython -m py_compile node\utxo_db.py node\test_utxo_db.py-> passed
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Thanks for contributing. Approved.
TJCurnutte
left a comment
There was a problem hiding this comment.
Approved. I focused this pass on the spend-input shape guard in both transaction application and mempool admission.
Validation run from detached PR head b38d21c9e615:
git diff --check origin/main...HEAD -- node/utxo_db.py node/test_utxo_db.py
/tmp/rustchain-bounty-review-venv/bin/python -B -m py_compile node/utxo_db.py node/test_utxo_db.py
PYTHONPATH=node /tmp/rustchain-bounty-review-venv/bin/python -m pytest -q node/test_utxo_db.pyResult: 73 passed, 13 subtests passed in 0.37s.
I also ran a runtime probe over the malformed spend-input cases this patch is meant to harden: inputs=None, a string instead of a list, a dict missing box_id, blank/whitespace box_id, a non-dict list entry, and duplicate use of the same real box_id. For every case:
apply_transaction()returnedFalsewithout raising.mempool_add()returnedFalsewithout raising.- Alice’s balance stayed at
100 * UNIT, Bob stayed at0. - The real input box was not marked as a mempool double-spend.
mempool_get_block_candidates()stayed empty.
The shared _normalize_spend_inputs() path now makes the duplicate and malformed-input checks consistent before either apply-time balance mutation or mempool input locking. I do not see a blocking issue in this patch.
ZacharyZhang-NY
left a comment
There was a problem hiding this comment.
Reviewed PR #5454 at head b38d21c.
Validation performed:
- Checked rustchain-bounties #2819. The scoped category includes UTXO code-quality validation hardening and mempool DoS prevention.
- git fetch origin pull/5454/head:review-pr-5454 --force
- git diff --check origin/main...review-pr-5454 -- node/utxo_db.py node/test_utxo_db.py -> passed.
- python -m py_compile node/utxo_db.py node/test_utxo_db.py on an extracted PR-head tree -> passed.
- python -B node/test_utxo_db.py on the extracted PR-head tree -> 73 tests passed.
- python -m pytest node/test_utxo_db.py -q --confcutdir= -> 73 passed.
The shared _normalize_spend_inputs() path now validates spend input shape before both transaction application and mempool admission. The new coverage confirms malformed input containers, non-dict entries, missing or blank box_id values, and duplicate box_id values fail validation without applying balance changes or claiming mempool inputs. Approving.
ZacharyZhang-NY
left a comment
There was a problem hiding this comment.
Reviewed PR #5454 at head b38d21c.
Validation performed:
- Checked rustchain-bounties#2819. This is a UTXO spend-input validation hardening finding covering malformed
inputsshapes at bothapply_transaction()andmempool_add()boundaries. - git fetch origin pull/5454/head:review-pr-5454 --force
- git diff --check origin/main...review-pr-5454 -- node/utxo_db.py node/test_utxo_db.py -> passed.
- python -m py_compile node/utxo_db.py node/test_utxo_db.py on an extracted PR-head tree -> passed.
- From the extracted PR-head
node/directory: python -B -m unittest test_utxo_db.TestUtxoDB.test_malformed_spend_inputs_rejected_without_exception test_utxo_db.TestUtxoDB.test_mempool_rejects_malformed_spend_inputs_without_locking -v -> 2 passed. - From the extracted PR-head
node/directory: python -B test_utxo_db.py -> 73 passed. - python test_bcos_spdx_check.py on the extracted PR-head tree -> passed.
Malformed spend inputs now fail closed before raw indexing or mempool UTXO claiming, and duplicate box_id rejection is shared across transaction application and mempool admission. Approving.
508704820
left a comment
There was a problem hiding this comment.
Reject malformed UTXO spend inputs. HIGH VALUE - UTXO validation is core to chain integrity. Verify: (1) Malformed inputs are rejected before any state mutation. (2) Input format validation covers all UTXO types. (3) Double-spend of malformed inputs is impossible. - Xeophon (security review, UTXO)
|
Security Review ✅ IMPORTANT UTXO spend-input validation gap fix. Before this patch, malformed inputs could crash the node:
These are DoS vectors — attacker sends malformed transaction and the node crashes instead of rejecting it. Fix adds proper type checking and validation before any DB operations. Reviewed by Xeophon - Solana: Lt9nERv6VHsojw15LpFeiaabuphAggzfLF9sM9UXRrZ |
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Great work on this PR. 🚀
PR Review — PR #5454Title: [UTXO-BUG] Reject malformed UTXO spend inputs Author: galanime What I reviewed
Observations
LGTM pending CI. Good validation fix with appropriate test coverage. Input validation is critical for UTXO security. Bounty: #2782 |
|
Closing as stale branch — would cause destructive deletions if merged. Your branch is 155 commits behind current main. Filed during the May 11-13 contributor burst, the codebase has since moved substantially. GitHub's Bounty credit acknowledged where applicableMost of the canonical fixes from your work-period have already shipped via other contributors' parallel PRs that landed earlier this week. Specific cases credited via the Codex audit batches:
If you want fresh reviewRebase against current main and verify your diff matches the size of your original changes: If the deletion count is much higher than what you intended, the branch is still picking up stale assumptions — recreate from a fresh main. Thanks for the contribution work. |
Summary
Fixes a UTXO spend-input validation gap in
node/utxo_db.py.Before this patch, malformed
inputspayloads could reach raw indexing in both transaction application and mempool admission:inputs=Noneor a string could raise instead of returning a validation failure.box_idvalues could raise or drift into later validation.box_idhandling was local toapply_transaction()and not shared withmempool_add().The patch adds a shared
_normalize_spend_inputs()helper and applies it at both boundaries, so malformed spend inputs fail closed before they can raise, persist, or claim UTXOs in the mempool.Bounty
RTC74b80ab40602e5ae31819912b2fca974484e5dabDuplicate Boundary
This overlaps the broad UTXO validation area, but it covers a distinct spend-input shape path on current
main: malformedinputsare normalized before bothapply_transaction()andmempool_add(). Prior nearby fixes covered output metadata, timestamps, tx types, data inputs, or transfer endpoint scalar fields.Verification
python -B node\test_utxo_db.py-> 73 passedpython -m py_compile node\utxo_db.py node\test_utxo_db.py-> passedgit diff --check-> passedpython -B test_bcos_spdx_check.py-> passedThis is a public receive address only. No private key, seed phrase, keystore, password, bank, exchange, withdrawal, or transfer action is included.