Repository navigation
fix: validate workflow env credentials using parsed references - #76633
Conversation
Use parsed reference paths for env credential validation and preserve engine credential isolation requirements. Reject invalid env expression syntax instead of silently skipping classification. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
update.googleapis.com
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
network:
allowed:
- defaults
- "update.googleapis.com"See Network Configuration for more information.
💥 [THE END] — Illustrated by Smoke Claude · claude · sonnet46 · ~83 AIC · ⌖ ~11 AIC · ⊞ 1K
Comment /smoke-claude to run again
|
|
||
| // Keep credential classification separate from named-secret extraction, which | ||
| // also drives bindings for secrets but not github.token. | ||
| func credentialExpressionsFromMap(values map[string]string) ([]string, error) { |
There was a problem hiding this comment.
Nice refactor! Extracting credentialExpressionsFromMap makes the credential detection logic reusable. Using parsed AST references instead of raw string matching is more robust and handles bracket notation like github[token].
| {name: "unversioned firewall", key: "ANTHROPIC_API_KEY", strict: true, awfVersion: "custom", wantError: "requires AWF v0.25.3 or newer"}, | ||
| {name: "non-strict older firewall", key: "ANTHROPIC_API_KEY", awfVersion: "v0.25.0"}, | ||
| {name: "older firewall without secrets", key: "ANTHROPIC_API_KEY", strict: true, awfVersion: "v0.25.0", envValue: "plain-value"}, | ||
| {name: "declared key with github token", key: "ANTHROPIC_API_KEY", strict: true, envValue: "${{ github['token'] }}"}, |
There was a problem hiding this comment.
Good addition of github[token] bracket notation test cases. This ensures credential validation works for both dot-notation (github.token) and bracket-notation (github[token]) expressions.
|
@copilot address review feedback |
There was a problem hiding this comment.
🟡 Changes recommended
Credential-validation and environment-exclusion gaps let imported or unresolved credential references bypass checks and allow a Copilot API key to reach the agent sandbox.
4 open issues
What changed in this PR
Updates gh-aw’s workflow environment validation to classify credentials using parsed expression references shared with prompt validation.
Changes:
- Rejects credential-bearing workflow env expressions in strict mode, warns in non-strict mode, and rejects invalid expression syntax.
- Extends the existing AWF version check while preserving supported
engine.envcredential overrides. - Adds file/string compilation regressions and documents the validation boundary.
| File | Description |
|---|---|
pkg/workflow/strict_mode_env_validation.go |
Adds parsed credential classification and updates env validation. |
pkg/workflow/env_secrets_validation_test.go |
Covers reference forms, syntax errors, engine overrides, and lock generation. |
pkg/workflow/credential_free_prompt.go |
Extracts the shared credential-reference predicate. |
docs/src/content/docs/reference/environment-variables.md |
Documents credential restrictions, syntax rules, and AWF requirements. |
Review effort: Max (auto)
| // Whole-context secrets serialization has its own validation pass. | ||
| if slices.ContainsFunc(actionslanguageservice.References(expression), func(path []string) bool { | ||
| return len(path) >= 2 && isCredentialReference(path) | ||
| }) { |
| if err != nil { | ||
| return fmt.Errorf("invalid expression in 'engine.env' section: %w", err) | ||
| } | ||
| if c.strictMode && len(credentialRefs) > 0 && !awfSupportsExcludeEnv(getFirewallConfig(ctx.workflowData)) { |
| // Extract secrets from env values | ||
| secrets := ExtractSecretsFromMap(envStrings) | ||
| if len(secrets) == 0 { | ||
| secretRefs, err := credentialExpressionsFromMap(envStrings) |
| return nil, fmt.Errorf("invalid expression in env variable %q: %w", key, err) | ||
| } | ||
| for _, span := range spans { | ||
| expression, err := actionslanguageservice.ParseSyntax(span.Content) | ||
| if err != nil || expression == nil { | ||
| if err == nil { | ||
| err = errors.New("an expression was expected") | ||
| } | ||
| return nil, fmt.Errorf("invalid expression in env variable %q: %w", key, err) |
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Addressed in |
|
🎉 This pull request is included in a new release. Release: |


Summary
engine.envcredential overrides and apply the existing minimum AWF version requirement consistently.Validation
make agent-report-progresspassed, including lint, impacted tests, and recompilation of 365 workflows with no lock drift. Follow-up compatibility adjustment passed related regressions, compile/vet, rebuild, and final changed-code lint.Relates to githubnext/gh-aw-security#3369.
✨ PR Review Safe Output Test - Run 42929322893
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
update.googleapis.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.