Git worktree directories created with chmod 777 (CWE-732)
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
調査の方向性
st2common/st2common/runners/base.py の385-387行目から始め、git worktree のパスがどのように作成され、chmod に渡されるかを追跡します。shell=True がないことも含め、worktree に対する結果の権限とコマンドの動作を検証します。worktree へのアクセスが必要なユーザーに限定され、他のローカルユーザーにアクションコードが公開されないことを確認できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
When StackStorm creates git worktree directories for pack content versioning, it sets the permissions to 777 (world-readable, world-writable, world-executable). This allows any user on the system to read or tamper with action code before it executes.
Affected File
st2common/st2common/runners/base.py (lines 385-387)
# Make sure system / action runner user can access that directory
args = ["chmod", "777", worktree_path]
cmd = list2cmdline(args)
run_command(cmd=cmd, shell=True)
This also unnecessarily uses shell=True for a simple chmod operation.
Impact
The worktree directory contains the action code that will be executed by the action runner. With 777 permissions:
-
Code tampering: Any local user can modify the action scripts in the worktree between creation and execution, achieving arbitrary code execution in the context of the StackStorm action runner.
-
Information disclosure: Any local user can read the action code, which may contain embedded configuration, API endpoints, or logic that should not be broadly accessible.
-
Race condition: Since the worktree is created and then permissions are set in a separate step, there is a window where the directory exists with its original permissions before being opened up.
Recommended Fix
Use the minimum necessary permissions. The directory only needs to be accessible by the StackStorm system user and the action runner user:
# Use 750 (owner: rwx, group: r-x, other: none) or 770 if group write is needed
args = ["chmod", "750", worktree_path]
Or better, set ownership and permissions atomically:
import os
import stat
os.chmod(worktree_path, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP) # 750
This also eliminates the need for shell=True and the subprocess call entirely.
References
- CWE-732: Incorrect Permission Assignment for Critical Resource
- Discovered via manual code review
- 主要言語
- Python
- スター
- 6.5k
- フォーク
- 792
- 平均マージ
- 1日 3時間
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
StackStorm/st2 のほかの issue
-
yaml.FullLoader used instead of SafeLoader in pack metadata parsing (CWE-502)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
StackStorm/st2#6393 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
StackStorm/st2#6389 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
StackStorm/st2#6387 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
StackStorm/st2#6391 ·
-
CORS middleware reflects Origin with Allow-Credentials, enabling cross-origin attacks (CWE-346)対応中かも @R-zin が 8 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
StackStorm/st2#6390 ·
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
spec-kitty/spec-kitty#6112 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: OpenRouter streaming chunks report the requested router name instead of the model OpenRouter served対応中かも @Mrun25 が今日担当しました。 オープンbug llm translation
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
BerriAI/litellm#46095 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
uberdeveloper/fastbt#29 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
andrew-blake/melcloudhome#368 ·
メンテナーはふだん 1 日以内に返信
-
lane:discover
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
SPARDiffData/differential-data-collection#33 ·
メンテナーはふだん 1 日以内に返信