← ALL ADVISORIES

MEDIUM BYTERAY-2026-0406Disclosed

wolfSSL — Secret-Indexed Operands in ECC Scalar Multiplication Ladder Under ESP32 Platform Defaults

With WC_NO_CACHE_RESISTANT defined, as the ESP-IDF and Arduino ESP32 platform defaults do, the timing-resistant ECC ladder in ecc_mulmod selects the points it doubles and adds by the current secret scalar bit. The variant that keeps operand addresses constant is compiled out.

Advisory
BYTERAY-2026-0406
CWE
CWE-1300
CVSS
5.7 (CVSS:3.1/AV:P/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N)
Vendor
wolfSSL
Product
wolfSSL
Reported
2026-09-28
Disclosure
2026-12-03
Affected
wolfSSL 5.9.2 (tested at master commit d95483f), builds that use the generic ecc_mulmod ladder with ECC_TIMING_RESISTANT and WC_NO_CACHE_RESISTANT defined, as set by the ESP-IDF and Arduino ESP32 platform defaults
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

wolfCrypt's generic ECC scalar multiplication, ecc_mulmod(), has a timing-resistant double-and-add ladder. It performs the same sequence of operations for every scalar bit, so remote timing does not distinguish the bits.

The ladder exists in two forms. With WC_NO_CACHE_RESISTANT defined, each step reads and writes accumulator points chosen by the current bit of the secret scalar. The other form always works on the same point and uses constant-time swaps. The ESP-IDF and Arduino ESP32 platform defaults define WC_NO_CACHE_RESISTANT, so those builds compile the first form.

An attacker who can measure the chip's power draw or electromagnetic emissions during a remotely triggered ECDHE handshake or ECDSA signature can classify the address-dependent signature of each iteration and attempt to reconstruct the scalar. That is the ECDH private key or, from signing, ECDSA nonce bits that lead to the long-term signing key. These are the default settings for the ESP-IDF and Arduino ESP32 platforms.

Affected Products and Versions

  • Component: wolfcrypt/src/ecc.c, ecc_mulmod(), the ECC_TIMING_RESISTANT ladder at wolfcrypt/src/ecc.c:3279.
  • Required build: the generic ECC path with WC_NO_CACHE_RESISTANT. The Arduino ESP32 defaults (wolfssl/wolfcrypt/settings.h:727) and the ESP-IDF defaults (wolfssl/wolfcrypt/settings.h:1068) define it. The ESP-IDF template enables HAVE_ECC (IDE/Espressif/ESP-IDF/user_settings.h:97) with USE_FAST_MATH (IDE/Espressif/ESP-IDF/user_settings.h:165-166) and leaves SP math commented out (IDE/Espressif/ESP-IDF/user_settings.h:168-171).
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • Builds that do not define WC_NO_CACHE_RESISTANT compile the constant-address form of the ladder.
  • Other releases were not checked.

Technical Details

Each ladder iteration takes the current scalar bit, b = v & 1 (wolfcrypt/src/ecc.c:3347), and under WC_NO_CACHE_RESISTANT runs (wolfcrypt/src/ecc.c:3349-3354):

        err = ecc_projective_dbl_point_safe(R[b^1], R[b^1], a, modulus, mp);
        if (err == MP_OKAY) {
            err = ecc_projective_add_point_safe(R[b^1], R[b], R[b^1], a,
                                                        modulus, mp, &infinity);
        }

The final addition is selected by the low scalar bit in the same way: b = k->dp[0] & 1, then an add on R[b] (wolfcrypt/src/ecc.c:3406-3408). The #else branch (wolfcrypt/src/ecc.c:3356-3375) always operates on R[0] and swaps with mp_cond_swap_ct_ex. It is excluded by the same macro.

Coordinate randomization does not cover this. wc_ecc_gen_z runs only when an RNG is passed (wolfcrypt/src/ecc.c:3322-3325). The public wc_ecc_mulmod entry passes NULL (wolfcrypt/src/ecc.c:4193), and wc_ecc_mulmod_ex forwards an RNG only under FP_ECC (wolfcrypt/src/ecc.c:3880-3882). Where it runs, it hides coordinates and not which point is addressed.

  1. A TLS peer sends its ECDHE public point.
  2. wc_ecc_shared_secret_ex (wolfcrypt/src/ecc.c:5267) reaches wc_ecc_mulmod_ex2 with the private scalar (wolfcrypt/src/ecc.c:5082), which reaches the ecc_mulmod() ladder.
  3. Each iteration doubles and adds on R[b^1] and R[b], and the final add uses R[b].
  4. ECDSA signing multiplies the secret nonce through ecc_make_pub_sw (wolfcrypt/src/ecc.c:5569) into the same ladder.

The Espressif port accelerates big-number, AES and SHA operations and has no ECC acceleration, so nothing takes this work off the software ladder.

Reachability and Preconditions

  • Build with the ESP-IDF or Arduino ESP32 platform defaults, or any build that defines WC_NO_CACHE_RESISTANT and uses the generic ECC ladder.
  • The device performs ECDHE key agreement or ECDSA signing. A remote peer can trigger both through TLS handshakes without authentication.
  • The attacker has physical or near-field access to measure power or electromagnetic emissions.
  • Many traces are needed. For ephemeral ECDH the analysis has to work within a trace unless the key is reused across sessions.

Impact

Recovery of the ECDH private scalar, which compromises session keys, or recovery of enough ECDSA nonce bits to compute the long-term signing key, which allows impersonation of the device. The ladder gives no timing signal, so the attack depends on physical instrumentation.

ByteRay did not build a proof of concept for this issue. The analysis is from source review.

Remediation and Mitigation

ByteRay has not confirmed a fixed wolfSSL release for this issue as of 2026-12-03, and has not checked it against wolfSSL changes made after the tested commit.

The fix direction is to remove WC_NO_CACHE_RESISTANT from the ESP32 and Arduino ESP32 platform defaults, or make it an explicit opt-in, so the constant-address ladder is what ships. Passing a live RNG into all secret-scalar multiplications, including the public wc_ecc_mulmod entry, adds coordinate randomization as a second layer. Workaround: undefine WC_NO_CACHE_RESISTANT in the application's settings and keep ECC_TIMING_RESISTANT on. Building with SP math for the curves in use is an alternative, since it takes secret scalar multiplications off this ladder.

Timeline

  • 2026-09-28 — Reported to wolfSSL.
  • 2026-12-03 — Public disclosure.

Credits

Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.

References