Repository navigation
Description
Summary
The daily withdrawal limit introduced in #4457 (PV14) uses gross outflow
accounting: every withdrawal spends the daily budget, and deposits (asset locks)
never refill it. This means an attacker can cycle their own coins
deposit → withdraw to exhaust the entire day's withdrawal capacity for every
user, indefinitely, for the cost of only transaction fees — even though the pool
of credits never actually shrinks.
#4457 correctly defends the limit from being raised by an inflated total (the
24h-lagged base). It does not defend the budget from being consumed by
self-cancelling flow. Those are two different attacks; this issue is the second.
Reproduction
Self-contained test that passes against the merged code on v4.2-dev
(#4457 = fa9fd05abb). A passing run is the proof: if deposits flowed back into
the budget, the final available() == 0 assertion would fail.
Gist (repro instructions + test + patch):
https://gist.github.com/PastaPastaPasta/561a88e1b54163b98bf719769cd182da
git checkout v4.2-dev
git apply withdrawal-net-proof.patch # appends the test to the #4457 test module
cargo test -p drive --features full --lib deposit_then_withdraw_cycling
# => ...deposit_then_withdraw_cycling_consumes_the_whole_budget_and_deposits_restore_nothing ... okEvery mutating step in the test is the real production call:
- deposit (asset lock) →
add_to_system_credits
(SystemOperationType::AddToSystemCredits,address_funding_from_asset_lock_transition.rs); - pool the withdrawal →
add_enqueue_untied_withdrawal_transaction_operations
(WithdrawalOperationType::ReserveWithdrawalAmount), exactly what
pool_withdrawals_into_transactions_queuedoes after checkingavailable(); - execute the withdrawal →
remove_from_system_credits.
Trace: Platform holds 20,000 Dash → a day later daily_maximum = 15% = 3,000,
available() = 3,000. Attacker deposits 3,000 and withdraws it. Result:
TOTAL_SYSTEM_CREDITSends at exactly 20,000 — nothing left Platform net;available() == 0— the whole day's budget is gone for every other user;- after recording history, tomorrow's
daily_maximumis still 3,000 — the cycle
is invisible to the day-old base, so the same recycled coins zero it out again,
every day.
Why the "deposits get added back in" intuition doesn't hold
Deposits do raise TOTAL_SYSTEM_CREDITS, which raises daily_maximum — but only
a day later, and only if the deposit is still there when the 24h-lagged
reference is sampled. A same-day deposit→withdraw cycle cancels itself out of the
history, so it never reaches the base. "Added back in" is true for the base,
tomorrow, if held; it is never true for available(), today — which is the
quantity that blocks users. The only three touchers of the budget are
ReserveWithdrawalAmount (add, on pooling), the 25h expiry cleanup (remove), and
calculate_current_withdrawal_limit (read); no asset-lock path touches it.
Impact
- Griefing / DoS: any user can pin the network-wide withdrawal throughput to
~0 for the cost of fees, recycling a fixed amount of their own coins. At today's
mainnet totals (~30k Dash held → 4,000 Dash cap binds) this is the same attack,
at the same cost, as under the old flat limit — feat(drive)!: make the daily withdrawal limit 15% of the total credits held a day ago #4457 does not change it. - It also defeats the stated goal of feat(drive)!: make the daily withdrawal limit 15% of the total credits held a day ago #4457: legitimate high-frequency
shielded↔Core economic flow burns the budget even though the pool level does not
move, so honest users get limited by exactly the churn the feature was meant to
enable.
Proposed fix
Make the budget net of L1-verifiable inflows only:
available = daily_maximum + asset_lock_inflows_in_last_24h − withdrawals_in_last_24h
This is algebraically the rule "the total may never drop below (100−percent)% of
the total held a day ago" — it limits the drop in the pool level, not the
flow through the pool. Properties:
- honest churn (deposit X, withdraw X) nets to zero and consumes no budget →
unlimited legitimate flow; - the griefing cycle self-cancels and blocks nobody;
- the inflation guardrail is preserved: asset locks are chain-locked coins
Core validated, so a Platform minting bug cannot forge inflow to raise the
budget; the worst case still drains at mostpercent/day. The 24h-lagged base
from feat(drive)!: make the daily withdrawal limit 15% of the total credits held a day ago #4457 stays exactly as-is.
Implementation is small and mirrors machinery #4457 already added: one more 24h
rolling sum of asset-lock inflows, subtracted alongside the existing
WITHDRAWAL_TRANSACTIONS_SUM_AMOUNT_TREE_KEY sum.
Core side: the v24 credit-pool rule (src/evo/creditpool.cpp,
ConstructCreditPool) counts only unlocks in its window and will become the new
bottleneck under heavy honest flow. It needs the same net treatment — allow
unlocks as long as the credit-pool balance stays above (100−percent)% of its
value one window ago. DEPLOYMENT_V24 is not activated on any network yet, so
this can land before activation without an additional fork.
Related
- PR feat(drive)!: make the daily withdrawal limit 15% of the total credits held a day ago #4457 — the change this concerns
- PR feat(drive)!: raise the daily withdrawal limit to 4000 Dash #4452 — raised the flat cap to 4,000 Dash
Activity
refactor(drive)!: record credit inflows once per block as a system event
fix(drive): let inflows extend past the capped base and rewind mints …
Merge #7712: feat(consensus): relative net asset-unlock limit for v24…