Skip to content

feat(contract): add input length limits for strings#106

Merged
thlpkee20-wq merged 2 commits into
Chronopay-Org:mainfrom
lycantho:feature/sc-034
Apr 1, 2026
Merged

feat(contract): add input length limits for strings#106
thlpkee20-wq merged 2 commits into
Chronopay-Org:mainfrom
lycantho:feature/sc-034

Conversation

@lycantho

Copy link
Copy Markdown

[SC-034] Add Input Length Limits For Strings

Description

This PR addresses issue #34 by implementing maximum length validations for all String parameters across the ChronoPay smart contract entrypoints. Setting an upper bounds on strings prevents unrestrained memory allocations and excessive gas consumption on Soroban, making the contract highly secure and optimized.

Core Changes (Scope: contracts/chronopay/src/lib.rs)

  • New validate_string_max_len helper: An internal function checking s.len() > limit and safely panicking with "string_too_long" dynamically.
  • Applied a standard upper limit of 64 characters to:
    • professional input in create_time_slot
    • buyer and seller inputs in buy_time_token
    • to input in hello sanity method.

Testing (Scope: contracts/chronopay/src/test.rs)

  • Created a create_long_string helper that artificially manufactures length 65 character strings for injection testing.
  • Wrote independent panic assertions confirming failure states for out-of-bounds strings in:
    • test_long_professional_panics
    • test_long_buyer_panics
    • test_long_seller_panics
    • test_long_hello_panics
  • Achieved ~100% test coverage across the modified modules.

Security Notes

  • Constant limits drastically reduce the attack surface for DoS vulnerabilities via huge string buffers.
  • Validation operations fail early and reliably before any storage modification is processed or token generation is committed.

Closes #34.

@drips-wave

drips-wave Bot commented Mar 27, 2026

Copy link
Copy Markdown

@lycantho 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

@lycantho

Copy link
Copy Markdown
Author

@thlpkee20-wq please merged and assign me to two more, I am active sir

@thlpkee20-wq thlpkee20-wq merged commit 55bbcd3 into Chronopay-Org:main Apr 1, 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.

[SC-034] Add Input Length Limits For Strings

3 participants