Skip to content

Fix ECC validation regression#10260

Open
Frauschi wants to merge 1 commit intowolfSSL:masterfrom
Frauschi:ecc_fix
Open

Fix ECC validation regression#10260
Frauschi wants to merge 1 commit intowolfSSL:masterfrom
Frauschi:ecc_fix

Conversation

@Frauschi
Copy link
Copy Markdown
Contributor

Fix a regression accidentally added in #9851 due to rebasing after #10133 has landed. Added a test to catch this in the future.
Fixes zd#21654.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 20, 2026

MemBrowse Memory Report

No memory changes detected for:

@Frauschi
Copy link
Copy Markdown
Contributor Author

Jenkins retest this please

@JacobBarthelmeh
Copy link
Copy Markdown
Contributor

Retest this please Jenkins. The history is no longer available.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes a regression in ECC point validation during X9.63 public key import by ensuring the legacy import wrapper treats inputs as untrusted, and adds a regression test to catch off-curve points in the future.

Changes:

  • Update wc_ecc_import_x963_ex to pass untrusted=1 so imported points are validated as on-curve.
  • Add an API test that imports a deliberately off-curve P-256 point and expects rejection.
  • Register the new test in the ECC API test header.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
wolfcrypt/src/ecc.c Restores on-curve validation by treating X9.63 imports as untrusted in the wrapper.
tests/api/test_ecc.h Declares and registers a new ECC X9.63 off-curve regression test.
tests/api/test_ecc.c Adds a regression test asserting off-curve X9.63 points are rejected.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/api/test_ecc.c
Comment on lines +778 to +783
* Regression coverage for the invalid-curve attack: the legacy wrapper
* wc_ecc_import_x963_ex must pass untrusted=1 to wc_ecc_import_x963_ex2
* so that ECIES, PKCS#7 KARI, and EVP ECDH callers validate that the
* imported point actually lies on the curve. Without that, an attacker
* can feed a point from a weak twist and leak the victim's private
* scalar modulo small primes (Biehl-Meyer-Mueller).
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is internally inconsistent: it says it’s testing wc_ecc_import_x963(), but then describes the regression as being in the wc_ecc_import_x963_ex wrapper. Please update the comment to match the function/path actually being tested (or update the test to exercise the wrapper that regressed) so future readers understand what regression this test is guarding.

Suggested change
* Regression coverage for the invalid-curve attack: the legacy wrapper
* wc_ecc_import_x963_ex must pass untrusted=1 to wc_ecc_import_x963_ex2
* so that ECIES, PKCS#7 KARI, and EVP ECDH callers validate that the
* imported point actually lies on the curve. Without that, an attacker
* can feed a point from a weak twist and leak the victim's private
* scalar modulo small primes (Biehl-Meyer-Mueller).
* Regression coverage for the invalid-curve attack in the public-point
* import validation path. This test directly exercises
* wc_ecc_import_x963(), which must reject points that do not lie on the
* selected curve. A related historical regression was in the legacy
* wc_ecc_import_x963_ex wrapper, which must pass untrusted=1 to
* wc_ecc_import_x963_ex2 so higher-level callers validate imported
* public points before use.

Copilot uses AI. Check for mistakes.
Comment thread tests/api/test_ecc.c
Comment on lines +812 to +813
ExpectIntNE(wc_ecc_import_x963(offCurveX963, (word32)sizeof(offCurveX963),
&pubKey), 0);
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test currently calls wc_ecc_import_x963(...), but the regression described in the PR is in the legacy wrapper wc_ecc_import_x963_ex(...) passing the untrusted flag. To ensure the test actually covers the fixed code path, consider calling wc_ecc_import_x963_ex(offCurveX963, sizeof(offCurveX963), &pubKey, ECC_SECP256R1) (or the appropriate curve id constant used elsewhere in this test suite). If wc_ecc_import_x963 already routes through _ex, please make that explicit in the test comment to avoid ambiguity.

Copilot uses AI. Check for mistakes.
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.

4 participants