Missing validation in JSON constructors, LEFT expressions, and CH-block decoding

オープン
#11,328 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@windtalker がすでに取り組んでいます。

2026年11月16日 から。

  • #11329 @windtalker による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
cpp
領域
backend, databases

調査の方向性

The report identifies three areas: JSON constructors, buildLeftUTF8Function, and CH-block decoding, including cached appends; it does not name source files or tests. Start by tracing those entry points and their existing error handling, then inspect related tests for JSON, LEFT expressions, and V0/V1/V2 decoding. Done means rejecting the described invalid inputs with the specified errors while preserving the valid cases; pull request #11329 is already open.

索引モデルが issue の本文から書いたものです。

説明

type/bug

Bug Report

1. Minimal reproduce step (Required)

These are source-level reproduction scenarios; they were not executed locally.

  1. Pass a non-NULL, zero-byte binary JSON value to the internal json_array function, or as a value argument to json_object. These functions expect binary JSON, so this input represents an invalid binary JSON payload, not a valid JSON empty string. Both nullable and non-nullable execution branches construct JsonBinary using data_from.size - 1 without first checking that the input is nonempty.
  2. Build a scalar DAG expression with signature tipb::ScalarFuncSig::LeftUTF8 and zero children, or one valid string child, then analyze it with DAGExpressionAnalyzer::getActions. buildLeftUTF8Function reads children 0 and 1 without first checking their count. With more than two children, extra arguments are silently ignored.
  3. Decode a CH-block chunk declaring two rows and two UInt64 columns, but containing two values in the first column and only one value, or no values, in the last column. For V1/V2, keep the declared sub-block row count at two and compress the shortened raw payload so compression framing remains valid. Exercise both first-chunk decoding and appending after a valid cached chunk. A single-column chunk that provides fewer values than its declared row count exposes the same missing validation.
2. What did you expect to see? (Required)

Reject non-NULL empty binary JSON with BAD_ARGUMENTS, before reading its type byte or subtracting from its length. SQL NULL values should still become JSON null, correctly encoded JSON empty strings should remain valid, and json_object should continue to accept empty member names.

Reject LEFT expressions whose child count is not exactly two with an ordinary Coprocessor::BadRequest error before accessing any child. Preserve normal two-argument UTF-8 LEFT behavior.

Reject CH-block columns whose decoded row count does not match the declared count with an ordinary CANNOT_READ_ALL_DATA error before exposing the Block to downstream execution. Check each column and sub-block, accounting for rows accumulated from previous chunks. Preserve valid V0/V1/V2 decoding, compression, and cached appends.

3. What did you see instead (Required)

For empty binary JSON constructor values, the length subtraction wraps to SIZE_MAX. JsonBinary stores that length without validation; the array/object builders can pass it through VectorWriter::write to memcpy, potentially crashing TiFlash.

For LEFT expressions with fewer than two children, the analyzer indexes outside the protobuf repeated field, potentially crashing TiFlash. Extra children are ignored instead of being rejected.

For truncated CH-block columns, numeric bulk deserialization accepts short reads at EOF. The V0 and V1/V2 decode paths do not verify each column's actual resulting size, and Block::rows() only reports the first column's size. A Block whose first column has two rows and last column has one can therefore reach downstream vectorized code that assumes equal column lengths, potentially reading outside the shorter column's valid range. The same gap exists during cached appends.

These findings were confirmed by source inspection, without a local runtime reproduction.

4. What is your TiFlash version? (Required)

master at 1e98c8ec6627674d848132a8f81b79baec80a7ad.

主要言語
C++
スター
1k
フォーク
428
平均マージ
2日 7時間
マージ済み PR(30日)
100

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pingcap/tiflash のほかの issue

pingcap/tiflash の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。