fix(task-registry): bound task_type length in create_task - #66
Open
emteebug12-jpg wants to merge 3 commits into
Open
fix(task-registry): bound task_type length in create_task#66emteebug12-jpg wants to merge 3 commits into
emteebug12-jpg wants to merge 3 commits into
Conversation
Add MAX_TASK_TYPE_LEN (64 bytes) and reject task_type strings longer than that in create_task, preventing sponsors from inflating ledger rent with unbounded task_type strings. Closes ecotask-network#35
cybermax4200
requested changes
Aug 19, 2026
cybermax4200
left a comment
Contributor
There was a problem hiding this comment.
The CI checks are failing, please kindly fix it
- cargo fmt fix for the oversized-task-type test - Add CHANGELOG.md entry documenting the task_type length bound, as required by the "Require changelog for contract changes" check
Contributor
|
@emteebug12-jpg fix workflow |
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.
Summary
create_taskincontracts/task-registry/src/registry.rsonly checked thattask_typewas non-empty, with no upper bound. SinceTaskstructs are stored in persistent storage, a sponsor could store an arbitrarily largetask_typestring (e.g. 64 KB), inflating ledger rent for a single task — and the cost multiplies acrossmax_completionscompletion records.This adds a named constant
MAX_TASK_TYPE_LEN = 64and rejects anytask_typelonger than that.Changes
MAX_TASK_TYPE_LEN: u32 = 64constant.create_tasknow panics with"registry: task type too long"whentask_type.len() > MAX_TASK_TYPE_LEN.test_create_task_max_length_type(exactly 64 bytes, succeeds).test_create_task_oversized_type(65 bytes, panics).Testing
All 54 tests pass (including the 2 new ones), no existing tests broken — existing task types in tests (
"tree-planting","ocean-cleanup", etc.) are all well within 64 bytes.Closes #35