feat(smart-contract): enforce metadata and storage size validation in agent-registry#133
Open
Opulencechuks wants to merge 16 commits into
Open
feat(smart-contract): enforce metadata and storage size validation in agent-registry#133Opulencechuks wants to merge 16 commits into
Opulencechuks wants to merge 16 commits into
Conversation
|
@Opulencechuks is attempting to deploy a commit to the Jaja's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Nice implementation @Opulencechuks |
…encechuks/ai-net into feature/agent-registry-size-limits
devJaja
self-requested a review
July 20, 2026 22:40
Contributor
|
@Opulencechuks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #115
Summary
The
agent-registrycontract previously allowed agents to store arbitrary metadata with no size limits. This vulnerability could allow a malicious or buggy agent to write unbounded data to persistent storage, consuming the contract's rent budget and increasing ledger costs for all users. This PR addresses the issue by defining maximum size constants and adding strict size validation on agent IDs, metadata entries, metadata value bytes, and total record storage size.Changes
MAX_AGENT_ID = 64,MAX_METADATA_ENTRIES = 16,MAX_METADATA_VALUE_SIZE = 256,MAX_TOTAL_AGENT_STORAGE = 4096).AgentRecordto includemetadata: Map<Symbol, Val>to store metadata entries.AgentIdTooLong,TooManyMetadataEntries,MetadataValueTooLarge,StorageLimitExceeded) to theErrorenum.validate_recordhelper utilizingToXdrserialization to calculate exact byte sizes.register_agent().update_agent(env: Env, record: AgentRecord) -> Result<(), Error>to support validated updates, including capability indexing updates if an agent changes capabilities.metadatamap and added 7 new unit tests verifying limit validations."metadata":{}.Testing
register_with_metadata_ok) and successful updates (update_agent_ok).validation_too_many_metadata_entries)validation_metadata_value_too_large)validation_total_storage_limit_exceeded)Related Issue
Smart-contract metadata and storage size bounds protection enhancement.
Checklist