gh-aw icon indicating copy to clipboard operation
gh-aw copied to clipboard

Detection job on arc-dind: threat-detect not staged, output path is read-only and unread

Open jonas-harmoney opened this issue 2 months ago • 3 comments

Summary

With runner: topology: arc-dind, the detection job fails and threat detection never runs, while the workflow still concludes success. This is the same class of silent failure as #44249 (fixed by #44445 for the Copilot binary), but one binary later: threat-detect is never staged to a daemon-visible path.

The detection job is pinned to runs-on: ubuntu-latest and is not overridable from the frontmatter, yet it still receives the ARC/DinD codegen. There are three independent defects, listed below with line numbers from the generated lock.

Environment

  • gh-aw v0.88.7
  • AWF v0.28.14
  • threat-detect v0.5.1
  • engine: copilot, CLI pinned to 1.0.79
  • runner: ARC (actions-runner-controller) with containerMode: dind, glibc runner image, Alpine docker:28.2-dind sidecar
  • frontmatter: runs-on: <arc scale set>, runs-on-slim: <arc scale set>, runner: topology: arc-dind

Symptom

The detection job reports two errors:

detection  Process completed with exit code 127
detection  ERR_SYSTEM: Detection result file not found at: /tmp/gh-aw/threat-detection/detection_result.json
detection  Process completed with exit code 1

conclude_threat_detection.sh then reports:

RUN_DETECTION env: "true"
detection execution outcome: "failure"
Listing all files in artifact directory for diagnosis: /tmp/gh-aw/threat-detection
   Found 16 file(s):
     - agent_output.json
     - detection.log
     - sandbox/firewall/...
Detection log stats: 138 lines, 8612 bytes
No lines containing THREAT_DETECTION markers found in 138 lines
Threat Detection Engine Failure - The analysis engine could not complete.

The overall run still concludes success, so nothing surfaces except annotations.

Defect 1: threat-detect is not staged to a daemon-visible path

The detection job installs the binary and then invokes it bare:

# line 1874
- name: Install threat-detect binary
  run: bash "${RUNNER_TEMP}/gh-aw/actions/install_threat_detect_binary.sh" v0.5.1
# line 1949
export PATH="${RUNNER_TEMP}/gh-aw/bin:$PATH" ... && threat-detect --engine copilot --output ...

The Copilot binary has an explicit staging step, added by #44445:

# line 1868
- name: Copy Copilot CLI to daemon-visible path
  run: |
    mkdir -p "${RUNNER_TEMP}/gh-aw/bin"
    COPILOT_SRC="$(command -v copilot)"
    cp "$COPILOT_SRC" "${RUNNER_TEMP}/gh-aw/bin/copilot"

threat-detect has no equivalent. Without arc-dind the chroot is the daemon host filesystem, so /usr/local/bin/threat-detect resolves. With arc-dind the chroot is the staged sysroot, so it does not, which produces the exit 127.

Defect 2: the output path is inside a read-only mount

# line 1947
awf --config ... \
  --mount "${RUNNER_TEMP}/gh-aw:${RUNNER_TEMP}/gh-aw:ro" \
  --mount "${RUNNER_TEMP}/gh-aw/home:${RUNNER_TEMP}/gh-aw/home:rw" \
  --mount "${RUNNER_TEMP}/gh-aw/sandbox/agent:${RUNNER_TEMP}/gh-aw/sandbox/agent:rw" \
  --mount /tmp/gh-aw/threat-detection:/tmp/gh-aw/threat-detection:rw
# line 1949
threat-detect --engine copilot --output ${RUNNER_TEMP}/gh-aw/threat-detection/detection_result.json ${RUNNER_TEMP}/gh-aw/threat-detection

${RUNNER_TEMP}/gh-aw is mounted ro, so even with the binary on PATH the write would fail. /tmp/gh-aw/threat-detection is the mount that is rw.

Defect 3: producer and consumer disagree on the path

The result is written to ${RUNNER_TEMP}/gh-aw/threat-detection/detection_result.json (line 1949) but read from /tmp/gh-aw/threat-detection/detection_result.json:

# line 1975
- name: Upload threat detection artifact
  path: /tmp/gh-aw/threat-detection/detection_result.json

