[Backend] Strip control characters and clamp length on on-chain token symbol and name metadata
Overview
When backend/src/lib/token-metadata.ts fetches symbol() and name() from arbitrary Soroban token contracts, malicious or misconfigured contracts can return strings containing control characters, zero-width spaces, or hundreds of characters.
Problem
- Unsanitized token metadata stored in the database can break UI layouts or spoof legitimate token tickers using invisible Unicode characters.
Proposed Changes
- Add a
sanitizeTokenString(raw: string, maxLength: number)helper inbackend/src/lib/token-metadata.ts. - Strip ASCII/Unicode control characters (
[\x00-\x1F\x7F-\x9F\u200B-\u200D\uFEFF]), trim whitespace, and clampsymbolto 16 chars andnameto 64 chars.
Acceptance Criteria
- [ ] Control characters and zero-width characters are stripped from token names and symbols.
- [ ] Oversized strings are truncated to safe bounds.
- [ ] Unit tests added in
backend/tests/token-metadata.test.ts.
@Peaostrel has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
i can handle this quickly
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Peaostrel to this issue.
@DooseWayo has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
Can I work on this task?
ℹ️ Repo Maintainers: To accept this application, review their application or assign @DooseWayo to this issue.
@Yilkash has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
Can i work on this?
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Yilkash to this issue.
Congratulations, @DooseWayo! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.
🧑💻 @DooseWayo: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
🌊 Happy Wave 🌊
This issue has been completed by @DooseWayo as part of the Stellar Wave Program's 10th Wave 🥳
😎 @DooseWayo: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.
🧑💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.