Out-of-bounds read in MyDateTime formatting from unvalidated packed values

Abierto
#11,336 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@ChangRui-Ryan ya está trabajando en esto.

Desde el 16/11/2026.

  • #11337 de @ChangRui-Ryan — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
cpp, grpc
Área
backend, security

Línea de trabajo

Start with decodeLiteral in dbms/src/Flash/Coprocessor/DAGUtils.cpp and the packed-value constructor and formatters in dbms/src/Common/MyTime.cpp. Trace how malformed literals and boundary rounding or timezone shifts reach formatting, then inspect the linked pull request for ongoing work. Done means packed datetimes are range-checked before unsafe formatting paths and tests cover crafted out-of-range values and boundary cases.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

affects-25.10 affects-26.3 affects-26.9 affects-7.5 affects-8.1 affects-8.5 severity/major type/bug

Bug Report

1. Minimal reproduce step (Required)

tipb::ExprType::MysqlTime literals are decoded without any range check
(decodeLiteral in dbms/src/Flash/Coprocessor/DAGUtils.cpp), and
MyTimeBase::MyTimeBase(UInt64 packed) (dbms/src/Common/MyTime.cpp:322)
unpacks the raw 64-bit value without validating the format invariants.
The UInt64 field then passes through convertFieldToType unchanged into
DataTypeMyDateTime columns.

Send a hand-crafted coprocessor/MPP request to the TiFlash service port
containing a datetime literal whose 8-byte val encodes out-of-range
fields, e.g. micro_second = 16777215 (> 999999) or year = 20164
(> 9999), and let any formatting path consume it
(date_format(col, '%f'), cast(col as string), or result
serialization).

  • MyDateTime::toString / %f formatter indexes
    int_to_2_width_string[micro_second / 10000] → up to index 1677
  • %Y/%X/%x formatters index int_to_2_width_string[year / 100]
    → up to index 201

(int_to_2_width_string is a 100-entry static array.)

Under ASan any such request reports a global-buffer-overflow in
dbms/src/Common/MyTime.cpp. Legitimate TiDB instances never emit such
values (datetime literals are validated at parse time), so this requires
a directly crafted gRPC request.

Out-of-range packed values can also be produced internally at the max
datetime boundary (pre-existing issue, same sink): fraction-rounding
overflow on 9999-12-31 23:59:59.9999999 and timezone-shift of
9999-12-31 23:59:59-14:00 yield year=10000, i.e.
int_to_2_width_string[100], one-past-end.

2. What did you expect to see? (Required)

Out-of-range packed datetime values must be rejected at the request
boundary, and every packed value reaching MyDateTime must stay within
the documented field ranges (year <= 9999, micro_second <= 999999,
etc.). No memory-safety violation regardless of request bytes.

3. What did you see instead (Required)

Out-of-bounds reads up to ~1.6k entries past the end of the static
int_to_2_width_string array. The adjacent global memory is
interpreted as String objects and appended into the query result
returned to the client — information disclosure — or causes a crash on
invalid String objects. Classified High / INFORMATION_DISCLOSURE by
the internal code-security scan (first detected 2026-11-13).

4. What is your TiFlash version? (Required)

master

Lenguaje dominante
C++
Estrellas
1k
Forks
428
Merge medio
2 d 7 h
PR fusionados (30 d)
100

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de pingcap/tiflash

Todos los issues de pingcap/tiflash

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.