Out-of-bounds write in HLSLTokenizer::Next() when a preset shader identifier exceeds 255 characters
メンテナーはふだん 5 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 77/100
調査の方向性
識別子のスキャン付近にある vendor/hlslparser/src/HLSLTokenizer.cpp と、識別子バッファのサイズが分かる vendor/hlslparser/src/HLSLTokenizer.h を読み、ScanLineDirective() の範囲を制限したスキャンと比較してください。報告された AddressSanitizer ハーネスを使い、255 文字を超える識別子で再現してから、修正によって安全に処理され、エラーが報告されることを確認してください。オーバーフローがなくなり、通常の tokenizer の動作が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Please confirm the following points:
- This report is NOT about the Android apps in the Play Store
- I have searched the project page to check if the issue was already reported
Affected Project
libprojectM (including the playlist library)
Affected Version
4.1.8 (Git tag v4.1.8)
Operating Systems and Architectures
All
Build Tools
Build Tool: CMake
Additional Project, OS and Toolset Details
Bug is in vendor/hlslparser/src/HLSLTokenizer.cpp (identifier scan) and is
independent of OS, architecture, compiler and build system. Reproduced with
clang++ -fsanitize=address against the vendored tokenizer compiled in isolation.
Reachable in normal use via MilkdropShader::TranspileHLSLShader() when a preset's
warp/composite shader is parsed.
Type of Defect
Build failure (compiler/linker or toolset error)
Log Output
==12345==ERROR: AddressSanitizer: stack-buffer-overflow
WRITE of size 5000 at 0x... thread T0
#0 memcpy
#1 M4::HLSLTokenizer::Next(bool) HLSLTokenizer.cpp:289
#2 M4::HLSLTokenizer::HLSLTokenizer(...) HLSLTokenizer.cpp:166
#3 main harness.cpp
[128, 696) 'tok' <== Memory access at offset 696 overflows this variable
Describe the Issue
Summary
M4::HLSLTokenizer::Next() copies an identifier token into the fixed 256-byte
member m_identifier using memcpy with a length taken directly from the input,
with no bounds check. A Milkdrop preset whose warp/composite shader contains an
identifier longer than 255 characters triggers an out-of-bounds write.
Location
vendor/hlslparser/src/HLSLTokenizer.cpp, identifier scan:
size_t length = m_buffer - start; // unbounded
memcpy(m_identifier, start, length); // OOB write when length > 255
m_identifier[length] = 0; // OOB terminator too
m_identifier is char[s_maxIdentifier] with s_maxIdentifier = 256
(HLSLTokenizer.h). length is never compared against it. The #line parser
ScanLineDirective() in the same file shows the correct bounded loop that this
path is missing.
Reachability
MilkdropPreset load → MilkdropShader::TranspileHLSLShader()
(src/libprojectM/MilkdropPreset/MilkdropShader.cpp) → HLSLParser::Parse()
→ HLSLTokenizer. The tokenizer starts scanning in its constructor, so the
overflow fires during lexing — no valid-shader semantics required.
Proof of concept
A tokenizer constructed over a buffer containing one 5000-char identifier
(e.g. 5000 'A's) overflows under AddressSanitizer; see log output above.
End-to-end, a .milk preset with a 256+ char identifier token in warp_1/comp_1
reaches the same path.
Impact
Out-of-bounds write of attacker-controlled length and content from an untrusted
preset file. Minimum demonstrated impact is a reliable crash (DoS); code
execution cannot be excluded given the write primitive.
Suggested fix
Clamp the length to the buffer size before copying (patch attached):
size_t length = m_buffer - start;
if (length > s_maxIdentifier - 1) { length = s_maxIdentifier - 1; Error("Identifier too long"); }
memcpy(m_identifier, start, length);
m_identifier[length] = 0;
- 主要言語
- C++
- スター
- 4.6k
- フォーク
- 498
- 平均マージ
- 19日 3時間
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
projectM-visualizer/projectm のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
projectM-visualizer/projectm#1055 ·
メンテナーはふだん 5 日以内に返信
-
[DEV BUG] HLSLParser does not support comma operator in for loop increment statements対応中かも @r3wretrhy が 17 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
projectM-visualizer/projectm#1043 ·
メンテナーはふだん 5 日以内に返信
-
[FEATURE] Cross-repo CI for the Windows Store app: review frontend-uwp#7, add a UWP build here対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
projectM-visualizer/projectm#1058 ·
メンテナーはふだん 5 日以内に返信
-
[FEATURE]オープンenhancement triage
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
projectM-visualizer/projectm#1051 ·
メンテナーはふだん 5 日以内に返信
-
License provenance for the bundled PVRTC decoder対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンquestion
難易度 4/5 3〜5日 初心者へのやさしさ 34/100
projectM-visualizer/projectm#1046 · コメント 2 件 ·
メンテナーはふだん 5 日以内に返信
projectM-visualizer/projectm の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
NKI-AI/fastslide#105 · コメント 2 件 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
DarkCastleMUD/DarkCastle#283 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
-priority- blocked good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
scribe-org/Scribe-Android#761 · コメント 2 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信