EVerest libocpp — SQL Injection in OCPP 2.0.1 GetChargingProfiles
In OCPP 2.0.1 GetChargingProfiles, libocpp and EVerest concatenate chargingLimitSource values directly into a SQLite IN (...) clause instead of binding them as parameters. An authenticated CSMS, or an on-path attacker on Security Profile 0 or 1, can break out of the string literal and modify the query.
- Advisory
- BYTERAY-2026-0289
- CWE
- CWE-89
- CVSS
- 8.3 (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L); 8.6 (CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:L/SC:N/SI:N/SA:N)
- Vendor
- LF Energy
- Product
- EVerest (libocpp)
- 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); standalone libocpp 0.31.1 and earlier
- Fixed in
- EVerest 2026.02.2 (commit 5f8533a4d57def1d48fe2995b01e239f7f52d8c5) and 2026.10.0 (commit c4fa1abe2c4093b27fc7c02932e487c0f8bc468f, PR 2861)
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
When a charge point handles an OCPP 2.0.1 GetChargingProfiles request, DatabaseHandler::get_charging_profiles_matching_criteria builds a SELECT query against the local SQLite database. The chargingProfilePurpose, stackLevel, and evseId filters use bound SQLite parameters. The chargingLimitSource list does not. The function wraps each CiString<20> entry in single quotes and concatenates the list into CHARGING_LIMIT_SOURCE IN (...).
A single quote inside chargingLimitSource closes the SQL string literal and injects SQL syntax into the query. An authenticated Central System Management System (CSMS), or a network attacker on the link when OCPP Security Profile 0 or 1 is in use, can read or alter rows accessible through that SQLite connection.
Affected Products and Versions
- Product: LF Energy EVerest (
lib/everest/ocpp) and standaloneEVerest/libocpp. - Affected versions: EVerest versions before
2026.02.0, and2026.02.0through2026.02.1; standalonelibocpp0.31.1and earlier (0a1880a0b12efd82e745707d4bffe50568f055fb). - Tested on:
libocppcommit0a1880a0b12efd82e745707d4bffe50568f055fband EVerest commite640fb4aa080a3dc27b653daa5d607f041e07077. - Fixed in: EVerest
2026.02.2(5f8533a4d57def1d48fe2995b01e239f7f52d8c5, backport PR 2863) and the2026.10.0line (c4fa1abe2c4093b27fc7c02932e487c0f8bc468f, PR 2861). StandaloneEVerest/libocppis archived upstream; ongoing development lives in the EVerest monorepo.
Technical Details
Inbound GetChargingProfiles messages enter SmartCharging::handle_get_charging_profiles_req (lib/ocpp/v2/functional_blocks/smart_charging.cpp, line 1154), which calls get_reported_profiles (line 1021) and passes request.chargingProfile to DatabaseHandler::get_charging_profiles_matching_criteria.
In lib/ocpp/v2/database_handler.cpp (lines 922-928 in libocpp 0.31.1; lines 957-963 in EVerest lib/everest/ocpp/lib/ocpp/v2/database_handler.cpp), the handler builds the IN clause by string concatenation:
if (criteria.chargingLimitSource.has_value() && !criteria.chargingLimitSource->empty()) {
const std::string sources = boost::algorithm::join(
criteria.chargingLimitSource.value() |
boost::adaptors::transformed([](CiString<20> source) {
return "'" + source.get() + "'";
}),
", ");
where_clauses.push_back("CHARGING_LIMIT_SOURCE IN (" + sources + ")");
}
The same function binds its neighboring filters (@charging_profile_purpose, @stack_level, and @evse_id) afterward with stmt->bind_text and stmt->bind_int.
CiString<20> does not block single quotes. CiString::is_valid (include/ocpp/common/cistring.hpp, line 38) is not declared virtual, so String<L>::set (include/ocpp/common/string.hpp, line 61) calls String<L>::is_valid, which always returns true. Even if CiString::is_valid ran, it permits all printable ASCII characters (0x20 through 0x7e), which includes ' (0x27). Passing CSO' OR '1'='1 produces:
CHARGING_LIMIT_SOURCE IN ('CSO' OR '1'='1')
Reachability and Preconditions
- The charger runs EVerest or
libocppwith OCPP 2.0.1 smart charging enabled. - The attacker controls or compromises the CSMS (
PR:Lover TLS on Security Profile 2 or 3), or sits on the network path between the charger and CSMS when Security Profile 0 or 1 (plaintext WebSocket) is configured. - No user interaction on the charger is required.
CiString<20>caps eachchargingLimitSourceentry at 20 bytes, andget_charging_profiles_matching_criteriajoins all entries in thechargingLimitSourcevector into one SQL statement.
Impact
SQL injection (CWE-89) in the charge-point SQLite store. At minimum, an attacker can bypass filter predicates in GetChargingProfiles and extract data from tables reachable on the SQLite connection via UNION queries. Depending on how SQLite and statement execution are configured, injected expressions can also alter state or cause query failures during smart-charging operations.
Remediation and Mitigation
Upgrade to EVerest 2026.02.2 or a 2026.10.0 build containing commit c4fa1abe2c4093b27fc7c02932e487c0f8bc468f (PR 2861, backported as 5f8533a4d57def1d48fe2995b01e239f7f52d8c5 in PR 2863). The fix replaces string concatenation with indexed parameter placeholders bound individually through SQLite.
Deployments that cannot upgrade immediately should enforce OCPP Security Profile 2 or 3 (TLS with mutual or server authentication) so unauthenticated on-path attackers cannot inject GetChargingProfiles frames. TLS does not stop a compromised CSMS from reaching this code path.
Timeline
- 2026-09-22 — Upstream fix merged to
mainin PR 2861 (c4fa1abe2c4093b27fc7c02932e487c0f8bc468f), and backported tostable/2026.02on 2026-10-17 (5f8533a4d57def1d48fe2995b01e239f7f52d8c5). - 2026-11-05 — Reported to EVerest by ByteRay; EVerest released
2026.02.2and publishedGHSA-qqxx-m733-jcf5.
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-qqxx-m733-jcf5.