//nefariousplan

CVE-2026-37537: The Bound Was a Comment

pattern

cve

Line 23 of Transport_Protocol_Data_Transfer.cpp in collin80/Open-SAE-J1939 reads a byte off a CAN frame and uses it as an array index. The valid range of that byte is documented in a comment in Structs.h, two files away: between 2 and 224, because 1785 divided by 8 is 224 rounded up. The comment is not a check. When the byte arrives as zero, a uint8_t index underflows to 255, and the loop on line 25 writes seven attacker-controlled bytes past the end of a 1785-byte buffer, into the next struct in the J1939 state machine. CVE-2026-37537 is those seven bytes. The commit the CVE names is three years old, and it is the most recent commit the repository has.

Line 23

The vulnerable file is src/SAE_J1939/SAE_J1939-21_Transport_Layer/Transport_Protocol_Data_Transfer.cpp. The function is SAE_J1939_Read_Transport_Protocol_Data_Transfer, called every time the ECU receives a J1939 Transport Protocol Data Transfer frame on PGN 0xEB00. The bug is on the third line of the function body:

void SAE_J1939_Read_Transport_Protocol_Data_Transfer(J1939 *j1939, uint8_t SA, uint8_t data[]) {
    /* Save the sequence data */
    j1939->from_other_ecu_tp_dt.sequence_number = data[0];
    j1939->from_other_ecu_tp_dt.from_ecu_address = SA;
    uint8_t index = data[0] - 1;
    for (uint8_t i = 1; i < 8; i++)
        j1939->from_other_ecu_tp_dt.data[index*7 + i-1] = data[i];

data[0] is the sequence number byte from a CAN frame. The CAN frame is an unauthenticated, unsigned wire-format message arriving over a shared bus. The function stores data[0] into from_other_ecu_tp_dt.sequence_number, then declares uint8_t index = data[0] - 1. The subtraction is unsigned. When data[0] is 0, index underflows to 255.

The loop runs i from 1 to 7 inclusive. Each iteration writes to from_other_ecu_tp_dt.data[index*7 + i-1]. With index = 255, the writes target offsets 1785 through 1791 of the data[] array. The array is declared uint8_t data[MAX_TP_DT], where MAX_TP_DT is 1785, indexed 0 through 1784. Every iteration of the loop is an out-of-bounds write.

The bytes written into those offsets come from data[1] through data[7]: the remaining seven bytes of the same CAN frame the sequence number arrived on. The attacker controls the index (through data[0]) and the seven bytes written (through data[1..7]).

The parent state object is the J1939 struct in Structs.h. Its field ordering is fixed:

struct TP_DT {
    uint8_t sequence_number;
    uint8_t data[MAX_TP_DT];
    uint8_t from_ecu_address;
};

typedef struct {
    /* ... */
    struct TP_CM from_other_ecu_tp_cm;
    struct TP_DT from_other_ecu_tp_dt;
    struct DM    from_other_ecu_dm;
    struct Identifications from_other_ecu_identifications;
    /* ... */
} J1939;

Writing past from_other_ecu_tp_dt.data[] reaches from_other_ecu_tp_dt.from_ecu_address, then continues into from_other_ecu_dm, which begins with errors_dm1_active, errors_dm2_active, and the byte fields of the embedded dm1. Those fields drive the diagnostic message dispatcher elsewhere in the library. Setting them to attacker-chosen values puts the ECU into states the diagnostic state machine does not expect, with no protocol-level signal that anything is wrong.

CVSS records this as CVE-2026-37537, vector AV:A/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H, score 8.1.

The bound was documented two files away

The valid range of data[0] is not a mystery. The author of the library wrote it down. In src/Open_SAE_J1939/Structs.h:

struct TP_CM {
    uint8_t  control_byte;
    uint16_t total_message_size;
    uint8_t  number_of_packages;  /* How many times we are going to send packages via TP_DT - 2 to 224 because 1785/8 is 224 rounded up */
    uint32_t PGN_of_the_packeted_message;
    uint8_t  from_ecu_address;
};

struct TP_DT {
    uint8_t sequence_number;      /* When this sequence number is the same as number_of_packages from TP_CM, then we have our complete message */
    uint8_t data[MAX_TP_DT];
    uint8_t from_ecu_address;
};

The bound is in plain English. Number-of-packages is 2 to 224. The math is shown: 1785 divided by 8 equals 224 rounded up. The sequence number is described in the next struct as the value that matches number_of_packages from TP_CM, which implies its range is [1, number_of_packages], which is bounded by [1, 224].

The bound is also in the SAE J1939-21 specification. A sequence number of zero is not a valid TP-DT frame by the protocol. The first packet in a multi-packet transfer is sequence number 1.

The bound is also in the protocol's flow control. A RTS (Request To Send) frame in the TP-CM module declares number_of_packages before any TP-DT frames arrive. The receiver is supposed to reject TP-DT frames whose sequence number is outside [1, number_of_packages].

The bound exists in three places: the author's prose, the SAE standard, and the protocol's own flow control. None of those three becomes a runtime check inside SAE_J1939_Read_Transport_Protocol_Data_Transfer. The function does not read from_other_ecu_tp_cm.number_of_packages. The function does not compare data[0] against any constant. The function does not validate that the TP_CM module has been initialized at all. A TP-DT frame received with no prior TP-CM exchange runs the same loop with the same arithmetic and the same out-of-bounds write.

The check the author wrote down was the check the compiler never ran.

The fork is frozen at the commit the CVE names

The CVE description names the commit by hash: 744024d4306bc387857dfce439558336806acb06, dated 2023-03-08. That hash is the master branch's HEAD.

$ git log --oneline
744024d Basically gutted remaining support for STM32 or the other default environments. Now supports CAN_COMMON compliant interfaces and Teensy FlexCAN_T4 which are the environments I needed.
ec3d7bf Restructured readme a bit
d21a825 Add Arduino library properties file
9f1bd73 Initial commit of modified library. Now geared toward Arduino

Four commits, all in February and March 2023. The repository has not been touched since. The library was modified to target Teensy FlexCAN_T4, the Arduino-compatible CAN board that researchers and small fleet operators use to talk to heavy-duty vehicle networks from a microcontroller. The fork was the author's working copy for a specific Teensy-based project. It was published, then frozen.

There will be no patch on this fork. There is no maintainer for this fork. The CVE record will exist as long as the fork's commit history does.

The upstream has the same line

collin80/Open-SAE-J1939 is a fork of DanielMartensson/Open-SAE-J1939. The upstream is still maintained. Its master branch HEAD is b6caf88. The upstream's TP-DT module contains:

// daniel/Src/SAE_J1939/SAE_J1939-21_Transport_Layer/Transport_Protocol_Data_Transfer.c, line 23
uint8_t i, j, index = data[0] - 1;
for (i = 1; i < 8; i++){
    j1939->from_other_ecu_tp_dt.data[index*7 + i-1] = data[i];
}

Identical arithmetic. Identical offset. Identical out-of-bounds write. The upstream adds CTS flow-control handling around the assignment (it sends a CTS retransmit when the sequence number does not match number_of_packages_being_transmitted), but the retransmit decision runs after the unsafe write executes. The bug is in the upstream at the same line, in the same function, in the same module.

CVE-2026-37537 names the collin80 fork. The upstream is covered by CVE-2026-37534 and CVE-2026-42467, filed for an integer-underflow and a stack overflow in the same Transport Layer module. The same disclosure batch produced both sets of CVE numbers. The fork's CVE and the upstream's CVEs travel on the same vulnerability gist, in adjacent rows of the same table.

The upstream's line 23 is not in either of the upstream's CVE titles. It is the same bug as CVE-2026-37537 in everything but ownership. The disclosure treated the fork as its own product because the fork has its own GitHub URL.

What "adjacent" means on a truck

The CVSS vector is AV:A. Reading that on a web vulnerability, adjacent usually means a shared layer-2 segment, a research lab, a corporate VLAN. On a heavy-duty vehicle CAN bus, adjacent means:

  • The OBD-II port under the dash.
  • The trailer connector behind the cab.
  • The aftermarket telematics dongle the fleet's insurance carrier mailed the operator.
  • The post-sale ECU upgrade module bolted to the harness.
  • The cell-connected gateway whose firmware does not strictly filter the CAN frames it forwards from a remote endpoint.

AC:L is honest about how easy it is to inject a frame onto a J1939 bus once any of the above is in reach. PR:N is honest about the absence of authentication on the CAN protocol. S:U (Scope: Unchanged) is the line that needs unpacking. The scope is "unchanged" because the J1939 protocol assumes the bus is a closed network and a malformed frame stays within the trust domain of the parser that receives it. The engine ECU, the transmission ECU, the brake controller, and the trailer brake controller all sit on the same bus and trust each other's frames the same way SAE_J1939_Read_Transport_Protocol_Data_Transfer trusts data[0]. Scope is unchanged because the threat model says the bus is friendly.

The disclosure is a survey

CVE-2026-37537 cites a gist by Feng Ning of Innora Security Research, dated 2026-04-30. The gist is not a single-CVE writeup. It is a batch disclosure of eleven CVEs across eight CAN, J1939, ISO-TP, UDS, and CAN-log-format libraries:

Library Class of bug
Open-SAE-J1939 (upstream) TP-CM size-calculation underflow, stack overflow
collin80/Open-SAE-J1939 (this fork) TP-DT sequence-number underflow
openxc/isotp-c ISO 15765-2 reassembly OOB read
miaofng/uds-c UDS service-data stack overflow
socketcand CAN ID string stack overflow
cannelloni UDP/TCP/SCTP-tunneled CAN frame parsing heap overflow
OpenAMP ELF loader 32-bit multiplication overflow on PT_LOAD size
OVMS3 (three log parsers) header-length-driven memcpy into stack buffer

Every entry in the table is the same shape. A wire-format integer drives a memory operation without a bounds check. Different fields, different libraries, different protocols, different attack surfaces. The same bug class in every one of them.

The gist is not a vulnerability disclosure. The gist is a survey of one bug class across one ecosystem. The eight libraries were not chosen because they share code. They were chosen because they share a worldview: the bus is a closed network, the wire is a trusted source, the protocol defines the legal range so the legal range is what arrives. Each library implements the worldview in different code. The disclosure shows the worldview produces the same class of bug in every implementation.

This is the closed-network-assumed shape. A parser written for a "trusted" bus accepts framing fields as if the protocol's valid-range constraints were guaranteed by the medium. Sequence numbers, length fields, and indices arrive without bounds checks because the developer's threat model excludes adversaries on the wire. When the bus admits a malformed frame, the protocol-derived constant becomes the size of the overflow.

CVE-2026-37537 is one row of the survey. The fork's specific CVE will not be patched. The upstream's matching bug travels on different CVE numbers. The other seven libraries each have their own. The worldview is intact.

PoC: collin80/Open-SAE-J1939 · Disclosure: Innora Security Research

The bug is the threat model. There is no patch for a threat model.