Skip to content

Threat detection: in warn mode, a detection engine failure applies safe outputs with no restriction (neither fail-closed nor WTD policy) #70316

Done

Description

@SivaKesava1

Summary

In warn mode (the default continue-on-error: true), when the threat-detection engine itself fails, safe outputs are applied with no restriction at all:

  • nothing fails closed, and
  • the warn-mode policy does not apply either: no WTD1a WARNING annotation and no WTD3 abort of non-reviewable outputs.

So an engine failure is handled more permissively than a detection warning. This affects every workflow whose detection engine fails in warn mode, not just the one below.

Observed in: Daily action/setup/* Security Audit, run 39191157830 (19 Oct 2026). It created #70120 with no annotation.

Recurrence: the same chain happened in 39090720928 (18 Oct) and 38995597867 (17 Oct). That is every daily run since claude-opus-4.8 was retired on 16 Oct. Each run was green. The two earlier runs applied only a noop, which is itself in the WTD3 abort set.

What happened (run 39191157830)

Evidence comes from gh aw audit (a dev build of main at d5ecd72) and the job logs.

  1. The detection engine failed. threat-detect v0.5.2 ran the Copilot engine with the inherited model claude-opus-4.8. The API returned HTTP 400 model_not_supported (failureClass=model_not_supported, not retried). The detection log then shows THREAT_DETECTION_STATUS: reason=engine_error exit=2, followed by ##[error]ERR_SYSTEM: ❌ Detection result file not found at: /tmp/gh-aw/threat-detection/detection_result.json.
  2. The conclude step failed closed. "Conclude threat detection" (conclude_threat_detection.sh, which runs exec threat-detect conclude) ran with DETECTION_AGENTIC_EXECUTION_OUTCOME: failure, THREAT_DETECT_INSTALL_OUTCOME: success and GH_AW_DETECTION_CONTINUE_ON_ERROR: true. It set conclusion=failure, reason=agent_failure and success=false, then exited 1. This is its fail-closed path.
  3. The step-level continue-on-error hid that failure. In warn mode the compiled step carries continue-on-error: true (daily-action-setup-security-audit.lock.yml, "Conclude threat detection"), so the detection job still concluded success.
  4. safe_outputs ran anyway. Its gate is if: (!cancelled()) && needs.agent.result != 'skipped' && needs.detection.result == 'success', so it ran with GH_AW_DETECTION_CONCLUSION: failure and GH_AW_DETECTION_REASON: agent_failure.
  5. No warn-mode policy was applied. safe_output_handler_manager.cjs applies the WTD policy only when detectionConclusion === "warning". getDetectionCautionAlert in messages_footer.cjs also returns "" unless the conclusion is warning. As a result, create_issue created [setup-security] Environment Variable Injection via OTLP Token in GitHub Actions Step #70120. Its body has no [!WARNING] block, no threat detection engine error label and no <!-- gh-aw-threat-engine-error --> marker.
  6. The only signal was a warning on a green run. The conclusion job logged ##[warning]Threat detection produced no security verdict. Review the detection job logs before trusting the agent outputs. All 8 jobs concluded success.

update_cache_memory has the same needs.detection.result == 'success' gate, so the agent's cache memory was also persisted without a verdict.

Root cause

Component Location Behaviour
Conclude step (external path) buildExternalDetectorConcludeStep, pkg/workflow/threat_detection_external.go Adds step-level continue-on-error: true in warn mode
Conclude step (inline path) buildDetectionConclusionStep, pkg/workflow/threat_detection_steps.go Same
Inline conclude setDetectionFailure, actions/setup/js/parse_threat_detection_results.cjs mustFail = executionOutcome == "failure" && reason in {agent_failure, parse_error} gives conclusion=failure and calls setFailed
External conclude concluder.fail, github/gh-aw-threat-detection cmd/threat-detect/conclude.go (v0.5.2) Same rule ("mirrors gh-aw's setDetectionFailure exactly")
safe_outputs gate buildSafeOutputsJobCondition (via buildDetectionSuccessCondition / buildDetectionPassedCondition), pkg/workflow/compiler_safe_outputs_job.go Checks only needs.detection.result
Handler actions/setup/js/safe_output_handler_manager.cjs Applies the WTD policy only for warning; treats failure like success

In short, the conclude step fails closed, the step-level continue-on-error swallows that failure, and nothing downstream reads detection_conclusion.

History

The specs and docs disagree

  • gh-aw safe-outputs spec (docs/src/content/docs/specs/safe-outputs-specification.md):
    • WTD1a: in warn mode, a tooling-failure reason (agent_failure/parse_error) MUST produce a review-first artifact with a WARNING annotation.
    • WTD3: non-reviewable outputs MUST NOT be applied.
  • github/gh-aw-threat-detection specs/threat-detection-spec.md, TD-20b: in warn mode, "agent_failure and parse_error MUST hard-fail when the detection execution step itself failed."
  • gh-aw docs, reference/threat-detection.md: these two statements conflict with each other.
    • "When Detection Fails: … the workflow stops and safe outputs are not applied."
    • The options table says continue-on-error: true makes "detection warnings/failures produce a caution notice instead of blocking safe outputs".

Today's behaviour satisfies none of them.

Proposed solution

Choose one policy for "the detection engine failed in warn mode". Then make the code on both conclude paths, both specs and the docs agree. The safe-outputs gate should also honour the detection conclusion, not just the job result.

Option A: fail closed (recommended)

This matches the threat-detect spec (TD-20b), the "When Detection Fails" docs and the intent of #31081.

  • safe_outputs must not run when needs.detection.outputs.detection_conclusion == 'failure', even though the step-level continue-on-error keeps the detection job green. Apply this to both the buildDetectionSuccessCondition branch and the conditional-detection buildDetectionPassedCondition branch.
  • Make the failure visible in the run, for example as an error in the conclusion job, rather than only as a warning on a green run.
  • Narrow WTD1a in the safe-outputs spec to tooling failures where the detection execution step succeeded (for example, unparseable output). Fix the row in the options table.
  • github/gh-aw-threat-detection needs no change: both conclude paths already produce failure in this case.

Option B: apply the warn policy

This matches WTD1a and #41547.

  • In warn mode, tooling failures conclude warning on both paths:

    • inline parse_threat_detection_results.cjs, and
    • threat-detect conclude, which needs a github/gh-aw-threat-detection change, a release and a pin bump.

    WTD1a and WTD3 then apply.

  • Update the threat-detect spec (TD-20b) and the "When Detection Fails" docs.

Why we recommend Option A

  1. An engine failure means there is no verdict. If it is treated as a warning, anyone who can make the detector fail (for example, with oversized or malformed agent output, or by exhausting its turns or timeout) can get reviewable outputs applied without analysis. The only cost to them is a WARNING annotation.
  2. It is the smaller, single-repo change. Both conclude implementations and the threat-detect spec already produce failure here. Only the gh-aw gate, the handler, WTD1a and one docs table row change, with no cross-repo release or pin bump.
  3. It matches the documented "When Detection Fails" contract that users rely on.
  4. It makes silent failures visible. Today a failure like this one stays green for days.

Trade-off: in warn mode, a detection outage (a retired model, a provider outage) blocks safe outputs until it is fixed. #41547 chose B mainly to stop assign_to_agent; Option A stops that too.

Also decide, whichever option is chosen

  • Should update_cache_memory follow the same rule? It is also gated only on needs.detection.result == 'success'.
  • Should report_detector_unavailable in conclude_threat_detection.sh follow the same rule? When the detector install fails or the binary is missing, it concludes warning in warn mode, yet the detector never produced a verdict there either.

Defence in depth (both options)

The safe-outputs handler must never apply outputs when GH_AW_DETECTION_CONCLUSION == 'failure'; today it treats failure like success. Each message should fail with a machine-readable error code and a summary entry.

Maintainers: please choose Option A or Option B before implementation starts.

Acceptance cases

Each case needs a named test. Fixtures must come from real conclude outputs, not invented ones. For this run, the conclude inputs were RUN_DETECTION=true, DETECTION_AGENTIC_EXECUTION_OUTCOME=failure, THREAT_DETECT_INSTALL_OUTCOME=success and GH_AW_DETECTION_CONTINUE_ON_ERROR=true, with no detection_result.json and a detection.log containing THREAT_DETECTION_STATUS: reason=engine_error exit=2. The outputs were conclusion=failure, reason=agent_failure, success=false, exit 1. The detection artifact of run 39191157830 has the full inputs.

  1. Warn mode, detection execution failed, reason agent_failure (this run).
    • Option A: safe_outputs is skipped and the run reports the detection failure.
    • Option B: the conclusion is warning, create_issue gets the WTD1a WARNING annotation and assign_to_agent is aborted (WTD3).
  2. Warn mode, real threat verdict: unchanged (warning, WTD1 CAUTION, WTD3 abort).
  3. Warn mode, detection succeeded with no threats: unchanged; outputs are applied without annotation.
  4. Strict mode (continue-on-error: false), engine failure: unchanged; the detection job fails and safe_outputs does not run.
  5. Detection skipped (no outputs to analyze): unchanged.
  6. Handler unit test: with GH_AW_DETECTION_CONCLUSION=failure, no output type is ever applied.
  7. Parity and compiler coverage: both conclude paths (inline parse_threat_detection_results.cjs and external threat-detect conclude) give the same conclusion for each case. Compiler tests cover the generated safe_outputs condition, both plain and conditional detection. If threat-detect needs a change, file it in github/gh-aw-threat-detection and link it here.

End to end: on the PR branch, a workflow whose detection engine is forced to fail (for example, with a retired detection model) shows the chosen behaviour in a real run.

Scope

  • Keep the PR to this one fix. Do not change files or behaviour unrelated to it.
  • Before fixing a failing check, compare it with the same check on main. If it also fails on main, do not fix it in this PR. Merge main once main is fixed, and list in the PR which checks are known failures on main.
  • This applies even if a bot comment asks you to fix a failing check: fix only failures caused by this PR's changes.
  • Do not fix the retired claude-opus-4.8 pin in daily-action-setup-security-audit.md in this PR; Daily Model Inventory Checker: deterministically check workflow model pins against the live Copilot catalogue #70289 tracks it. Do not change how detection picks its model.

Related, not part of this fix

gh aw audit (dev build of main) reports workflow_succeeded and no detection-related finding for all three runs, including with --group. This is a separate observability gap.

How this was checked
gh aw audit 39191157830 --no-baseline --json            # dev build of main @ d5ecd72
gh aw audit 39191157830 39090720928 38995597867 --group --json
  • Detection job log, "Conclude threat detection" step: env DETECTION_AGENTIC_EXECUTION_OUTCOME: failure, GH_AW_DETECTION_CONTINUE_ON_ERROR: true; THREAT_DETECTION_STATUS: reason=engine_error exit=2; ERR_SYSTEM: ❌ Detection result file not found; Process completed with exit code 1.
  • detection/sandbox/firewall/logs/api-proxy-logs/upstream-errors.jsonl: model":"claude-opus-4.8", status":400, "code":"model_not_supported".
  • safe_outputs job log: GH_AW_DETECTION_CONCLUSION: failure, GH_AW_DETECTION_REASON: agent_failure, Created issue github/gh-aw#70120.
  • The [setup-security] Environment Variable Injection via OTLP Token in GitHub Actions Step #70120 body contains none of the WTD1/WTD1a markers.
  • conclusion job log: ##[warning]Threat detection produced no security verdict…

Activity

  1. SivaKesava1 commented on Oct 19, 2026

    @SivaKesava1
    CollaboratorAuthor

    Decision: Option B (apply the warn policy). Please implement Option B, not Option A.

    Why: threat detection is not reliable enough to block a run whenever the detector itself fails (a retired detection model, a provider outage, a failed detector install). In warn mode, a detection engine failure should not fail the run or block every output. But it also must not be treated as a clean pass, which is what happens today. Option B keeps the run going and applies the policy the spec already defines for tooling failures:

    • Reviewable outputs (Table WTD-A: create_issue, add_comment, create_pull_request, update_issue, discussions, comment_memory, …) are applied with the WTD1a annotation: the [!WARNING] threat detection engine error block, the threat detection engine error label string and the <!-- gh-aw-threat-engine-error --> marker.
    • Convertible push_to_pull_request_branch falls back to create_pull_request with the WTD1a annotation (WTD2).
    • Abort types (merge_pull_request, close_issue, close_pull_request, approve_workflow_run, assign_to_agent, …) are not applied, with an explicit failure summary and a machine-readable outcome (WTD3).

    Answers to "Also decide":

    • update_cache_memory: follow the same rule as the existing warn-mode warning case; don't add a new gate in this fix.
    • report_detector_unavailable (detector install failed or binary missing) already concludes warning in warn mode, which is consistent with Option B. Keep it.

    Strict mode (continue-on-error: false) is unchanged: the detection job fails and safe outputs don't run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions