Rootless threat detection deletes its installed binary before execution
Summary
With gh-aw v1.2.2, external threat detection on a non-ARC/DinD Linux runner fails when runner.installation: rootless is enabled. The installer succeeds, but the generated detection step deletes the installed detector before trying to copy it. The same staging logic is present on current main.
Reproduction
- Compile an agentic workflow with
runner.installation: rootlessand external threat detection, targeting a non-ARC/DinD Linux runner. - Start a run that produces a safe output so the detection job runs.
- The rootless installer places the verified executable at
$RUNNER_TEMP/gh-aw/bin/threat-detect. The next generated step removes that path and tries to copy the same source file into it, so detection fails before AWF starts.
Expected: the verified detector remains executable and threat detection runs. The job can appear successful because detection continues on error, despite detection not being performed; in the observed run, safe-output handling aborted the output.
Root cause
prepare_rootless_install_dirselects$RUNNER_TEMP/gh-aw/bin, and the installer publishes the verified path.threatDetectBinaryPathSetupunconditionally removes that same destination before copying the verified source. This setup is emitted for rootless, non-ARC/DinD runners.
Related prior work: #75440.
Suggested implementation and tests
- In
buildExternalDetectorPathSetup, avoid removing or copying the detector when the verified source is already the destination; retain the existing checks for an executable regular file and symlinks. - Add a regression test that executes the generated host setup when source and destination are the same, and a test for a distinct source and destination. Preserve checksum verification and the existing ARC/DinD and privileged paths.
- Verify that a rootless non-ARC detection job reaches the detector and produces a detection result without changing safe-output policy.
Same failure on a plain self-hosted Linux runner (not ARC/DinD), gh-aw v1.2.2, with runner.installation: rootless.
"Install threat-detect binary" succeeds and prints threat-detect v0.5.3. The verified binary is installed at $RUNNER_TEMP/gh-aw/bin/threat-detect. The next generated step, "Execute threat detection with AWF", removes that path and then copies $detector onto the same path, so the copy fails:
cp: cannot stat '.../gh-aw/bin/threat-detect': No such file or directory
AWF never starts. "Conclude threat detection" then runs the fail-closed placeholder and exits 1:
ERROR: threat-detect installation did not complete verification
ERR_SYSTEM: threat-detect conclude exited with status 1 without reporting a conclusion
With continue-on-error: false, the detection job fails and safe outputs are skipped. The agent job in the same run succeeded.