Threat Detection | GitHub Agentic Workflows
Skip to main content Threat Detection GitHub Agentic Workflows includes automatic threat detection to analyze agent output and code changes for potential security issues before they are applied. When safe outputs are configured, a threat detection job automatically runs to identify prompt injection attempts, secret leaks, and malicious code patches. How It Works Section titled “How It Works” Threat detection provides an additional security layer by analyzing agent output for malicious content, scanning code changes for suspicious patterns, using workflow context to distinguish legitimate actions from threats, and running automatically after the main job completes but before safe outputs are applied.
Detection sanitizes its files after firewall-log collection and custom post-steps, before accounting reads or renders them. A second redaction pass covers newly generated usage files before log rendering, result publication, and artifact upload. These consumers require successful detection-job redaction; a failed or skipped redaction blocks publication for an active detection run even when detection uses continue-on-error .
When no detection is needed, the redaction passes are skipped and the job still reports a successful skipped conclusion without reading detection output files. Exact-value secret inputs are limited to the detection job’s own steps and inherited environment, not unrelated workflow credentials. GitHub Actions console masking does not sanitize downloadable artifact contents. Copied firewall files must be valid UTF-8 text no larger than 16 MiB; unsupported byproducts are removed before upload, and removal failures block publication.
Security Architecture: ┌─────────────────┐ │ Agentic Job │ (Read-only permissions) │ Generates │ │ Output & Patches│ └────────┬────────┘ │ artifacts ▼ ┌─────────────────┐ │ Threat Detection│ (Analyzes for security issues) │ Job │ └────────┬────────┘ │ configured output policy ▼ ┌─────────────────┐ │ Safe Output Jobs│ (Scoped writes; warn/strict policy) │ Create Issues, │ │ PRs, Comments │ └─────────────────┘ Default Configuration Section titled “Default Configuration” Threat detection is automatically enabled when safe outputs are configured: safe-outputs : create-issue : # Threat detection enabled automatically create-pull-request : The default configuration uses AI-powered analysis to detect prompt injection (malicious instructions manipulating AI behavior), secret leaks (exposed API keys, tokens, passwords, credentials), and malicious patches (code changes introducing vulnerabilities, backdoors, or suspicious patterns).
Configuration Options Section titled “Configuration Options” Basic Enabled/Disabled Section titled “Basic Enabled/Disabled” Control threat detection with a boolean flag: safe-outputs : create-issue : threat-detection : true # Explicitly enable (default when safe-outputs exist) # Or disable entirely: safe-outputs : create-pull-request : threat-detection : false # Disable threat detection entirely The features.gh-aw-detection flag controls the detection implementation, not whether threat detection runs.
The external threat-detect implementation is the default; set features.gh-aw-detection: false to select the legacy inline engine implementation. Compiled workflows embed the reviewed detector release tag and per-architecture SHA-256 digests. Installation verifies the downloaded binary against those compiler-controlled pins instead of a runtime checksum file. If installation does not complete verification, the detection job neither runs nor concludes with a detector binary: analysis is skipped and the conclusion is reported as an agent_failure (a warning in warn mode, a hard failure in strict mode).
Advanced Configuration Section titled “Advanced Configuration” Use object syntax for fine-grained control: safe-outputs : create-issue : threat-detection : enabled : true # Enable/disable detection prompt : " Focus on SQL injection " # Additional analysis instructions steps : # Custom steps run before engine execution - name : Setup Security Gateway run : echo "Connecting to security gateway..." post-steps : # Custom steps run after engine execution - name : Custom Security Check run : echo "Running additional checks" Configuration Fields: Field Type Description enabled boolean Enable or disable detection (default: true when safe-outputs exist) prompt string Custom instructions appended to default detection prompt engine string/object/false AI engine config ( "copilot" , full config object, or false for no AI) ca-cert string/false Absolute host path to a CA certificate for the detection API proxy.
Inherits sandbox.agent.ca-cert when unset or empty and the detection engine matches the agent engine; set to false to disable inheritance. Requires AWF v0.28.10 or later. runs-on string/array/object Runner for the detection job (default: inherits from workflow runs-on ) artifact-base-url string HTTPS base URL for a mirror of the pinned detector release assets. The compiler appends the pinned release tag and asset name; the embedded digest cannot be overridden. steps array Additional GitHub Actions steps to run before AI analysis (pre-steps) post-steps array Additional GitHub Actions steps to run after AI analysis (post-steps) max-ai-credits integer AI Credits cap for the detection run, independent of the main agent budget.
Defaults to 400 when unset, with runtime override via vars.GH_AW_DEFAULT_DETECTION_MAX_AI_CREDITS . Accepts plain integers; -1 disables the detection budget. continue-on-error boolean When true (default), detected threats and detection engine failures apply the warn-mode policy (annotate reviewable outputs, convert branch pushes, abort non-reviewable outputs) instead of blocking all safe outputs. When false , they fail the detection job and safe outputs are not applied. report-as-issue boolean When true (default), detection warnings/failures create or update the [aw] Detection Runs tracking issue.
Set to false to keep threat detection and its enforcement enabled while skipping the tracking issue; results remain visible in the GitHub Actions run logs. Issue reporting permissions Section titled “Issue reporting permissions” When detection is runnable and report-as-issue is enabled (the default), the conclusion job and its GitHub App token request issues: write . Reusable workflow callers must grant this permission throughout the caller chain.
When safe-outputs.github-app is configured, the App must have Issues: write access; otherwise, token creation can fail. Reusable callers without the required scope can fail workflow validation before any job runs. The existing opt-out disables the tracking issue and its detection-specific permission grant without disabling threat detection or enforcement: safe-outputs: threat-detection: report-as-issue: false Other enabled issue-writing outputs or conclusion reporters can still require issues: write .
Private CA certificates Section titled “Private CA certificates” The detection job inherits sandbox.agent.ca-cert for upstream API proxy TLS verification only when the detection and agent engines match. A non-empty safe-outputs.threat-detection.ca-cert overrides the inherited path; set it to false to opt out, or leave it unset/empty to use the matching-engine inheritance behavior. Detection runs on a fresh runner, so the certificate file must also exist there before engine execution.
Use detection pre-steps to write it: safe-outputs : create-issue : threat-detection : ca-cert : /tmp/detection-ca.pem steps : - name : Write CA certificate env : CA_PEM : ${{ secrets.INTERNAL_CA_PEM }} run : printf '%s\n' "$CA_PEM" > /tmp/detection-ca.pem AWF versions before v0.28.1
The rest of this page is on the live site.