tests: cover the `registry` fixed-width value guards added in #9220

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

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

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp
領域
testing

調査の方向性

Start in osquery/tables/system/windows/registry.cpp: the value buffer is allocated to lpData bytes in queryKey (~line 340), the REG_LINK conversion is around line 372, and the DWORD/QWORD guards are around lines 395-427. Write malformed values into a temporary key with RegSetValueEx, read them back through the table, and check that the short-payload cases return empty data without over-reading. Done means the four listed cases pass on Windows, and the optional ERROR_MORE_DATA case is either covered or explicitly skipped.

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

説明

test virtual tables Windows

Summary

PR #9220 fixed genuine over-reads in osquery/tables/system/windows/registry.cpp but shipped without regression tests (the affected paths are Windows-only, which the PR notes). This issue tracks adding that coverage, to bring it in line with the other bounds-check PRs in the same hardening series.

Background

queryKey allocates the value buffer to exactly lpData bytes (registry.cpp, ~line 340). Before #9220:

  • A REG_QWORD value shorter than 8 bytes caused an over-read of up to 7 bytes (*((unsigned long long*)bpDataBuff.get())).
  • REG_LINK data, which RegGetValueW does not null-terminate, was read as an unbounded wchar_t* string.

The PR guards REG_DWORD / REG_DWORD_BIG_ENDIAN on lpData >= sizeof(DWORD) and REG_QWORD on lpData >= sizeof(ULONGLONG) (~lines 395-427), and builds the REG_LINK string length-bounded from lpData / sizeof(wchar_t) (~line 372). The fixes verify by inspection, but nothing pins them.

Suggested tests

Malformed values can be written into a temporary key (e.g. RegSetValueEx with REG_QWORD type and a 1-byte payload) and then read back through the table, so no production-code hook should be needed:

  1. REG_QWORD with lpData < sizeof(ULONGLONG) — query succeeds without reading past the buffer; data is empty.
  2. REG_DWORD and REG_DWORD_BIG_ENDIAN with lpData < sizeof(DWORD) — same expectation.
  3. REG_LINK with no NUL within lpData — conversion stops at lpData / sizeof(wchar_t) characters.
  4. Optional: a value that grows between the size query and the data read (the ERROR_MORE_DATA path).

References

  • PR #9220
  • osquery/tables/system/windows/registry.cpp (buffer allocation ~line 340; REG_LINK ~372; DWORD/QWORD guards ~395-427)

Found during a post-merge review of recently merged hardening PRs.

主要言語
C++
スター
23.8k
フォーク
2.7k
平均マージ
6日 11時間
マージ済み PR(30日)
69

環境構築

はじめの一歩

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

osquery/osquery のほかの issue

osquery/osquery の issue をすべて見る

似ている issue

C++ の issue をもっと見る

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

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