Skip to content

fix(task-registry): bound task_type length in create_task - #66

Open
emteebug12-jpg wants to merge 3 commits into
ecotask-network:mainfrom
emteebug12-jpg:fix/task-type-max-length-issue-35
Open

fix(task-registry): bound task_type length in create_task#66
emteebug12-jpg wants to merge 3 commits into
ecotask-network:mainfrom
emteebug12-jpg:fix/task-type-max-length-issue-35

Conversation

@emteebug12-jpg

Copy link
Copy Markdown

Summary

create_task in contracts/task-registry/src/registry.rs only checked that task_type was non-empty, with no upper bound. Since Task structs are stored in persistent storage, a sponsor could store an arbitrarily large task_type string (e.g. 64 KB), inflating ledger rent for a single task — and the cost multiplies across max_completions completion records.

This adds a named constant MAX_TASK_TYPE_LEN = 64 and rejects any task_type longer than that.

Changes

  • Added MAX_TASK_TYPE_LEN: u32 = 64 constant.
  • create_task now panics with "registry: task type too long" when task_type.len() > MAX_TASK_TYPE_LEN.
  • Added test_create_task_max_length_type (exactly 64 bytes, succeeds).
  • Added test_create_task_oversized_type (65 bytes, panics).

Testing

cargo test -p task-registry

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

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 cybermax4200 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI checks are failing, please kindly fix it

emteebug12-jpg and others added 2 commits August 21, 2026 16:48
- 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
@cybermax4200

Copy link
Copy Markdown
Contributor

@emteebug12-jpg fix workflow

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.

task_type has no maximum length validation; unbounded strings inflate on-chain storage cost per task

2 participants