bug: ListTypeFromJson hits undefined behavior when a list type has no "element"
メンテナーはふだん 2 日以内に返信
関連するプルリクエストがすでにマージされています。
- #997 @LuciferYang による — マージ済み
評価
調査の方向性
ListTypeFromJson(src/iceberg/json_serde.cc)から始めてください。ここでは要素型を const アクセサ json[kElement] で読み取っています。同じファイルの MapTypeFromJson は GetJsonValue を通じて key と value をすでに読み取っているので、そのパターンを kElement にも適用してください。"element" を持たないリスト型オブジェクトが未定義動作を起こさず JsonParseError を返せば完了です。issue の再現手順で確認できます。
索引モデルが issue の本文から書いたものです。
説明
Summary
ListTypeFromJson in src/iceberg/json_serde.cc reads the element type with the const json[kElement] accessor and never checks that the key exists. For a list type object without "element", nlohmann's const operator[] is undefined behavior: with assertions enabled it aborts on JSON_ASSERT(it != m_data.m_value.object->end()), and under NDEBUG it dereferences the end iterator.
Reproduction
auto json = R"({"type":"list","element-id":1,"element-required":true})"_json;
auto result = TypeFromJson(json);
// Debug build: Assertion failed: (it != m_data.m_value.object->end()), function operator[], file json.hpp
Impact
Every list type goes through TypeFromJson, so a schema with a list-typed field that lacks "element" hits this whether the list is top level or nested in a struct, map or list. SchemaFromJson reaches it when parsing table metadata schemas, the add-schema table update, and the REST CreateTableRequest. Per SECURITY-THREAT-MODEL.md catalog-supplied metadata is trusted input, so this is a robustness issue rather than a security one.
Proposed Fix
Read the key with GetJsonValue<nlohmann::json>(json, kElement), the way MapTypeFromJson reads key and value, so a missing key returns JsonParseError.
Raised in https://github.com/apache/iceberg-cpp/pull/982#pullrequestreview-5477946927.
- 主要言語
- C++
- スター
- 226
- フォーク
- 133
- 平均マージ
- 5日 20時間
- マージ済み PR(30日)
- 39
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/iceberg-cpp のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
apache/iceberg-cpp#1000 · コメント 2 件 · リアクション 1 件 ·
メンテナーはふだん 2 日以内に返信
-
Support Iceberg table encryption (Java-compatible)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 8/100
apache/iceberg-cpp#988 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
apache/iceberg-cpp#959 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
apache/iceberg-cpp#946 · コメント 5 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
apache/iceberg-cpp#944 ·
メンテナーはふだん 2 日以内に返信
apache/iceberg-cpp の issue をすべて見る
似ている issue
-
llvm.memcpy with destination align but no source align asserts "Missed Source alignment!"対応中かも @pvelesko が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
KhronosGroup/SPIRV-LLVM-Translator#4093 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
SIMQ silently truncates multi-query batch search to the first query対応中かも @LHT129 が今日担当しました。 オープンkind/bug module/index needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
antgroup/vsag#3080 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 半日 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
KhronosGroup/glslang#4469 ·
メンテナーはふだん 1 日以内に返信