Skip to content

Reject direct issue creation and safe-output access in post-steps - #66064

Merged
pelikhan merged 10 commits into
mainfrom
copilot/add-compiler-support-for-post-steps
Oct 6, 2026
Merged

pelikhan merged 10 commits into
mainfrom
copilot/add-compiler-support-for-post-steps

Conversation

Copilot AI commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

User post-steps can attempt to publish agent-generated issues outside safe outputs or read the agent’s output file directly. The compiler now reports these patterns as errors and points authors to safe outputs.

  • Validation: Check main and imported post-steps for direct issue creation through common gh, REST, curl, and GitHub Script patterns, and for access to agent_output.json. Read-only issue queries remain allowed.
  • Guidance: Identify the offending step and suggest safe-outputs.create-issue for issue publishing. Document the restriction in the post-steps reference.
  • Coverage: Add cases for rejected patterns and permitted read-only operations.

Copilot AI and others added 2 commits October 6, 2026 07:30
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Reject unsafe issue creation and safe-output reads in post-steps Reject direct issue creation and safe-output access in post-steps Oct 6, 2026
Copilot AI requested a review from pelikhan October 6, 2026 07:38
@pelikhan
pelikhan marked this pull request as ready for review October 6, 2026 11:48
Copilot AI balanced review requested due to automatic review settings October 6, 2026 11:48
@pelikhan

pelikhan commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

@copilot they also try to access the safeoutputs mcp storage file outputs.jsonl

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Validation still permits prohibited operations and rejects valid read-only requests.

Review effort: Balanced
Findings: 7 High severity

Open (7)
What changed in this PR

Adds compiler checks intended to keep post-step issue publishing and agent-output access within the safe-output system.

Changes:

  • Validates main and imported post-steps.
  • Adds rejection, read-only, and compilation tests.
  • Documents the restriction and safe-output alternative.
File Description
pkg/​workflow/​workflow_builder_steps.go Validates merged post-steps.
pkg/​workflow/​post_steps_validation.go Detects prohibited commands and output-file references.
pkg/​workflow/​post_steps_validation_test.go Tests validation and compiler integration.
docs/​src/​content/​docs/​reference/​steps-jobs.md Documents post-step restrictions.

Comment thread pkg/workflow/post_steps_validation.go Outdated
)

