fix: identify Stellar assets by (code, issuer) pair to prevent token spoofing - #218
Merged
Obiajulu-gif merged 1 commit intoAug 25, 2026
Conversation
… spoofing Fixes Chainmove#202 — asset_code alone is insufficient to identify a Stellar asset; an attacker can mint a token named CMOVE or USDC under a different issuer. - Add lib/stellar/asset-identity.ts with classifyAsset() returning asset, issuer, verified, and canonicalId fields. verified=true only when both the asset code AND issuer match the configured canonical issuer (or native XLM). - Update app/api/stellar/activity/route.ts to use classifyAsset() for live Horizon balances and indexed activity events. Live balances now carry verified and canonicalId. Activity entries now include assetIssuer, assetVerified, and assetCanonicalId pulled from raw Horizon payload. - Add __tests__/lib/stellar/asset-identity.test.ts covering native XLM, canonical asset, spoofed same-code token from different issuer, missing issuer, and missing/empty config values. - Update __tests__/api/stellar/activity.test.ts to assert the new fields.
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 #202
Summary
asset_codealone lets an attacker mint aCMOVEorUSDCtoken under a different issuer and have it appear identical to the canonical token.lib/stellar/asset-identity.tswithclassifyAsset(code, issuer, config)that returns{ asset, issuer, verified, canonicalId }.verifiedistrueonly when both the code and issuer match the configuredSTELLAR_ISSUER_PUBLIC_KEY, or the asset is native XLM.app/api/stellar/activity/route.tsto applyclassifyAsset()to every balance returned from Horizon and every indexed activity event. Activities now carryassetIssuer,assetVerified, andassetCanonicalId(extracted from the raw Horizon payload).__tests__/lib/stellar/asset-identity.test.tscovering: native XLM, canonical CMOVE, spoofed same-code token from wrong issuer, missing issuer, and empty config values.__tests__/api/stellar/activity.test.tsto assert the newverifiedandcanonicalIdfields.Test plan
classifyAsset("CMOVE", CANONICAL_ISSUER, config)→verified: trueclassifyAsset("CMOVE", SPOOF_ISSUER, config)→verified: false, differentcanonicalIdclassifyAsset("XLM", null, config)→verified: true,canonicalId: "XLM:native"classifyAsset("CMOVE", null, config)→verified: false,canonicalId: "CMOVE:unknown"verifiedandcanonicalIdon each balanceassetVerified,assetIssuer,assetCanonicalId