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

JSON.parse on data before passing verification #275

Closed
emanuelb opened this issue Aug 4, 2020 · 1 comment
Closed

JSON.parse on data before passing verification #275

emanuelb opened this issue Aug 4, 2020 · 1 comment

Comments

@emanuelb
Copy link

emanuelb commented Aug 4, 2020

The call to const json = JSON.parse(jsonB64); in line 19 is done before the verification of the data in if (result) in line 30

const json = JSON.parse(jsonB64);
// @ts-ignore
const sig = new KJUR.crypto.Signature({ alg: sigalg, prov: 'cryptojs/jsrsa' });
sig.init({ xy: pubkey, curve });
sig.updateString(jsonB64);
const result = sig.verify(signature);
if (result) {
resolve(json);
} else {
reject('invalid ECDSA signature');
}

thus even not verified data will be passed to JSON.parse (which can be invalid or try to trigger DOS/other attacks)

fix:
call to JSON.parse only if verification successful (line 31 inside the if (result) block)

@kaplanlior
Copy link
Member

Fixed at c2cfc6f

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

No branches or pull requests

2 participants