Skip to content

Fix: Reject Invalid Stellar Asset Codes During Upload Validation #701

Description

@jahrulezfrancis

Problem

Payment rows with an invalid asset code pass upload validation and only
fail later, during actual transaction construction — turning what should be
a clear pre-submission rejection into a confusing mid-batch failure.

Severity: Medium
Location: lib/stellar/validator.ts:124-153, lib/stellar/utils.ts:155-169

Description

The asset validator checks that the code portion of CODE:ISSUER is
non-empty and at most 12 characters, and that the issuer address checksum is
valid — but never checks that the code is alphanumeric, which Stellar
requires. A value like "BAD CODE" (8 characters, including a space) passes
validation as valid: true. Later, new Asset(code, issuer) in
stellar-sdk throws when actually building the payment operation, turning a
row that should have been rejected at upload into a failure during batch
execution.

Steps to Reproduce

  1. Upload a row with asset BAD CODE:<valid issuer address>.
  2. Validation reports the row as valid.
  3. Submit the batch.
  4. stellar-sdk throws "Asset code is invalid" while constructing the
    payment operation, failing that row at execution time instead of upload.

Expected Behavior

Any asset accepted by pre-submission validation should be guaranteed
constructible by stellar-sdk — invalid codes should be rejected at upload.

Suggested Fix Approach

Require the code to match Stellar's alphanumeric rule directly in the
validator, or construct a stellar-sdk Asset inside validation itself and
convert any thrown exception into a row-level validation error.

Acceptance Criteria

  • Asset codes with non-alphanumeric characters are rejected at
    validation time, not execution time
  • Test covers a code with a space, and a code with other invalid
    characters
  • Valid alphanumeric codes of length 1-12 continue to pass

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions