Skip to content

fix(audit): skip zero-padded destination/puller slots (MULT-8)#36

Merged
dev-jodee merged 5 commits into
audit/ai-scanner/06-subscribe-terms-bindingfrom
audit/ai-scanner/07-filter-zero-destinations
Apr 28, 2026
Merged

fix(audit): skip zero-padded destination/puller slots (MULT-8)#36
dev-jodee merged 5 commits into
audit/ai-scanner/06-subscribe-terms-bindingfrom
audit/ai-scanner/07-filter-zero-destinations

Conversation

@dev-jodee
Copy link
Copy Markdown
Collaborator

@dev-jodee dev-jodee commented Apr 28, 2026

Audit finding: MULT-8

Plan::check_destination and Plan::can_pull checked membership against the full fixed-size 4-slot arrays, including zero-padded unused slots. A plan with fewer than 4 configured destinations effectively whitelisted Pubkey::default() as a valid receiver — a whitelisted puller could route subscription pulls to a same-mint token account owned by the all-zero address, locking funds permanently in an unspendable account.

Fix

Filter zero-padded slots before membership tests in both check_destination and can_pull. Defense-in-depth on can_pull even though the signer requirement already prevents exploitation there.

Test plan

  • cargo test -p subscriptions --lib (216/216 pass; 3 new unit tests)
  • cargo build -p subscriptions
  • check_destination_rejects_zero_owned_receiver_with_partial_whitelist
  • check_destination_open_when_all_zero
  • can_pull_rejects_zero_caller_with_partial_whitelist

Stack

Stacked on top of #35 (MULT-6).

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

Compute Unit Report

Instruction Samples Min CUs Max CUs Avg CUs Est Cost (Low) [SOL] Est Cost (Med) [SOL] Est Cost (High) [SOL]
cancel_subscription 11 1774 2098 1982 0.000005000 0.000005079 0.000005991
close_subscription_authority 7 1866 1901 1871 0.000005000 0.000005074 0.000005935
create_fixed_delegation 36 3566 9561 4847 0.000005001 0.000005193 0.000007423
create_plan 84 3525 11038 4546 0.000005001 0.000005181 0.000007273
create_recurring_delegation 25 3587 11092 5034 0.000005001 0.000005201 0.000007517
delete_plan 8 401 401 401 0.000005000 0.000005016 0.000005200
init_subscription_authority 136 5805 19753 9409 0.000005002 0.000005376 0.000009704
revoke_delegation 19 303 570 405 0.000005000 0.000005016 0.000005202
subscribe 21 6639 15639 8292 0.000005002 0.000005331 0.000009146
transfer_fixed 6 8478 8481 8480 0.000005002 0.000005339 0.000009240
transfer_recurring 17 8566 8651 8599 0.000005002 0.000005343 0.000009299
transfer_subscription 10 8862 8985 8901 0.000005002 0.000005356 0.000009450
update_plan 21 409 488 461 0.000005000 0.000005018 0.000005230

Generated: 2026-04-28

@dev-jodee dev-jodee force-pushed the audit/ai-scanner/06-subscribe-terms-binding branch from 33dfaf3 to 9a6c2b0 Compare April 28, 2026 15:51
Plan::check_destination and Plan::can_pull now filter out zero-padded
slots before membership tests. A plan with fewer than four configured
destinations no longer authorizes a zero-owned receiver, and a plan
with fewer than four pullers no longer authorizes a zero-pubkey caller.
@dev-jodee dev-jodee force-pushed the audit/ai-scanner/07-filter-zero-destinations branch from b6941f7 to b916404 Compare April 28, 2026 15:52
@dev-jodee dev-jodee marked this pull request as ready for review April 28, 2026 16:23
…-10)

Webapp exit flows now pass the on-chain payer as receiver when it
differs from the connected signer, so sponsor-funded delegations and
SubscriptionAuthority accounts can actually be closed.

Also migrates revokeSubscription and cancelAndRevokeSubscription from
buildRevokeDelegation to buildRevokeSubscription with planPda + receiver,
fixing subscription revoke for both sponsor and non-sponsor cases.
…(MULT-9)

Stale-delegation cleanup no longer appends a close on the current
SubscriptionAuthority. Revoking stale delegations is now scoped to the
supplied delegation accounts; the SA stays open and current grants
remain valid.
@dev-jodee dev-jodee merged commit 5bb7598 into audit/ai-scanner/06-subscribe-terms-binding Apr 28, 2026
6 checks passed
@dev-jodee dev-jodee deleted the audit/ai-scanner/07-filter-zero-destinations branch April 28, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant