Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate that assetMetaDataHash is 32 bytes #253

Merged
merged 3 commits into from
Dec 9, 2020

Conversation

jasonpaulos
Copy link
Contributor

@jasonpaulos jasonpaulos commented Dec 1, 2020

Currently, the Javascript SDK does not validate assetMetadataHash properly. This value is supposed to be exactly 32 bytes long, but if you pass in a smaller value the Javascript SDK will construct and sign a transaction with that smaller value.

Then when the transaction reaches the server, the assetMetadataHash gets unpacked into the field here, which is 32 bytes long. In the case of a smaller value, it appears extra 0s are added. This means that when the server tries to verify the transaction signature it fails because a different transaction with a shorter assetMetadataHash was actually signed in Javascript.

This PR fixes this by throwing an error if assetMetadataHash isn't 32 bytes long, and I've made it so that an empty string or a zero-length Uint8Array also get treated the same as undefined for this field.

Closes #250.

src/transaction.js Outdated Show resolved Hide resolved
@jasonpaulos jasonpaulos merged commit 00a5da7 into develop Dec 9, 2020
@jasonpaulos jasonpaulos deleted the jason/assetMetadataHash-validation branch December 9, 2020 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Submitting an empty "assetMetadataHash" causes the signature validation to fail
2 participants