CLI flag parser does not consume option values: --memo can hijack --asset, and --memo --yes bypasses the burn confirmation
Report
Suggested severity tier: Low
Area: CLI argument parsing, cmd/xe/main.go (cmdSend, cmdBurn)
Repository state checked: xeprotocol/xe HEAD 978785929bc17a2f4ab30c383e5fc9cf4d634512
Summary
The send and burn commands scan their arguments with a loop that never skips a consumed option value. Every argument is examined in turn, including values already taken by a preceding flag. A value that looks like a flag is therefore interpreted as a flag. Two consequences follow: a memo value of "--asset" changes the asset of a send, and a memo value of "--yes" sets the skip-confirmation flag of a burn. The burn confirmation is the only guard on an irreversible action in this CLI, and it can be bypassed through a memo value.
What was proven
The loop in cmdSend (cmd/xe/main.go, around lines 674-684) walks all arguments:
for i, a := range args { if a == "--asset" && i+1 < len(args) { asset = args[i+1] } if a == "--memo" && i+1 < len(args) { memo = args[i+1] } }
After "--memo" takes its value, the loop continues to that value on the next iteration and treats it as a flag. cmdBurn (cmd/xe/main.go, line 866 onward) has the same pattern over rest := args[1:].
Proven against a local build of the CLI plus a local stub node (stub balances: XUSD 0, XE 1,000,000,000 micro):
xe send <64-hex address> 1 --memo --asset XEprints "Sent 1 XE". The user meant memo "--asset" with the default asset XUSD. What happened: the memo took "--asset" as its value, and then "--asset" was read again as a flag, so the asset became XE and the send went through because the XE balance was sufficient. Had the asset stayed XUSD, the command would have failed with insufficient funds.xe burn 1 --memo --yeswith stdin from /dev/null prints "Burned 1 XE" with no prompt. The control,xe burn 1with no flags and the same stdin, prints the confirmation prompt and then fails with "error: aborted". The memo value "--yes" set skipConfirm to true while also being stored as the memo.
Reproduction
- Clone https://github.com/xeprotocol/xe and confirm HEAD is 978785929bc17a2f4ab30c383e5fc9cf4d634512.
- Build the CLI from source and point it at a stub or local node.
- Run
xe send <destination> 1 --memo --asset XEand observe "Sent 1 XE" with the asset changed to XE. - Run
xe burn 1 --memo --yeswith stdin closed and observe "Burned 1 XE" with no confirmation prompt. Runxe burn 1with the same stdin and observe the prompt followed by "error: aborted".
Impact
A send can go out in the wrong asset when a memo value happens to be flag-like, and a burn can execute with no confirmation when a memo value is "--yes". The realistic trigger is a memo taken from a script variable or pasted input that contains a flag-like string, rather than a user typing it by hand. No remote party can trigger this without control of the user's command line or script input. No funds move to an attacker's account through this path; the send still goes to the intended destination, and the burn still burns the user's own tokens.
Suggested fix
Parse flags with a proper argument parser, or advance the loop index past a consumed option value so a value is never re-examined as a flag. The same fix applies to cmdSend and cmdBurn, and the same review should cover the other commands that scan arguments by hand.
Honest limits of this proof
The proof ran against a local build and a local stub node. It does not involve the public testnet. The trigger requires the user's own input to contain a flag-like memo value, so this is a parser defect with a narrow trigger, not a remotely exploitable vulnerability. If the maintainers intended the parser to be this simple, the honest resolution is to document the behavior and the issue drops to Info or docs.
Thread
Thanks for the report. We have read it against the code and it is being handled; we will update https://bounty.xe.network/XE-0683 when there is news.