var (
postStepIssueCreateRE = regexp.MustCompile(`(?i)(?:^|[\s|;&])gh\s+issue\s+create\b`)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added detection for gh -R/--repo before issue create and regression coverage confirming gh -R ... issue list remains allowed. Fix is in e24f63b.

Comment thread pkg/workflow/post_steps_validation.go Outdated
postStepIssueAPIRE = regexp.MustCompile(`(?i)(?:^|[/\s"'=])(?:https://api\.github\.com/)?repos/(?:[^/\s"'?]+/[^/\s"'?]+|\$\{\{\s*github\.repository\s*\}\}|\$\{?GITHUB_REPOSITORY\}?)/issues(?:[?"'\s]|$)`)
postStepAPIPostRE = regexp.MustCompile(`(?i)(?:^|\s)(?:-X\s+POST|--method(?:=|\s+)POST|-f(?:\s|=)|-F(?:\s|=)|--(?:raw-)?field(?:\s|=))`)
postStepAPIGetRE = regexp.MustCompile(`(?i)(?:^|\s)(?:-X\s+GET\b|--method(?:=|\s+)GET\b)`)
postStepCurlPostRE = regexp.MustCompile(`(?i)\bcurl\b[^\n]*\s(?:-X\s+POST\b|--request(?:=|\s+)POST\b|(?:-d|--data(?:-raw|-binary|-urlencode)?)(?:\s|=))`)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curl validation now derives the effective method from JSON/data options, -G/--get, and explicit -X/--request overrides, with POST and GET regression cases. Fix is in e24f63b.

postStepAPIPostRE = regexp.MustCompile(`(?i)(?:^|\s)(?:-X\s+POST|--method(?:=|\s+)POST|-f(?:\s|=)|-F(?:\s|=)|--(?:raw-)?field(?:\s|=))`)
postStepAPIGetRE = regexp.MustCompile(`(?i)(?:^|\s)(?:-X\s+GET\b|--method(?:=|\s+)GET\b)`)
postStepCurlPostRE = regexp.MustCompile(`(?i)\bcurl\b[^\n]*\s(?:-X\s+POST\b|--request(?:=|\s+)POST\b|(?:-d|--data(?:-raw|-binary|-urlencode)?)(?:\s|=))`)
postStepOctokitRE = regexp.MustCompile(`\b(?:github|octokit)(?:\.rest)?\.issues\.create\s*\(`)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added checks for literal POST issue routes in both github.request and octokit.request; GET and issue-comment routes remain allowed. Fix is in e24f63b.

Comment thread pkg/workflow/post_steps_validation.go Outdated
postStepAPIGetRE = regexp.MustCompile(`(?i)(?:^|\s)(?:-X\s+GET\b|--method(?:=|\s+)GET\b)`)
postStepCurlPostRE = regexp.MustCompile(`(?i)\bcurl\b[^\n]*\s(?:-X\s+POST\b|--request(?:=|\s+)POST\b|(?:-d|--data(?:-raw|-binary|-urlencode)?)(?:\s|=))`)
postStepOctokitRE = regexp.MustCompile(`\b(?:github|octokit)(?:\.rest)?\.issues\.create\s*\(`)
postStepOutputRE = regexp.MustCompile(`(?i)(?:\bagent_output\.json\b|(?:safeoutputs|safe-outputs)/output\.json\b|\bGH_AW_AGENT_OUTPUT\b)`)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validator now rejects outputs.jsonl, the collected safe-output path, GH_AW_SAFE_OUTPUTS, and the runtime-path expression. Fix is in e24f63b.

Comment on lines +30 to +34
if with, ok := step["with"].(map[string]any); ok {
if script, ok := with["script"].(string); ok {
scripts = append(scripts, script)
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added safe-output checks for path inputs to upload-artifact, cache, and upload-pages-artifact actions, including broad /tmp/gh-aw/ paths. The docs example now uploads only /tmp/gh-aw/agent/. Fix is in e24f63b.

Comment thread pkg/workflow/post_steps_validation.go Outdated

for _, script := range scripts {
createsIssue := postStepIssueCreateRE.MatchString(script) || postStepOctokitRE.MatchString(script)
for _, command := range ghAPICmdRE.FindAllStringSubmatch(script, -1) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shell validation now joins backslash-continued lines and splits commands at unquoted shell separators, preserving command boundaries. Added continued gh api and curl regressions. Fix is in e24f63b.

Comment thread pkg/workflow/post_steps_validation.go Outdated
createsIssue := postStepIssueCreateRE.MatchString(script) || postStepOctokitRE.MatchString(script)
for _, command := range ghAPICmdRE.FindAllStringSubmatch(script, -1) {
for _, args := range command {
if postStepIssueAPIRE.MatchString(parseGHAPIEndpoint(args)) &&

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handled gh api --input before the endpoint in post-step endpoint parsing and added a regression case for that argument order. Fix is in e24f63b.

@pelikhan

pelikhan commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill
also scan for secrets in post-step env section (should not be allowed)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot they also try to access the safeoutputs mcp storage file outputs.jsonl

Post-step validation now rejects both safeoutputs/outputs.jsonl and the collected safeoutputs.jsonl path. Added regression coverage in commit 11c44de.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot run pr-finisher skill
also scan for secrets in post-step env section (should not be allowed)

Post-step validation now rejects GitHub secret references in step-level env values without echoing the referenced secret. Added coverage and documented the restriction in e24f63b.

@pelikhan

pelikhan commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

@copilot merge main, recompile , fix golden wasm

Copilot AI and others added 2 commits October 6, 2026 12:53
…support-for-post-steps

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot merge main, recompile , fix golden wasm

Merged main, recompiled all workflows, and refreshed the stale WASM golden fixtures. The CI golden failures are fixed in 39511b8.

@pelikhan

pelikhan commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix https://github.com/github/gh-aw/actions/runs/37467420656/job/112292656739?pr=66064

Fixed the failing workflow tests in 527bcf6. The impacted Go tests and final change-scoped validation pass; automated Code Review reported no comments, though its backend was unavailable, and CodeQL was skipped because these are test-only changes.

@pelikhan

pelikhan commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts on this branch.

…support-for-post-steps

# Conflicts:
#	pkg/workflow/action_pins_test.go
#	pkg/workflow/compiler_jobs_test.go

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts on this branch.

Merged the latest main and resolved both test conflicts in merge commit 68c4aa6b. Targeted workflow tests and the final impacted checks pass.

@pelikhan
pelikhan merged commit 62aa9ec into main Oct 6, 2026
1 of 2 checks passed
@pelikhan
pelikhan deleted the copilot/add-compiler-support-for-post-steps branch October 6, 2026 14:34
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.91.2

github-actions Bot added a commit that referenced this pull request Oct 7, 2026
…ts changes

Document engine.dynamic-workflows (schema default false, added in #66195),
correct model-routing allowed-models to reflect that declared sub-agent
models are now admitted separately from routing candidates (#66234), and
note the compile-time rejection of issue creation and safe-output storage
access in user post-steps (#66064).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants