Skip to content

[BUG] assertValidPublicKey() utility accepts a valid-looking StrKey that actually decodes to a muxed account or contract address, when only a plain account address is expected #802

Open

Description

@meshackyaro

Description

The validator checks that a string decodes successfully via StrKey but doesn't check which StrKey version byte it decoded as, so a muxed-account address (M...) or a contract address (C...) passes validation in contexts that specifically expect a plain G... account address.

Component

utils

Steps to Reproduce

  1. Call assertValidPublicKey('M...') (a valid muxed address) where a plain account address is required by the calling context.
  2. Observe it passing validation.
  3. Trace what happens downstream when code written for plain G... addresses receives a muxed one instead.

Expected Behavior

The validator should accept an explicit expected-type parameter (or there should be separate validators per StrKey type) rather than one generic 'decodes successfully' check.

Actual Behavior

Code paths expecting a plain account address can receive a structurally-different muxed or contract address that happens to pass the too-permissive validator, risking confusing downstream behavior.

Environment

  • SDK version: 0.3.x
  • Node version: 20.x, 22.x
  • OS: macOS / Linux
  • Network: TESTNET

Code Example

assertValidPublicKey('MA7QIKTEY...'); // passes, even where only G... addresses are valid

Error Output

N/A — no thrown error; behavior is incorrect but silent.

Difficulty

🟡 Medium

Additional Context

The validator calls the generic StrKey.isValidEd25519PublicKey OR a catch-all decode check without being specific to the single expected address type per call site.

Activity

  1. added
    bug
    good first issue
    difficulty: medium
    priority: medium
    on Oct 29, 2026
  2. shobhamerabacha-star commented on Oct 29, 2026

    @shobhamerabacha-star

    Greetings,

    I looked into the details for "[BUG] assertValidPublicKey() utility accepts a valid-looking StrKey that actually decodes to a muxed account or contract address, when only a plain account address is expected" and would like to contribute the fix.

    I have reviewed the problem description and acceptance criteria for this issue. I have a clear, tested implementation ready with defensive error handling and 100% green CI proof.

    I will deliver a clean, well-tested, and production-ready PR promptly upon assignment. Kindly assign this issue to me.

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdifficulty: mediumgood first issuepriority: mediumsdk

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions