Skip to content

xdr decode commands fails with XDR decode error when base64 input contains whitespace #2431

@leighmcculloch

Description

@leighmcculloch

What version are you using?

25.1.0

What did you do?

Piped a base64-encoded transaction envelope containing line breaks into stellar tx hash via stdin:

{
  printf 'AAAAAgAAAADwSUp9CwmVlPN40mKX1I1j39y6DmYc36QS1aK2x6eYVQ'
  sleep 0.5
  printf '\n\n\n\n'
  sleep 0.5
  printf 'AAAGQAEcMsAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAACTMkzn1TwPo8SIhnKvnyuv9K2/aWjpX9NTYfyiA7vXaAAAAAAX14QAAAAAAAAAAAA=='
} | stellar tx hash --network testnet

This is the same base64 envelope as the single-line version below, just with line breaks inserted in the middle (as is common with PEM-style formatting, multi-line terminal paste, or copying from formatted output).

The same issue affects tx sign, tx send, tx simulate, and tx op add.

What did you expect to see?

The correct transaction hash, identical to the result of passing the envelope without line breaks:

printf 'AAAAAgAAAADwSUp9CwmVlPN40mKX1I1j39y6DmYc36QS1aK2x6eYVQAAAGQAEcMsAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAACTMkzn1TwPo8SIhnKvnyuv9K2/aWjpX9NTYfyiA7vXaAAAAAAX14QAAAAAAAAAAAA==' \
  | stellar tx hash --network testnet

What did you see instead?

An XDR decode error. The input is silently truncated at the whitespace, so the decoder either fails to parse the incomplete XDR or produces a wrong result.

Links

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Backlog (Not Ready)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions