Repository navigation
Conversation
parse_account_id documented the recipient as an SS58 address with the Quantus prefix (189) but discarded the decoded version, so the same 32-byte account encoded for any other network (e.g. the generic Substrate prefix 42) was accepted and signed for. The SS58 prefix is the only signal that the sender meant a Quantus address, so validate it against SS58_PREFIX and reject foreign prefixes. Recipient parsing is split into parse_account_id_checked with plain string errors so the validation is unit-testable off-wasm (JsError::new panics on non-wasm targets); parse_account_id keeps the same messages. Adds regression tests for both the Quantus-prefix accept and the foreign-prefix reject. cargo test: 11 passed.
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.
signTransferdocuments its recipient as "SS58 (prefix 189) or 0x-hex", butparse_account_idthrew the decoded SS58 version away:so the same 32-byte account encoded for any other network was accepted and signed for. I reproduced it with the generic Substrate prefix:
[2u8; 32]encoded at prefix 42 (5C7LYpP2ZH3tpKbvVvwiVe54AapxErdPBbvkYhe6y9ZBkqWt) parsed as a valid Quantus recipient. The prefix is the only signal that the sender actually meant a Quantus address — without the check, pasting an address copied from a different chain's address book silently produces a signed Quantus transfer to that account.Fix:
ext::SS58_PREFIX(189) and reject anything else withrecipient: SS58 address is not a Quantus (prefix 189) address. Hex recipients are unchanged.parse_account_id_checked(plain&'static strerrors) withparse_account_idas a thinJsErrorwrapper keeping the exact same messages. This is needed to test the error path at all:JsError::newpanics on non-wasm targets, which is also why the new tests call the checked helper.cargo testis 11 passed / 0 failed andcargo clippy --all-targetsis clean. No newcargo fmtdiffs (the pre-existing ext.rs/mnemonic.rs diffs under this rustfmt are untouched).@Kshot9000 (https://x.com/kshot9000) · QTC donations: qznY8nwuvWcCCVys4da1oQdysyh8YUZYRjRqgk3S8Wos8kbau · cc @Quantus-Network