Skip to content

fix: validate workflow env credentials using parsed references - #76633

Merged
lpcox merged 3 commits into
mainfrom
lpcox-bracket-token-guard
Nov 11, 2026
Merged

lpcox merged 3 commits into
mainfrom
lpcox-bracket-token-guard

Conversation

@lpcox

@lpcox lpcox commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Share parsed-reference credential classification between workflow environment validation and prompt validation.
  • Reject credential-bearing workflow env expressions in strict mode, warn in non-strict mode, and fail compilation for invalid env expression syntax rather than skipping classification.
  • Preserve supported engine.env credential overrides and apply the existing minimum AWF version requirement consistently.
  • Add file/string compilation regressions covering equivalent reference forms, compound expressions, safe literals, engine configuration, and absence of generated locks on failure; document the boundary.

Validation

  • Confirmed the new compile regressions fail before the fix and pass afterward.
  • Related env, engine, prompt, and secrets-serialization regression tests pass.
  • make agent-report-progress passed, 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.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

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>
Copilot AI dynamic review requested due to automatic review settings November 11, 2026 00:07

@github-actions github-actions Bot 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.

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) {

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.

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'] }}"},

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.

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.

@lpcox

lpcox commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address review feedback

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.

🟡 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.env credential 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)

Comment on lines +40 to +43
// 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)
Comment on lines +30 to +38
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)
Copilot AI and others added 2 commits November 11, 2026 00:43
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

Copilot AI commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Addressed in 35e14a0e (with lint cleanup in 9e306a1e). Final validation passed; CodeQL reported no alerts but skipped Go analysis because the database exceeded its size limit.

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.3

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