# line 2003
- name: Conclude threat detection
  run: bash ".../conclude_threat_detection.sh" /tmp/gh-aw/threat-detection/detection_result.json

The firewall logs are copied across explicitly, so the collection point is clearly /tmp/gh-aw/threat-detection:

# lines 1966-1968
mkdir -p /tmp/gh-aw/threat-detection/sandbox/firewall
if [ -d ${RUNNER_TEMP}/gh-aw/sandbox/firewall/logs ]; then ... cp -r ...; fi

Only detection_result.json is missing from that copy.

Why the detection job gets ARC/DinD codegen at all

The detection job is emitted with runs-on: ubuntu-latest (not overridable from the frontmatter), yet it also gets:

# line 1832
- name: Redirect tool cache and install paths for ARC/DinD
  run: |
    mkdir -p "${RUNNER_TEMP}/gh-aw/tool-cache"
    echo "RUNNER_TOOL_CACHE=${RUNNER_TEMP}/gh-aw/tool-cache" >> "$GITHUB_ENV"

and "runner":{"topology":"arc-dind"} in its awf-config.json (line 1926). The same step appears at line 438 for the agent job, where it is correct.

So the topology is applied to a job that never runs on ARC. Either the detection job should not receive the ARC/DinD codegen at all, or it should receive it completely, including the binary staging that the agent job gets.

Suggested fix

Whichever direction is preferred:

  1. do not emit the ARC/DinD tool-cache redirection and topology: arc-dind for jobs pinned to ubuntu-latest, or
  2. add a Copy threat-detect to daemon-visible path step mirroring line 1868, and point --output at /tmp/gh-aw/threat-detection/detection_result.json so producer and consumer agree.

Independently of the path work, a detection engine failure currently leaves the workflow green. Given that threat detection is a prompt-injection control, it would help if that surfaced more loudly than an annotation.

Related: #44249, #44445.

jonas-harmoney avatar Sep 10 '26 09:09 jonas-harmoney

two follow ups after another day on this.

workaround that works

setting features: gh-aw-detection: false puts detection back on the inline copilot engine and that one is fine on arc-dind, because the detection job does get the Copy Copilot CLI to daemon-visible path step that threat-detect is missing. confirmed on a full run: real verdict, not a tooling pass.

detection execution outcome: "success" No structured result file found. Falling back to detection log parsing. THREAT_DETECTION_RESULT:{"prompt_injection":false,"secret_leak":false,"malicious_patch":false,"reasons":[]}

so on 0.88.7 the flag is a usable escape until this is fixed.

downgrading is not an escape

worth flagging separately: on v0.85.4 the agent job does not even start on arc-dind, so you cannot pin to a version before the external binary landed. the codegen emits

--mount "${RUNNER_TEMP}/gh-aw:/host${RUNNER_TEMP}/gh-aw:ro"

with no rw counterpart for gh-aw/home under /host, and awf then masks .npmrc with /dev/null. runc cannot create the mountpoint inside a read only mount:

error mounting "/dev/null" to rootfs at "/host/home/runner/_work/_temp/gh-aw/home/.npmrc": create target of file bind-mount: mknod regular file ...: read-only file system

happy to open that as its own issue if you prefer it separate from this one.

jonas-harmoney avatar Sep 11 '26 09:09 jonas-harmoney

🔗 AWF tracking issue: github/gh-aw-firewall#8453

Generated by Firewall Issue Dispatcher · copilot · auto · 18.5 AIC · ⊞ 7.9K · ◷

lpcox avatar Sep 11 '26 12:09 lpcox

Confirmed working on ARC/DinD with v0.89.20, thanks.

Before, on v0.88.7, the conclude step fell back to parsing the log because the binary never reached the chroot:

No structured result file found. Falling back to detection log parsing.

On v0.89.20 the staged detector runs and its result is collected properly:

THREAT_DETECT_INSTALL_OUTCOME: success
🔎 Checking for structured result file: /tmp/gh-aw/threat-detection/detection_result.json
✔️  Structured result file found and parsed successfully.
✔️  Full result file found; recovered 0 reason(s).

We had been running with features: gh-aw-detection: false as a workaround to fall back to the inline engine. That flag is no longer needed and has been removed.

jonas-harmoney avatar Sep 23 '26 11:09 jonas-harmoney