Repository navigation
Add safe-output-credentials lint rule - #79268
Conversation
Flag authored safe-outputs.steps that use compiler-minted App tokens, write GITHUB_ENV/GITHUB_PATH, check out with persisted credentials, or modify agent output/patch files under /tmp/gh-aw. Error in strict mode, warning otherwise. Co-authored-by: Copilot App <[email protected]>
Add per-finding threat IDs via Rule.FindingThreatRuleIDs (registry-owned), update the compiler threat spec to 1.0.104 with catalog rules, implementation and lint mappings, conformance tests T-CTR-050–T-CTR-053, compliance map, changelog, and docs. Co-authored-by: Copilot App <[email protected]>
|
🧠 Matt Pocock Skills Reviewer is reviewing this pull request using Matt Pocock's engineering skills... |
|
🚀 PR Specification Reviewer has started processing this pull request |
|
🔎 PR Code Quality Reviewer is reviewing code quality for this pull request... |
|
🔍 Design Decision Gate 🏗️ is checking for design decision records on this pull request... |
|
✅ Ponytail Reviewer completed successfully! Warning Threat detection engine error Threat detection could not complete its analysis due to a tooling error. This is not a security finding. What happenedThe threat detection engine failed to produce results. Review the workflow run logs to troubleshoot the error. Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Test Quality Sentinel completed test quality analysis. Warning Threat detection engine error Threat detection could not complete its analysis due to a tooling error. This is not a security finding. What happenedThe threat detection engine failed to produce results. Review the workflow run logs to troubleshoot the error. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved lint-rule defects reject valid strict workflows and miss unsafe operations, with additional undocumented compilation failures and shared-slice isolation issues.
9 open issues
Deep-copy threat ID slices when registering and returning rules · New Keep the new rule from changing compile behavior · New Match protected directories without matching similarly named paths · New Capture complete token step IDs, including suffixes · New Exclude step status checks from token reuse matches · New Detect environment-file writes across shell and Actions syntax · New Include safe-output pre-steps and setup-steps in declared IDs · New Use shared action and boolean parsing for CTR-037 · New Parse command write operands when matching protected files · New
What changed in this PR
Adds safe-output-credentials to gh-aw’s default workflow linter to catch accidental misuse of write credentials by authored safe-output steps.
Changes:
- Checks token reuse, environment mutation, credential-persisting checkouts, and handler-input writes.
- Adds per-finding threat IDs and exposes them in CLI rule listings.
- Extends policy tests, reference documentation, and the threat specification.
| File | Description |
|---|---|
specs/compiler-threat-detection-spec.md |
Defines CTR-035–038 and per-finding threat mappings. |
specs/compiler-threat-detection-compliance/README.md |
Maps the new threats to conformance tests. |
specs/compiler-threat-detection-changelog.md |
Records specification version 1.0.104. |
pkg/workflow/lint/threat_policy_test.go |
Adds malformed-input and value-free diagnostic cases. |
pkg/workflow/lint/spec_test.go |
Includes the new public rule constructor. |
pkg/workflow/lint/safe_output_credentials.go |
Implements the four credential-related checks. |
pkg/workflow/lint/safe_output_credentials_test.go |
Exercises detection, exemptions, and severity. |
pkg/workflow/lint/rule_contract_test.go |
Adds rule-contract and per-finding threat assertions. |
pkg/workflow/lint/README.md |
Lists the new rule constructor. |
pkg/workflow/lint/lint.go |
Registers the rule and supports per-finding threat IDs. |
pkg/workflow/lint/lint_test.go |
Updates the expected default rule list. |
pkg/cli/lint_workflow_test.go |
Adds CLI coverage for the rule. |
pkg/cli/lint_command.go |
Displays multiple threat IDs in rule listings. |
docs/src/content/docs/reference/workflow-linters.md |
Documents the rule and strict-mode severity. |
docs/src/content/docs/reference/safe-outputs.md |
Describes credential-misuse checks for custom steps. |
Review effort: Max (adaptive)
| if rule.ThreatRuleID != "" && !threatRuleIDPattern.MatchString(rule.ThreatRuleID) { | ||
| return nil, fmt.Errorf("lint rule %q requires a compiler threat ID in CTR-NNN form", rule.ID) | ||
| } | ||
| for _, id := range rule.FindingThreatRuleIDs { |
There was a problem hiding this comment.
Fixed in 237f6c0: registration and retrieval clone the nested threat ID slices.
| PullRequestTargetRolesRule(), | ||
| UntrustedRolesDetectionRule(), | ||
| SafeOutputShellExpansionRule(), | ||
| SafeOutputCredentialsRule(), |
There was a problem hiding this comment.
Fixed in 237f6c0: compilation excludes this rule, with a regression test.
| } | ||
| } | ||
|
|
||
| const safeOutputInputPath = `["']?(?:\$\{?GH_AW_AGENT_OUTPUT\}?|\$\{?GH_AW_SAFE_OUTPUTS\}?|/tmp/gh-aw/|\$\{?RUNNER_TEMP\}?/gh-aw/|\$\{\{\s*runner\.temp\s*\}\}/gh-aw/)` |
There was a problem hiding this comment.
Fixed in 237f6c0: directory roots and descendants are matched without matching similarly named paths.
| const safeOutputInputPath = `["']?(?:\$\{?GH_AW_AGENT_OUTPUT\}?|\$\{?GH_AW_SAFE_OUTPUTS\}?|/tmp/gh-aw/|\$\{?RUNNER_TEMP\}?/gh-aw/|\$\{\{\s*runner\.temp\s*\}\}/gh-aw/)` | ||
|
|
||
| var ( | ||
| safeOutputMintedTokenRE = regexp.MustCompile(`(?i)\bsteps\s*(?:\.\s*([A-Za-z0-9_-]+-app-token)\b|\[\s*['"]([A-Za-z0-9_-]+-app-token)['"]\s*\])`) |
There was a problem hiding this comment.
Fixed in 237f6c0: full step IDs, including suffixes and indexed IDs, are checked.
| const safeOutputInputPath = `["']?(?:\$\{?GH_AW_AGENT_OUTPUT\}?|\$\{?GH_AW_SAFE_OUTPUTS\}?|/tmp/gh-aw/|\$\{?RUNNER_TEMP\}?/gh-aw/|\$\{\{\s*runner\.temp\s*\}\}/gh-aw/)` | ||
|
|
||
| var ( | ||
| safeOutputMintedTokenRE = regexp.MustCompile(`(?i)\bsteps\s*(?:\.\s*([A-Za-z0-9_-]+-app-token)\b|\[\s*['"]([A-Za-z0-9_-]+-app-token)['"]\s*\])`) |
There was a problem hiding this comment.
Fixed in 237f6c0: outcome and conclusion reads are exempted and covered by a regression test.
|
|
||
| var ( | ||
| safeOutputMintedTokenRE = regexp.MustCompile(`(?i)\bsteps\s*(?:\.\s*([A-Za-z0-9_-]+-app-token)\b|\[\s*['"]([A-Za-z0-9_-]+-app-token)['"]\s*\])`) | ||
| safeOutputEnvFileRE = regexp.MustCompile(`\$\{?(?:GITHUB_ENV|GITHUB_PATH)\b`) |
There was a problem hiding this comment.
Fixed in 237f6c0: write destinations are checked across shell, PowerShell and Actions-context forms; reads are permitted.
| declared := make(map[string]struct{}) | ||
| for _, raw := range steps { | ||
| if step, ok := raw.(map[string]any); ok { | ||
| if id, ok := step["id"].(string); ok { | ||
| declared[strings.ToLower(id)] = struct{}{} | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Fixed in 237f6c0: authored pre-step and setup-step IDs, including the job alias, are included.
| return "", false | ||
| } | ||
| uses = strings.TrimSpace(uses) | ||
| if uses != "actions/checkout" && !strings.HasPrefix(uses, "actions/checkout@") { |
There was a problem hiding this comment.
Fixed in 237f6c0 using the shared action and boolean parsing helpers.
| for _, command := range strings.FieldsFunc(line, func(r rune) bool { return r == ';' || r == '|' || r == '&' }) { | ||
| if safeOutputTamperRE.MatchString(command) { | ||
| return true | ||
| } | ||
| if safeOutputMoveCopyRE.MatchString(command) { | ||
| fields := strings.Fields(command) | ||
| if len(fields) > 2 && slices.ContainsFunc(fields[len(fields)-1:], safeOutputInputTargetRE.MatchString) { |
There was a problem hiding this comment.
Fixed in 237f6c0: shell command write operands are inspected, with regression cases for the reported examples.
|
Warning Threat detection engine error Threat detection could not complete its analysis due to a tooling error. This is not a security finding. What happenedThe threat detection engine failed to produce results. Review the workflow run logs to troubleshoot the error. 🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "2b7002c58ab2eb00c9c8cbf2c7585092d0911f17",
"kind": "requested",
"schema_version": "1",
"state": "bc47e247bda15f3e20638adcf3b358fe5acf89cd6bb5682081ed118c9685fc57",
"work": [
"38e84294bbdaccf5100894c54662be1f8db12f2e84340bebe73828999670f71b",
"3a48c5cfdc46cc3b15fa87dfc2b96661c195bb4577df61c2766f356424449376",
"608bcba1ae40395c4b39dd69c4132a565f9f6307229076673a346062980ffde1",
"7be24eb78cf4bea4ae65dd4573a5705fa3341f343ce6842e9305b95ff15cb4ed",
"bd04108f4c44bde7c656b7a621361977f91afbfa02d6ff29b512b371868861e2",
"c32552bd3fd8bedb5a2073ed554c2db5e42fe56bf909d9e802d2baec0d7664c2",
"c79412d9f867da383c13684ef5822d56d589fd4f0a7d19372f87912de82a3276",
"e044d139036157437553af29b19e5243b75a7f40a9ea84a22ebb33421492bc6f",
"e92fd48373a36772c76ec27666615939972af6078373d12d7fb0f3d28c1981d3"
],
"workflow": "pr-sous-chef"
}
|
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
|
@copilot fix ci failures |
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Merged main in 4673249 and replied to the review threads addressed by 237f6c0. Recompilation was blocked by npm registry DNS resolution.
Fixed the failing |

Custom
safe-outputs.stepsare trusted, but they run inside thesafe_outputsjob after the compiler has minted write-scoped GitHub App tokens and configured persisted git credentials for the safe-output handlers. A well-meaning step can accidentally reuse or disturb those credentials. This adds an AW lint rule (gh aw lint) to catch the common accidental misuses.What
safe-output-credentialsflagsFor each authored
safe-outputs.steps[N]:steps.*-app-tokenoutputs (dot or bracket form) in any step field, unless the token step id is declared by the user's own steps.$GITHUB_ENV/$GITHUB_PATH, orcore.exportVariable/core.addPathinrunorwith.script. These change the environment of later handler steps that hold write tokens.actions/checkoutwithoutpersist-credentials: false, which would replace the workspace and git credentials prepared for handlers.>/>>,tee,sed -i,rm,truncate,mv/cpdestination) on$GH_AW_AGENT_OUTPUT,$GH_AW_SAFE_OUTPUTS,/tmp/gh-aw/, or${RUNNER_TEMP}/gh-aw/. Handlers apply these after threat detection.Severity is error in strict mode and warning with
strict: false(viasourcePolicySeverity). Diagnostics are per step with precise paths (e.g.safe-outputs.steps[0].env) and value-free messages.Notes for reviewers
pkg/workflow/lintper the request.CTR-*threat ID is assigned, since none currently covers this./tmp/gh-awand copies from it are allowed)..github/workflowstriggers the rule.Testing
safe_output_credentials_test.gopolicy tests (19 cases), plus contract, spec, default-registry, value-free failure, and CLI lint test entries.make agent-report-progresspasses.Docs: added a row to the workflow-linters rule table and a paragraph in the safe-outputs reference.