Cryptographic Issues Affecting elliptic package, versions <6.5.3


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team

    Threat Intelligence

    Exploit Maturity
    Proof of concept
    EPSS
    0.35% (73rd percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-JS-ELLIPTIC-571484
  • published 17 Jun 2020
  • disclosed 5 Jun 2020
  • credit Unknown

How to fix?

Upgrade elliptic to version 6.5.3 or higher.

Overview

elliptic is a fast elliptic-curve cryptography implementation in plain javascript.

Affected versions of this package are vulnerable to Cryptographic Issues. Elliptic allows ECDSA signature malleability via variations in encoding, leading \0 bytes, or integer overflows. This could conceivably have a security-relevant impact if an application relied on a single canonical signature.

PoC

var crypto = require('crypto')
var EC = require('elliptic').ec;
var ec = new EC('secp256k1');

var obj = require("./poc_ecdsa_secp256k1_sha256_test.json");

for (let testGroup of obj.testGroups) {

var key = ec.keyFromPublic(testGroup.key.uncompressed, &#39;hex&#39;);

for(let test of testGroup.tests) {
 console.log(&quot;[*] Test &quot; + test.tcId + &quot; result: &quot; + test.result)

 msgHash = crypto.createHash(&#39;sha256&#39;).update(Buffer.from(test.msg, &#39;hex&#39;)).digest();
 
 try {
  result = key.verify(msgHash, Buffer.from(test.sig, &#39;hex&#39;));

 if (result == true) {
  if (test.result == &quot;valid&quot; || test.result == &quot;acceptable&quot;)
   console.log(&quot;Result: PASS&quot;);
  else
   console.log(&quot;Result: FAIL&quot;)     
 }

 if (result == false) {
  if (test.result == &quot;valid&quot; || test.result == &quot;acceptable&quot;)
   console.log(&quot;Result: FAIL&quot;);
  else
   console.log(&quot;Result: PASS&quot;)     
 }



 } catch (e) {
  console.log(&quot;ERROR - VERIFY: &quot; + e)

  if (test.result == &quot;valid&quot; || test.result == &quot;acceptable&quot;)
   console.log(&quot;Result: FAIL&quot;);
  else
   console.log(&quot;Result: PASS&quot;)     



 }


}

}

CVSS Scores

version 3.1
Expand this section

Snyk

Recommended
7.7 high
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    High
  • Privileges Required (PR)
    None
  • User Interaction (UI)
    None
  • Scope (S)
    Unchanged
  • Confidentiality (C)
    High
  • Integrity (I)
    High
  • Availability (A)
    Low
Expand this section

NVD

7.7 high
Expand this section

Red Hat

7.7 high