Enforce limit order price band to block dust-ask match DoS (#467) #1010
No reviewers
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic!1010
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/467-limit-price-band"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes GitLab #467: a dust-priced limit ask at
Decimal::raw(1)(1e-18) could sort to the book head and makechecked_mul_flooroverflow on1/priceduring hybrid match, reverting any crossing swap with a large enough token1 leg.MIN_LIMIT_PRICE(1e-9) andMAX_LIMIT_PRICE(1e9) index-common::limit_placementwithvalidate_limit_order_price.UpdateLimitOrderPrice.match_bids/match_asks/simulate_match_*skip legacy out-of-band resting rows on reciprocal math overflow instead of aborting the whole swap.make verify-issue-467.Acceptance checklist
raw(1)rejected at placementcargo test -p cl8y-dex-tests place_limit_order_dust_price_rejectedcargo test -p dex-common expand_ladder_rejects_out_of_bandcargo test -p cl8y-dex-tests dust_ask_brick_attack_prevented_valid_ask_still_fillscargo test -p cl8y-dex-pair match_asks_skips_legacy_dust_price_without_revertingcargo test -p cl8y-dex-tests match_asks_skips_zero_cost_fill_sub_unity_pricemake verify-issue-467(docs/skill grep steps)make verify-issue-467Verification for third parties
Optional broader sweep:
Related
Bugbot is not enabled for your account, so this pull request was not reviewed.
Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.
Security review — MR !1010
Commit reviewed:
e5cb6f3f1c89b79808e79056993eafb0b860b5c6Scope: Limit price band enforcement (
MIN_LIMIT_PRICE/MAX_LIMIT_PRICE,validate_limit_order_price), placement/ladder/price-update gates, and match-time overflow skip inmatch_*/simulate_match_*(GitLab #467 / invariant L19). Docs, QA script, and integration tests only otherwise.Method: Diff review; traced attacker-controlled
pricethroughPlaceLimitOrderBatch, ladder expansion,UpdateLimitOrderPrice, and hybrid book matching; checked auth boundaries, escrow accounting on skip paths, and overflow thresholds at band edges.Outcome:
FINDINGS: 0medium+Inline threads: none
Summary
This MR closes the documented dust-ask match DoS (extreme
priceat book head causingchecked_mul_floor/1/priceoverflow and whole-swap revert). Controls are appropriately layered:validate_limit_order_pricerejects out-of-band prices on batch items, ladder expansion (start/end and each rung), andUpdateLimitOrderPrice(owner-gated, unchanged).try_price_inverse/try_mul_floorfailures skip the resting row (continue) without debiting maker escrow or crediting the taker; walk advances vianext_ptr.MIN_LIMIT_PRICE(1e-9),1/priceoverflow requires taker notionals far above practicalUint128swap sizes (~3.4e29 raw units), so in-band placement does not recreate the pre-fix brick vector at realistic sizes.No authn/authz bypass, injection surface, secret leakage, or fund-extraction path identified in the added/modified code. Legacy out-of-band rows are intentionally skipped rather than matched; that is griefing mitigation, not a new theft vector. Indexer mirror parity for overflow-skip is out of this diff (quote accuracy only; on-chain execute remains authoritative).
Prior security-review threads: none on this MR; nothing to re-report.
Security review: no medium+ findings on this diff.
added 5 commits
main23a36d0f- Merge origin/main into fix/467-limit-price-bandCompare with previous version
Resolved merge conflicts with
main:docs/contracts-security-audit.md: kept L19 (blacklisted maker skip, #468 from main) and renumbered limit price band to L20 (#467).orderbook.rs: combined module docs for both invariants; added missingblacklist_gate: Nonearg inlimit_price_band_tests::match_asks_skips_legacy_dust_price_without_reverting.limit-orders.md,AGENTS_BOOK_MATCH_HINT_SECURITY.md, andverify-issue-467.sh.Sanity:
make verify-issue-467— all 7 steps pass.Bugbot is not enabled for your account, so this pull request was not reviewed.
Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.
Security review — MR !1010
Commit reviewed:
23a36d0f4f04aa5fe4f6268c5857e25900bbc7e6Scope: Post-merge-conflict re-review of limit price band enforcement (
MIN_LIMIT_PRICE/MAX_LIMIT_PRICE,validate_limit_order_price), placement/ladder/price-update gates, and match-time overflow skip inmatch_*/simulate_match_*(GitLab #467 / invariant L20). Includes merge withmain(L19 blacklist maker skip renumber,blacklist_gatetest fix).Method: Full MR diff review; traced attacker-controlled
pricethroughPlaceLimitOrderBatch, ladder expansion (expand_limit_ladder+ per-rung validation),UpdateLimitOrderPrice, andrelink_limit_order_price; verified skip paths do not debit maker escrow or credit takers; checked band-edge overflow thresholds vs realisticUint128swap notionals.Outcome:
FINDINGS: 0medium+Inline threads: none
Summary
This MR closes the documented dust-ask match DoS (extreme resting
priceat book head causingchecked_mul_floor/1/priceoverflow and whole-swap revert). Controls remain appropriately layered:validate_limit_order_pricerejects out-of-band prices on batch items, ladder expansion (start/end and each interpolated rung),UpdateLimitOrderPrice, andrelink_limit_order_price. Owner/auth checks on price update unchanged.try_price_inverse/try_mul_floorfailures skip the resting row (continuevianext_ptr) withoutmakers_used++, escrow debits, or taker credits.MIN_LIMIT_PRICE(1e-9),1/pricemul_floor overflow requires taker notionals far above practicalUint128swap sizes (~3.4e29 raw units), so in-band placement does not recreate the pre-fix brick vector at realistic sizes.Merge-conflict resolution with
main(L19/L20 renumber,blacklist_gate: Nonein unit test) does not weaken auth or introduce new attack surface.No authn/authz bypass, injection surface, secret leakage, or fund-extraction path identified in the added/modified code. Legacy out-of-band rows are intentionally skipped rather than matched; that is griefing mitigation, not a new theft vector. Indexer mirror parity for overflow-skip is out of this diff (quote accuracy only; on-chain execute remains authoritative).
Prior security-review thread (
e5cb6f3): conclusions still hold on this SHA; no new medium+ issues from the merge.Security review: no medium+ findings on this diff.
mentioned in commit
86cf616168