fix(globe-wallet): use case-insensitive check for native XLM asset - #97
Closed
s6pa1rta3n-lab wants to merge 1 commit into
Closed
fix(globe-wallet): use case-insensitive check for native XLM asset#97s6pa1rta3n-lab wants to merge 1 commit into
s6pa1rta3n-lab wants to merge 1 commit into
Conversation
… prevent squatting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #86
Description
In
contracts/globe-wallet/src/lib.rs,GlobeWallet::add_assetpreviously checkedis_nativeusing exact case-sensitive equality (asset.code == String::from_str(&env, "XLM")) while duplicate asset detection used case-insensitive equality (codes_match_case_insensitive).This allowed an attacker or untrusted payload to register a case-variant of XLM with an issuer (e.g.
code: "xlm",issuer: Some(fake_issuer)), which bypassed the native asset issuer check (treated as an issued asset) and occupied the case-insensitive namespace slot. Consequently, when the legitimate user later attempted to register real native XLM ("XLM"with no issuer), it was permanently blocked by duplicate detection (AssetAlreadyAdded).Solution
is_nativecheck inadd_assetto useSelf::codes_match_case_insensitive(&asset.code, &String::from_str(&env, "XLM"))."XLM"with an issuer (Some(...)) is now rejected outright withWalletError::InvalidAssetInfo."xlm") and mixed-case ("Xlm","xLm") with issuer before native XLM registration."XLM",None).WalletError::AssetAlreadyAdded.Design Decision
Decision on case-variant-of-XLM-with-issuer:
Non-native assets registered under any case-variant of
"XLM"with an issuer (e.g.,"xlm","Xlm") are rejected outright withWalletError::InvalidAssetInfo. On Stellar/Soroban, XLM is the singular native asset and cannot possess an issuer. Permitting an issued asset under a case variation of"XLM"allows impersonation of native XLM and enables namespace squatting. Aligningis_nativewith case-insensitive canonicalization ensures all case variations of XLM are subject to the native asset invariant (no issuer allowed).Definition of Done Checklist
is_nativecheck uses the same canonicalization as the duplicate-detection loop"xlm"(with any issuer) is rejected the same way an uppercase duplicate would be, before the real native XLM is ever registeredcargo test --workspaceoutput pastedTest Output (
cargo test --workspace)Payout Routing
0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC