Skip to content

fix(router-core): reject empty and whitespace-only metadata tags - #872

Merged
Maki-Zeninn merged 2 commits into
Maki-Zeninn:mainfrom
joshfatoye0011-bit:fix/validate-metadata-tags
Jul 26, 2026
Merged

fix(router-core): reject empty and whitespace-only metadata tags#872
Maki-Zeninn merged 2 commits into
Maki-Zeninn:mainfrom
joshfatoye0011-bit:fix/validate-metadata-tags

Conversation

@joshfatoye0011-bit

Copy link
Copy Markdown
Contributor

Summary Closes #713 Metadata validation in contracts/router-core/src/lib.rs checked tag count (max 5) and description length (max 256) but did not validate individual tag values. This allowed empty strings and whitespace-only tags to be stored, causing meaningless entries to accumulate and breaking tag-based filtering/search. ## Changes Added per-tag validation in all three validation sites: - \

egister_route\ inline metadata check - \update_route\ inline metadata check - \�alidate_metadata\ shared helper Each tag is now rejected with \RouterError::InvalidMetadata\ if it is: - Empty (\len == 0) - Whitespace-only (all bytes are \�' ') ## Implementation note \soroban_sdk::String\ does not expose .chars()\ (no-std environment), so validation uses \copy_into_slice\ to inspect raw bytes — consistent with the existing \�alidate_route_name\ pattern in the same file.

…ration Closes Maki-Zeninn#710 Adds a configurable upper bound on the number of routes that can be registered simultaneously, preventing storage exhaustion and O(n) DoS via recompute_best_route/batch_resolve. Changes: - Add DataKey::MaxRoutes (u32 storage key) - Add RouterError::TooManyRoutes = 17 - initialize() accepts Option<u32> max_routes; None defaults to 1000 - New get_max_routes() read-only getter - New set_max_routes() admin setter (rejects 0 with InvalidRouteName) - Enforce cap in register_route_internal (single choke-point for all registration paths) - Reuse the fetched count for RouteCount increment (eliminates duplicate storage read) - Add TooManyRoutes/InvalidTtlExtension/RecursionLimitExceeded arms to router_error_to_batch - Fix pre-existing duplicate discriminant: RecursionLimitExceeded 15->16, TooManyRoutes = 17 - 11 new tests covering default cap, custom cap at init, setter valid/zero/unauth, register_route at cap, freeing a slot, batch blocked/exactly at cap, lowering cap, raising cap, RouteCount increment
…y and whitespace-only values Closes Maki-Zeninn#713 Previously, metadata validation only checked tag count (max 5) and description length (max 256), but did not validate individual tag values. This allowed empty strings and whitespace-only tags to be stored, which would cause meaningless entries to accumulate and break tag-based filtering. Added per-tag validation in all three validation sites: - register_route inline check - update_route inline check - validate_metadata helper Each tag is now rejected if it is empty (len == 0) or consists entirely of space characters. Uses copy_into_slice byte inspection consistent with the existing validate_route_name pattern for soroban_sdk::String.
@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@joshfatoye0011-bit 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

@Maki-Zeninn
Maki-Zeninn merged commit 76c9c33 into Maki-Zeninn:main Jul 26, 2026
1 check 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.

feat(router-core): validate metadata tag values are non-empty strings

2 participants