Skip to content
Memory corruption Disclosed report Advanced CVE-2026-107815

Stack Buffer Overflow in MariaDB CONNECT storage engine when reading DOUBLE columns from TABLE_TYPE=DOS tables

A stack buffer overflow exists in MariaDB's CONNECT storage engine when reading DOUBLE columns from TABLE_TYPE=DOS tables, because the NUL terminator is written at an unclamped index. An attacker could crash the MariaDB server, causing a denial of service.

dstesk Follow

Originally disclosed on HackerOne

  • Triaged in 3 days
  • Fixed in 36 days
  • Disclosed after 2 months

This problem is located in storage/connect/value.cpp, function TYPVAL<double>::SetValue_char(). The function copies at most 31 bytes into a 64-byte stack buffer, but subsequently places the terminating "\0" byte using the original field length (n) instead of the bounded length.

bool TYPVAL<double>::SetValue_char(const char *p, int n){
  if (p && n > 0) {
    char buf[64];

    for (; n > 0 && *p == ' '; p++)
      n--;

    memcpy(buf, p, MY_MIN(n, 31));
    buf[n] = '\0';

When a DOUBLE(M,D) column is read back from a TABLE_TYPE='DOS' file, TYPVAL<double>::SetValue_char() copies the textual field into a 64-byte stack buffer, and then writes the terminating NUL byte at index n , where n is the SQL-declared field width, not the bounded copy length. The memcpy() that fills the buffer is correctly clamped with MY_MIN(n, 31), but the terminator buf[n] = '\0' is not clamped at all.

Because the SQL layer accepts widths up to 255, the C layer ends up executing buf[255] = '\0' on a 64-byte buffer, a single-byte (0x00) write up to 191 bytes past its end (for example).

Call chain:

  1. DOUBLE(255,30) is accepted by the SQL layer and field_length becomes 255 (sql/field.cc)
  2. CONNECT copies the declared width unchanged (ha_connect.cc)
  3. That length becomes the column's Long field, again unchanged (reldef.cpp, colblk.cpp, tabdos.cpp)
  4. DOSCOL::ReadColumn() assigns field = Long and passes it straight into the value parser (tabdos.cpp)
        case TYPE_DOUBLE:
          if (!(err = Value->SetValue_char(p, field))) {

PoC:

  1. Build with ASAN
  2. Run PoC.sh script (trigger + config inline in its launch flags)

Dockerfile: https://gist.github.com/dldLambda/58ad85abfb9bc65d661a69faba7523e0 PoC.sh script: https://gist.github.com/dldLambda/f4bc2a9c343bb28404989dba2628d2bf

Under ASAN, the server reports a stack-buffer-overflow write of 1 byte at the buf[n] = '\0' line in TYPVAL<double>::SetValue_char Without ASAN, the server crashes

Impact

Attacker can trigger a Denial of Service by crashing the MariaDB server.

The original report as published on HackerOne, by dstesk. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The memcpy is clamped with MY_MIN(n, 31) but the terminating NUL write buf[n] = '\0' uses the unclamped field width n, so a large declared width writes past the 64-byte stack buffer.

Impact

An attacker can trigger a denial of service by crashing the MariaDB server; without ASAN the server crashes.

What the attacker needed

Ability to create a DOS table with a DOUBLE column; declared width up to 255

How it was found

  1. Build MariaDB with ASAN enabled
  2. Run the provided PoC script that triggers the issue with inline config
  3. Observe the ASAN stack-buffer-overflow report or server crash

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A program keeps a small fixed-size box in memory (a 'buffer') to hold text. When copying text in, it correctly limits how much it copies, but then writes a single zero byte at a position based on the declared column width rather than the limited length, so the zero lands outside the box. Writing outside a buffer can corrupt memory and crash the program.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More from MariaDB

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.