Skip to content

Security/stellar address validation#524

Merged
1nonlypiece merged 2 commits into
Disciplr-Org:mainfrom
DevALVIN-24:security/stellar-address-validation
Jun 28, 2026
Merged

Security/stellar address validation#524
1nonlypiece merged 2 commits into
Disciplr-Org:mainfrom
DevALVIN-24:security/stellar-address-validation

Conversation

@DevALVIN-24

Copy link
Copy Markdown
Contributor

closes #494

PR Description

📌 Description

This PR resolves a security/UI vulnerability where AddressDisplay and explorer link helpers accepted arbitrary strings. A malformed or attacker-controlled value would be rendered directly into a Stellar Expert explorer href.

We now enforce standard Stellar StrKey format validation (specifically validating standard Ed25519 Account and Contract lengths, prefixes, and valid base32 charset usage) before creating explorer links. Invalid addresses are marked visually with a warning strike-through style and specific aria-labels, and explorer links are hidden for them. The user can still copy the address string verbatim if they need to debug the malformed key.

🎯 Changes Made

  • New Utility: Added isValidStellarAddress in src/utils/stellarAddress.ts to strictly validate G and C keys (56 length + standard RFC4648 Base32 alphabet constraints).
  • Guarded Components: Updated AddressDisplay.tsx to utilize this function. Visually strike-throughs and labels invalid addresses with a warning message, whilst hiding the explorer hyperlink.
  • Guarded Helpers: Refactored getExplorerAccountUrl and contractExplorerUrl inside src/utils/explorer.ts to return an empty string when the supplied address fails validation checks.
  • Tests Implemented:
    • Added full test coverage for the isValidStellarAddress utility handling all major edge cases (wrong lengths, invalid prefix, lower-case, bad padding).
    • Extended AddressDisplay.test.tsx to handle testing of invalid marking rendering and assuring explorer links are conditionally hidden.
  • Documentation: Created design-system/documentation/address-validation.md to reflect the new address formatting rules and implementations for developers.

✅ Testing & Validation

  • Ran the testing suite ensuring full compliance and 100% line and branch coverage on the specifically modified functions/components. Tested edge cases include valid G/C keys, empty strings, invalid characters (e.g. 1 and 0), and invalid lengths.

@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@DevALVIN-24 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

@DevALVIN-24

Copy link
Copy Markdown
Contributor Author

okay

@1nonlypiece

Copy link
Copy Markdown
Contributor

stellar address validation tightened up, good. merged

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.

Validate Stellar address checksum (StrKey) before rendering AddressDisplay links

2 participants