← ALL ADVISORIES

MEDIUM BYTERAY-2026-0291Patched

EVerest — Null Pointer Dereference in EvseV2G PaymentDetails

In EvseV2G ISO 15118-2 PaymentDetails, handle_iso_payment_details reads the eMAID from the parsed contract certificate before checking the parse status, then writes through conn->pubkey behind only an assert. A malformed certificate or a plain-TCP session crashes EvseV2G.

Advisory
BYTERAY-2026-0291
CWE
CWE-476
CVSS
6.5 (CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H); 7.1 (CVSS:4.0/AV:A/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N)
Vendor
LF Energy
Product
EVerest
Reported
2026-11-05
Disclosure
2026-11-05
Affected
EVerest before 2026.02.2 (all releases prior to 2026.02.0, and 2026.02.0 through 2026.02.1), EvseV2G ISO 15118-2
Fixed in
EVerest 2026.02.2 (commit eb158d037fc32d1b219ee3f964c2e8248f08ef3a) and 2026.10.0 (commit 73058ac943ba25c2eef65b205b0d500e25ddb5c9, PR 3047)
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

When an EV sends an ISO 15118-2 PaymentDetails request on the Plug & Charge (Contract) path, handle_iso_payment_details in EvseV2G parses the leaf certificate into contract_crt and stores the status in err. Before checking err, it extracts the eMAID from contract_crt. A certificate blob that fails DER decoding leaves contract_crt null and crashes the module while reading the subject name.

If the leaf certificate parses, the handler then checks conn->pubkey only with assert(conn->pubkey != nullptr) before writing *conn->pubkey. Plain TCP connections leave conn->pubkey null, and handle_iso_payment_service_selection previously recorded Contract even after rejecting it on TCP. In debug builds the assertion aborts the process; in NDEBUG release builds the write dereferences a null pointer.

Affected Products and Versions

  • Product: LF Energy EVerest, EvseV2G module (modules/EVSE/EvseV2G/iso_server.cpp), ISO 15118-2 Plug & Charge (Contract) path.
  • Affected versions: EVerest versions before 2026.02.0, and 2026.02.0 through 2026.02.1.
  • Tested on: EVerest commit e640fb4aa080a3dc27b653daa5d607f041e07077.
  • Fixed in: EVerest 2026.02.2 (eb158d037fc32d1b219ee3f964c2e8248f08ef3a, backport PR 3264) and the 2026.10.0 line (73058ac943ba25c2eef65b205b0d500e25ddb5c9, PR 3047).

Technical Details

In modules/EVSE/EvseV2G/iso_server.cpp, handle_iso_payment_details (lines 1151-1184) parses the vehicle's contract leaf certificate and uses it before testing err:

if (req->ContractSignatureCertChain.Certificate.bytesLen != 0) {
    err = parse_contract_certificate(contract_crt,
                                     req->ContractSignatureCertChain.Certificate.bytes,
                                     req->ContractSignatureCertChain.Certificate.bytesLen);
} else {
    res->ResponseCode = iso2_responseCodeType_FAILED_CertChainError;
    goto error_out;
}

auto cert_emaid = getEmaidFromContractCert(contract_crt);
/* ... compare eMAID, possibly goto error_out ... */

if (err != 0) {
    memset(res, 0, sizeof(*res));
    res->ResponseCode = iso2_responseCodeType_FAILED_CertChainError;
    goto error_out;
}

assert(conn->pubkey != nullptr);
*conn->pubkey = certificate_public_key(contract_crt.get());

parse_contract_certificate (modules/EVSE/EvseV2G/crypto/crypto_openssl.cpp, line 161) calls ::openssl::der_to_certificate and returns -1 with contract_crt == nullptr when DER parsing fails. getEmaidFromContractCert (line 166) immediately calls ::openssl::certificate_subject(crt.get()) (lib/everest/tls/src/openssl_util.cpp, line 774), which executes assert(cert != nullptr) at line 775 and X509_get_subject_name(cert) at line 779. The if (err != 0) check at line 1176 of iso_server.cpp is reached too late.

conn->pubkey is allocated only on TLS connections (modules/EVSE/EvseV2G/connection/tls_connection.cpp, line 36). Plain TCP connections allocate v2g_connection with calloc (connection/connection.cpp, line 656), leaving conn->pubkey null. With the default tls_security: allow and terminate_connection_on_failed_response: false, handle_iso_payment_service_selection rejected Contract over TCP with FAILED_PaymentSelectionInvalid (lines 1016-1029) yet still wrote session.iso_selected_payment_option = Contract (lines 1108-1114). A subsequent PaymentDetailsReq carrying any parseable DER certificate reached lines 1182-1183 (and a skipped PaymentDetailsReq reached the same assert(conn->pubkey != nullptr) pattern in handle_iso_authorization at lines 1365-1367).

Reachability and Preconditions

  • The charger runs EvseV2G with ISO 15118-2 enabled.
  • Over TLS with Plug & Charge offered, any plugged-in EV can send a PaymentDetailsReq whose Certificate bytes are non-empty and invalid DER; no valid contract certificate chain is required.
  • Over plain TCP (enabled under the shipped tls_security: allow and terminate_connection_on_failed_response: false defaults), an EV can select Contract, ignore FAILED_PaymentSelectionInvalid, and send PaymentDetailsReq with either invalid DER or any parseable certificate to hit the null conn->pubkey write.

Impact

Null pointer dereference (CWE-476) or reachable assertion abort in EvseV2G. A single crafted PaymentDetails message from a connected vehicle terminates the EvseV2G module process and interrupts ISO 15118 charging on the station. No out-of-bounds write or memory disclosure occurs.

Remediation and Mitigation

Upgrade to EVerest 2026.02.2 or a 2026.10.0 build containing commit 73058ac943ba25c2eef65b205b0d500e25ddb5c9 (PR 3047, backported as eb158d037fc32d1b219ee3f964c2e8248f08ef3a in PR 3264). The fix checks err and contract_crt before reading the eMAID, replaces the conn->pubkey assertion with a runtime null check that returns FAILED_CertChainError, and prevents PaymentServiceSelection from switching the session to Contract when the option was not offered.

Setting tls_security: force and terminate_connection_on_failed_response: true blocks the plain-TCP conn->pubkey path, but does not prevent the null contract_crt dereference on malformed DER certificates when Plug & Charge is offered over TLS.

Timeline

  • 2026-10-27 — Upstream fix merged to main in PR 3047 (73058ac943ba25c2eef65b205b0d500e25ddb5c9), and backported to stable/2026.02 on 2026-10-30 (eb158d037fc32d1b219ee3f964c2e8248f08ef3a).
  • 2026-11-05 — Reported to EVerest by ByteRay; EVerest released 2026.02.2 and published GHSA-qg7p-grpm-cg3f.

Credits

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

EVerest credited @Mehrrun in the 2026.02.2 release notes and published GHSA-qg7p-grpm-cg3f.

References