Skip to content
Crypto Disclosed report Advanced CVE-2017-7781

Issue with elliptic curve addition in mixed Jacobian-affine coordinates

The elliptic curve point addition algorithm in mixed Jacobian-affine coordinates is incorrect and may return the point at infinity when it should not. An attacker could potentially exploit this to cause incorrect cryptographic operations, though the text does not specify a concrete attack.

Antonio Sanso Follow

Originally disclosed on Mozilla

  • Fixed in 2 months
  • Paid in 2 months
  • Disclosed after 2 months
Text
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:52.0) Gecko/20100101 Firefox/52.0
Build ID: 20170316213829

Steps to reproduce:

The implemented elliptic curve point  addition  algorithm that uses mixed Jacobian-affine coordinates is currently incorrect. It may yield a result POINT_AT_INFINITY when it should not.

You can find the implementation in 

https://hg.mozilla.org/projects/nss/file/215207b4864c/lib/freebl/ecl/ecp_jm.c

ec_GFp_pt_add_jm_aff(const mp_int *px, const mp_int *py, const mp_int *pz,
                     const mp_int *paz4, const mp_int *qx,
                     const mp_int *qy, mp_int *rx, mp_int *ry, mp_int *rz,
                     mp_int *raz4, mp_int scratch[], const ECGroup *group)





Actual results:

The ec_GFp_pt_add_jm_aff implements the algorithm found in "Software Implementation of the NIST Elliptic Curves Over Prime Fields" (http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=7F30DF02245F1428D542471889BEEAAB?doi=10.1.1.144.5095&rep=rep1&type=pdf) page 12 algorithm 3.

It does implement the algorithm verbatim as in the paper . 
The problem is that in the formula reported in the paper  is actually incomplete. Indeed it can happen that

C = X2 Z1^2  -  A is equal to zero .

This will eventually yield  a result POINT_AT_INFINITY (since C is everywhere in the formulas) when it should not.


Expected results:

You can find the correct algorithm in https://en.wikibooks.org/wiki/Cryptography/Prime_Curve/Jacobian_Coordinates (Point Addition (12M + 4S)).

There this case is taken in consideration

...
if (U1 == U2)
  if (S1 != S2)
    return POINT_AT_INFINITY
  else 
    return POINT_DOUBLE(X1, Y1, Z1)


and the outcome would be POINT_DOUBLE(X1, Y1, Z1)

The original report as published on Mozilla's Bugzilla, by Antonio Sanso. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the algorithm copied from a paper is incomplete because it does not handle the case where the intermediate value C equals zero, which should lead to point doubling instead of returning the point at infinity.

Impact

The incorrect result could cause cryptographic operations to produce wrong outputs, potentially leading to security failures, but the text does not describe a specific exploit.

What the attacker needed

None

The fix

The algorithm should be corrected to handle the case where C equals zero by performing point doubling, as shown in the referenced Wikibooks algorithm.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Elliptic curve cryptography uses mathematical operations on points on a curve to secure data. This report says that one of those operations, adding two points, can give the wrong answer in a specific case, which could break security. The text does not explain how an attacker would use this.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by Antonio Sanso

View all

2 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.