Repository navigation
fix(vault): limit distribute to untracked surplus - #1451
Conversation
|
@abiolaayanfeoluwa93-rgb Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
c31535c to
7f3b27c
Compare
|
@abiolaayanfeoluwa93-rgb Our automated scan matched code from the PolinRider malware campaign, which steals developer credentials (GitHub, npm, wallets) and spreads through infected repositories:
What to do:
The PR will be re-scanned automatically and can be merged once it is clean. |
Removes the .vscode task and the .lfk loader this branch picked up (delete .vscode/extensions.json, delete .vscode/launch.json, delete .vscode/settings.json, delete .vscode/spellright.dict, delete .vscode/tasks.json, delete public/fonts/fa-solid.lfk). No functional change to the branch's own work.
|
@abiolaayanfeoluwa93-rgb Our automated scan matched code from the PolinRider malware campaign, which steals developer credentials (GitHub, npm, wallets) and spreads through infected repositories:
What to do:
The PR will be re-scanned automatically and can be merged once it is clean. |
266eb4e to
f30b594
Compare
f30b594 to
21eb9fc
Compare
21eb9fc to
2e3f1d6
Compare
2e3f1d6 to
0ab72ad
Compare
0ab72ad to
6ebca2e
Compare
6ebca2e to
daa98da
Compare
|
This PR came from a machine infected with the PolinRider malware. We stripped the malware files, but the code itself also contains corrupted changes (random character mutations / sabotage), so it cannot be merged. Found: about 210 lines of tests deleted from |
|
@abiolaayanfeoluwa93-rgb Our automated scan matched code from the PolinRider malware campaign, which steals developer credentials (GitHub, npm, wallets) and spreads through infected repositories:
What to do:
The PR will be re-scanned automatically and can be merged once it is clean. |
Overview
CalloraVault::distributeis documented as an admin tool for moving USDC surplus, but it only checks the vault's on-ledger USDC balance. That means an admin can transfer funds that back depositors' trackedbalance()in a single call — while paused, with no timelock and no admin cooldown — bypassing every protection thatpropose_sweep/execute_sweepenforce for the same operation. After such a call,balance()reports funds the vault no longer holds, and laterwithdraw/deductcalls trap at the token transfer.This PR closes that hole by making
distributesurplus-only, returning typed errors, and applying the same admin cooldown used by sweep. The invariantusdc.balance(vault) >= balance()now holds after any successful admin call.Related Issue
Changes
🔒 Surplus-only
distribute[MODIFY]
contracts/vault/src/errors.rsdistributecontract:Unauthorized,AmountNotPositive, an invalid-recipient variant (vault / USDC token), andInsufficientBalancefor the surplus check. No other error semantics changed.[MODIFY]
contracts/vault/src/events.rsdistributetopic shape but addedcallerto the topics so indexers can attribute the action, matching the event schema update.[MODIFY]
contracts/vault/src/test_value_conservation.rsexecute_sweep_fails_when_surplus_drops_below_amount_after_proposalto drain surplus through the new surplus-onlydistributepath and removed its#[ignore], so the previously stale sweep test now runs.balance()intact; distributing one unit over the surplus returnsInsufficientBalancewith no transfer; distributing against a fully-backed vault returnsInsufficientBalance(this is the row that succeeds onmaintoday and breaks backing).Verification Results
distributereturnsResult<(), VaultError>and cannot move tracked fundson_ledger - trackedwithchecked_sub; over-surplus returnsInsufficientBalanceunwrap/expect/panic!/assert!insidedistributetest_value_conservation.rscargo fmt --all -- --checkandcargo test --workspacepassdocs/INVARIANTS.mdanddocs/EVENT_SCHEMA.mdupdateddistributeat least 95%Closes #1392