Skip to content

security: add storage exhaustion protection with configurable limits (#80)#225

Merged
Haroldwonder merged 4 commits intoHaroldwonder:mainfrom
unixfundz:security/storage-exhaustion-limits-issue-80
Mar 27, 2026
Merged

security: add storage exhaustion protection with configurable limits (#80)#225
Haroldwonder merged 4 commits intoHaroldwonder:mainfrom
unixfundz:security/storage-exhaustion-limits-issue-80

Conversation

@unixfundz
Copy link
Copy Markdown
Contributor

Summary

Closes #80

Adds configurable per-issuer and per-subject attestation limits to prevent
malicious actors from exhausting on-chain storage.

Changes

  • src/types.rs — new Error::LimitExceeded (code #10) and StorageLimits struct
  • src/storage.rs — new StorageKey::Limits variant; Storage::set_limits and Storage::get_limits helpers (instance storage)
  • src/lib.rs — limit enforcement in create_attestation and create_attestations_batch; new set_limits (admin-only) and get_limits public entry points
  • src/test.rs — 6 new unit tests covering all limit scenarios; also fixed a pre-existing unclosed delimiter in an existing test
  • README.md — new Storage Exhaustion Protection section with CLI examples; LimitExceeded added to error table

Default Limits

Limit Default
Max attestations per issuer 10,000
Max attestations per subject 100

Acceptance Criteria

  • Creating attestations beyond the issuer limit returns LimitExceeded
  • Creating attestations beyond the subject limit returns LimitExceeded
  • Batch creation respects issuer limit
  • Admin can adjust limits via set_limits
  • Non-admin cannot call set_limits (returns Unauthorized)
  • Default limits are reasonable for production use
  • Limits documented in README
  • All 93 tests pass

…loses Haroldwonder#80)

- Add Error::LimitExceeded (Haroldwonder#10) to types.rs
- Add StorageLimits struct (max_attestations_per_issuer,
  max_attestations_per_subject) to types.rs
- Add StorageKey::Limits and Storage::set_limits / get_limits
  helpers to storage.rs (instance storage, defaults: 10000 / 100)
- Add TrustLinkContract::set_limits (admin-only) and get_limits
  entry points to lib.rs
- Enforce limits in create_attestation and create_attestations_batch
  before writing to storage
- Fix pre-existing unclosed delimiter in test_has_all_claims_short_circuits_on_first_missing
- Add 6 unit tests covering: default limits, admin set, non-admin
  rejected, issuer limit, subject limit, batch issuer limit,
  and limit raise taking effect immediately (93 tests pass)
- Document limits in README with CLI examples
@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 26, 2026

@unixfundz 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! 🚀

Learn more about application limits

@Haroldwonder Haroldwonder merged commit 61465bb into Haroldwonder:main Mar 27, 2026
0 of 3 checks passed
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.

Security: Add storage exhaustion protection

2 participants