validate() allocates program-declared sizes and loop ranges in check-only mode (resource exhaustion from a small QASM file)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 43/100
調査の方向性
Read src/pyqasm/modules/base.py around QasmModule.validate() and the cited allocation and loop paths in src/pyqasm/visitor.py; inspect src/pyqasm/maps/expressions.py for the array dimension limit. Start by tracing how check-only validation handles declared registers, arrays, and loops, then add bounds or check-only exits with tests for small programs that trigger large allocations or long loops. Done means validation rejects or safely handles these cases without exhausting resources.
索引モデルが issue の本文から書いたものです。
説明
Note: your SECURITY.md asks for reports through the private advisory form, but private vulnerability reporting is turned off for this repository, so the form isn't available. That is the only reason we're reporting this publicly. We also emailed [email protected] today asking for a private channel.
Our code review of qBraid/pyqasm at 95747c7bea4b73f6065249e708071fc5b3bdc461 (current main; pyproject version 1.4.0, three commits after the v1.4.0 tag) found that QasmModule.validate() still materialises program-declared sizes and loop ranges in check-only mode, so a short OpenQASM program can force a large allocation or a long loop.
validate() (src/pyqasm/modules/base.py:709–727) builds a QasmVisitor with check_only=True (line 715) and walks the program. A classical bit register is initialised with np.full of the declared length (src/pyqasm/visitor.py:2067–2069) and then one dict entry and one ClbitDepthNode per bit (lines 2212–2214) before the check-only return at line 2236. An array is similarly allocated with np.full (line 2097) after only the number of dimensions is capped (MAX_ARRAY_DIMENSIONS = 7 in src/pyqasm/maps/expressions.py:185), not the product of their sizes. A qubit register adds one label and one QubitDepthNode per qubit (visitor.py:309–312) with no size cap; validate()'s later device_qubits check (base.py:718) applies only if the caller set that option, which defaults to None (base.py:206). A for-loop range is turned into a list (visitor.py:2586) before the existing iteration-limit check (line 2601, default 1e9). A while loop has no check-only exit (unlike the for loop at line 2646) and runs until that same counter (lines 2841–2904, counter at 2895); a continue in the body jumps back without incrementing the counter (lines 2881–2887). The bundled CLI pyqasm validate <file> calls load() then validate() (src/pyqasm/cli/validate.py:74–75). This is a source review only, nothing was run or compiled.
This is an availability issue only: a caller that validates QASM it did not write (a service, a CI job, or the CLI) can be stalled or run out of memory by a small file. We have not claimed a particular hosted service. A suggested untested fix (caps on register and array sizes before allocation, a lazy for-loop range, and a check-only exit for while, plus tests) is available on request. The numeric caps in that patch are a policy choice for you to set.
Credit: Ugur Celik (ucsurf), @ucsurf
— ucsurf / https://uc.surf
If you'd like to support our work, even a coffee helps: https://buymeacoffee.com/ucsurf
- 主要言語
- Python
- スター
- 29
- フォーク
- 33
- 平均マージ
- 1日 20時間
- マージ済み PR(30日)
- 8
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
qBraid/pyqasm のほかの issue
-
dumps() prints the original program when unroll() leaves at most one statement対応中かも @ShiveshDragon が 9 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
qBraid/pyqasm#493 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
メンテナーはふだん 1 日以内に返信
-
enhancement error-handling program-validation
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
dependencies enhancement
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
Integer division for casts, int array elements, bitwise results, ** and int-returning subroutinesオープン
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
qBraid/pyqasm#480 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
available documentation good first issue
難易度 1/5 1〜3時間 初心者へのやさしさ 95/100
Nixitov/Riptide-Native#944 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
JTHCode/secretguard#24 ·
メンテナーはふだん 1 日以内に返信
-
area: middleware documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
omarelshamy25x/shamy-hijri#63 ·
メンテナーはふだん 1 日以内に返信