Threat detection never runs on arc-dind: stage step deletes the rootless-installed detector before copying it

オープン 初心者向け
#79,301 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
bash, github-actions
領域
devops, security

調査の方向性

stage_threat_detection_arc_dind.shから始め、THREAT_DETECT_BINARYと${BIN_DIR}/threat-detectの両方のパスが同じファイルを指す場合の処理を追ってください。報告されたrootlessインストールのシナリオを再現し、その後、ステージングスクリプトに関連するテストや呼び出し元を確認してください。ステージングが成功し、コピー元とコピー先が同一でも、後続の実行ステップでdetectorを引き続き利用できれば完了です。

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

説明

ai-inspected backlog:security
Summary

On self-hosted ARC runners with runner.topology: arc-dind, threat detection never runs: the stage step deletes the detector binary it is about to copy. Because detection defaults to warn mode, the job still ends green and the safe outputs only get a "Threat detection engine error" banner, so the failure is easy to miss.

Version

gh-aw v1.3.1 (github/gh-aw-actions/setup@dfe97a19c8249d41e2adfc95f92db2b8facea58f), threat-detect v0.5.3, AWF 0.29.14.

What happens
  1. install_threat_detect_binary.sh ... --rootless (no sudo on the runner) installs to prepare_rootless_install_dir, i.e. $RUNNER_TEMP/gh-aw/bin/threat-detect, and outputs that path as binary-path, which the execute step receives as THREAT_DETECT_BINARY.
  2. In the execute step, stage_threat_detection_arc_dind.sh stage does:
    detector="${THREAT_DETECT_BINARY:?...}"          # = $RUNNER_TEMP/gh-aw/bin/threat-detect
    BIN_DIR="${RUNNER_TEMP}/gh-aw/bin"
    ...
    rm -f "${BIN_DIR}/threat-detect"                  # deletes the detector itself
    cp "$detector" "${BIN_DIR}/threat-detect"         # cp: cannot stat ...: No such file or directory
    
  3. The step exits 1; conclude_threat_detection.sh logs threat-detect binary not found on PATH; continuing because GH_AW_DETECTION_CONTINUE_ON_ERROR != false, and safe outputs proceed without any analysis.

Reproduced outside Actions with the pinned script (sha256 a4064e12ac694a605d8a85eff737a2cf533548ea0fab88b49b3f3ab54c6c9301): create $RUNNER_TEMP/gh-aw/bin/threat-detect, set THREAT_DETECT_BINARY to that path and run stage → cp: cannot stat.

Suggested fix

Skip the copy when source and destination are the same file, e.g.

if [ ! "$detector" -ef "${BIN_DIR}/threat-detect" ]; then
  rm -f "${BIN_DIR}/threat-detect"
  cp "$detector" "${BIN_DIR}/threat-detect"
fi
chmod +x "${BIN_DIR}/threat-detect"

(or install the rootless detector to a directory other than BIN_DIR). With that change applied via a threat-detection.steps pre-step, detection runs and returns a structured verdict on the same runners.

It may also be worth surfacing an engine error more loudly than a warning banner when detection is enabled, since a silently skipped detection looks identical to a green one in the run list.

主要言語
Go
スター
5.7k
フォーク
635
平均マージ
3時間 43分
マージ済み PR(30日)
838

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

github/gh-aw のほかの issue

github/gh-aw の issue をすべて見る

似ている issue

Go の issue をもっと見る

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

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