pyk: arbitrary Python module import from untrusted `kbuild.toml`

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
15/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
活発
技術スタック
python

調査の方向性

Start at Source.from_dict in pyk/src/pyk/kbuild/project.py (around line 27), which builds PackageSource from the [dependencies] table, then read PackageSource.resolve (around line 49), which calls importlib.resources.files on the package name. Done means the untrusted package string is validated or restricted to installed or locked distributions, with tests covering a malicious kbuild.toml. The suggested fix also touches the _NODES/_PROOF_TYPES allow-lists, which needs maintainer input.

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

説明

Summary

PackageSource.resolve imports a Python package named by an untrusted kbuild.toml (kbuild.toml is data fetched/build-time config from the project being processed), giving arbitrary code execution in the pyk process when resolving that package.

1 finding(s) (1 LOW) — line-anchor verified at commit 4a46d1231473.

Findings
Severity ID Location Summary
LOW pyk-tools-004 pyk/src/pyk/kbuild/project.py:49 PackageSource.resolve imports an arbitrary Python module from untrusted kbuild.toml
Details
pyk-tools-004 — `PackageSource.resolve` imports an arbitrary Python module from untrusted `kbuild.toml` (pyk/src/pyk/kbuild/project.py:49)

Trigger (as reviewed): Source.from_dict (pyk/src/pyk/kbuild/project.py:27) builds PackageSource(dct['package']) from the [dependencies] table of a kbuild.toml with no allow-list or format validation. importlib.resources.files(name) imports the named module (and can import submodules) to locate it, executing its top-level code.

Impact (as reviewed): Cloning an untrusted K project and running kbuild kompile / kbuild which (or any pyk caller of Project.load) triggers import of an attacker-chosen module name, giving arbitrary code execution under the caller's privileges via import side effects. The dependency 'package' is treated as a plain string but is actually an import directive.

Deep review: reachability=REACHABLE-FROM-UNTRUSTED; exploitability=EXPLOITABLE; red-team=VERIFIABLE-UNKNOWN.

Suggested fix

Enforce the declared _NODES/_PROOF_TYPES allow-lists before globals()/locals() dispatch, restrict PackageSource.resolve to installed/locked distributions, and shlex-quote generated bug-report scripts.


From a static audit of this repository at commit 4a46d1231473b599c699160132fd6e76a5c46406 (master). Every location above was verified against the source at that revision; no exploit code was run against this repository or its infrastructure.

主要言語
Python
スター
605
フォーク
165
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

runtimeverification/k のほかの issue

runtimeverification/k の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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