Problem
The agent-registry contract allows agents to store arbitrary metadata with no size limits. A malicious or buggy agent could write unbounded data to storage, consuming the contract's rent budget and increasing costs for all users.
Current State
Agent data stored in agent_registry includes metadata blobs with no size validation:
pub struct AgentData {
pub agent_type: Symbol,
pub metadata: Map<Symbol, Val>, // unbounded!
pub status: Symbol,
}
Proposed Solution
- Define maximum sizes:
MAX_AGENT_ID: usize = 64
MAX_METADATA_ENTRIES: usize = 16
MAX_METADATA_VALUE_SIZE: usize = 256 (bytes)
MAX_TOTAL_AGENT_STORAGE: usize = 4096 (bytes)
- Add validation in
register_agent() and update_agent():
- Check symbol lengths
- Check metadata map size
- Check total serialized size
- Return typed errors for size violations
- Add tests for boundary conditions
Acceptance Criteria
Difficulty
Medium — validation logic only, no storage layout changes
Labels
smart-contract stellar enhancement
Problem
The agent-registry contract allows agents to store arbitrary metadata with no size limits. A malicious or buggy agent could write unbounded data to storage, consuming the contract's rent budget and increasing costs for all users.
Current State
Agent data stored in
agent_registryincludes metadata blobs with no size validation:Proposed Solution
MAX_AGENT_ID: usize = 64MAX_METADATA_ENTRIES: usize = 16MAX_METADATA_VALUE_SIZE: usize = 256(bytes)MAX_TOTAL_AGENT_STORAGE: usize = 4096(bytes)register_agent()andupdate_agent():Acceptance Criteria
Difficulty
Medium — validation logic only, no storage layout changes
Labels
smart-contractstellarenhancement