Repository navigation
chain: reject HMS transfer addresses with surrounding whitespace - #28
Conversation
The signing payload and shape validation trim addresses, but settlement credits the raw tx strings, so a padded recipient settles into an account row no address lookup can find and strands the funds now that the applier is wired (merged in jokeez#26). Reject raw != trimmed in ValidateHmsTransferShape (submit and apply-time re-validation both use it). Tests: zz_hms_transfers_settle_test.go (padded-address submit table + seeded-row apply rejection; red on main bdc2ef2, green on this branch).
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe HMS transfer shape validator now rejects sender or destination addresses with surrounding whitespace. Regression tests cover whitespace-padded addresses submitted to the transaction pool and a padded destination inserted directly into the pending pool. ChangesHMS address validation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk is identified for the HMS address whitespace change; it is ready for normal merge checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change is narrow and protective: padded addresses are rejected before funds move. No introduced or worsened security concern was identified. Deployment and failure-recovery evidence remains incomplete, and rollback would restore the previous acceptance behavior. Retained concerns Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
PR Summary by QodoReject HMS transfers with surrounding address whitespace
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history |
|
Thanks Bobby — good catch, and nice that you tied it back to the #26 review gap instead of just filing another report. Merged. The trim-at-sign / credit-raw mismatch is exactly the kind of thing that only shows up once settle is live, so appreciate you re-checking main after #27. HMS-only scope is fine for now; if you want to mirror the same guard on transfer_v1 / SUP in one small follow-up PR, we’ll take it. Docs for /api/hms/tx/send can wait unless you feel like adding a line in CHAIN_SPEC while you’re there. Deploying to the hub node next. |
…ace. Mirror the HMS #28 guard: sign payload trims From/To but settle credits raw strings — reject padding so funds cannot strand on unreachable rows.
Follow-up to #26 - the whitespace guard requested in its review did not make the merge window, and the fund-stranding path is live on merged main (bdc2ef2, re-verified after the #27 merge).
What
ValidateHmsTransferShape and the ed25519 signing payload both trim addresses, but settlement credits the raw tx strings. A transfer signed with a padded recipient (trailing space) passes validation, signs cleanly over the trimmed form, and - now that #26 wired the applier - settles into an account row no address lookup can find, stranding the amount.
Fix
Reject raw != trimmed for from/to in ValidateHmsTransferShape (used by submit, the apply-time re-validation, and the API simple-sign pre-check). Regression tests sign the trimmed form exactly like a real wallet would, cover the common whitespace boundaries (leading and trailing space, tab, newline, carriage return) plus a padded from, and assert invalid_address, the whitespace-specific message, and an empty pool. A second test seeds a padded row directly into hms_tx_pool and proves the apply-time path rejects it instead of crediting the raw address.
Scope: this closes the surrounding-whitespace variant (the reachable one). To still has only an HMC- prefix check, so internal whitespace or other malformed content in To remains a known follow-up, not closed here.
Evidence
Note: the same trim-vs-raw shape exists in both sibling lanes - transfer_v1 (ValidateTransferShape; its applier credits the raw item.tx.To) and transfer_sup_v1 (ValidateSupTransferShape, same). This PR is deliberately scoped to the HMS lane for a minimal diff; happy to extend the guard to both siblings on request.
Contract: a padded recipient was previously accepted as pending and settled into an account row no lookup could find; after this change it fails closed with invalid_address at submit and is rejected at apply time. A padded sender was already rejected before this change, but as address_pubkey_mismatch via the derived-address check; it now fails the same whitespace guard. The HMS endpoint (/api/hms/tx/send) and the invalid_address code are not yet listed in spec/CHAIN_SPEC.md or docs/API.md; happy to document them in a follow-up if useful.
Summary by CodeRabbit