Skip to content

Harden OpenAI WIF detection and firewall wiring - #76236

Merged
pelikhan merged 4 commits into
mainfrom
copilot/openai-wif-proxy-support
Nov 9, 2026
Merged

pelikhan merged 4 commits into
mainfrom
copilot/openai-wif-proxy-support

Conversation

Copilot AI commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

OpenAI WIF still depends on OpenAI support in the AWF API proxy; the current default, AWF v0.29.10, does not provide it. This change addresses gh-aw’s detector validation, permissions, and firewall allowlists while documenting the dependency.

  • Detection auth and permissions

    • Validate required OpenAI WIF fields when auth is configured only for threat detection.
    • Grant id-token: write based on the effective detection engine configuration.
    • Example detector-only configuration:
      safe-outputs:
        threat-detection:
          engine:
            id: codex
            auth:
              type: github-oidc
              provider: openai
              identity-provider-id: ${{ vars.OPENAI_IDENTITY_PROVIDER_ID }}
              service-account-id: ${{ vars.OPENAI_SERVICE_ACCOUNT_ID }}
              audience: https://api.openai.com/v1
  • Firewall and documentation

    • Add auth.openai.com to the agent and detection allowlists for OpenAI WIF.
    • Include the exchange host in the authentication example and note the current AWF limitation.
  • Remaining dependency

    • AWF issue #11355 tracks proxy support. A minimum-version pin and real token-exchange trial remain dependent on a supporting AWF release.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for starting this work, @Copilot! 🚀 The OpenAI WIF proxy support is well-aligned with AWF's agentic development focus.

A few things as this moves forward:

  • Tests — Once the implementation lands, make sure to add focused regression tests for the OpenAI WIF validation, detector engine resolution, and allowlist changes. The checklist mentions this, which is great.
  • PR scope — The checklist is clear and broken down nicely. Once implementation is complete, make sure the final PR includes all test coverage for the domain allowlists and detection logic.

The [WIP] status and agentic checklist approach looks perfect for this style of development. Looking forward to the next update!

Generated by ✅ Contribution Check · copilot · routed: haiku55 xhigh · ~14 AIC · ⌖ ~2 AIC · ⊞ 5.4K · ◷

Copilot AI changed the title [WIP] Add AWF proxy support for OpenAI WIF Harden OpenAI WIF detection and firewall wiring Nov 9, 2026
Copilot AI requested a review from pelikhan November 9, 2026 13:05
@pelikhan
pelikhan marked this pull request as ready for review November 9, 2026 14:42
Copilot AI adaptive review requested due to automatic review settings November 9, 2026 14:42
@pelikhan

pelikhan commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

@copilot also support configuring evals

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_no_action

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.

Generated from PR Specification Reviewer · gpt56 · ~2 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.7K · ◷

Generated by PR Specification Reviewer for #76236

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

❌ Design Decision Gate 🏗️ failed to deliver outputs during design decision gate check.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

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.

Generated from Test Quality Sentinel · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 7.2K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

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.

Generated from Ponytail Reviewer · routed: gpt61 medium · ~5 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 181 · ◷

Generated by Ponytail Reviewer for #76236

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Warning

The push_to_pull_request_branch operation failed: Cannot verify branch protection rules for "copilot/openai-wif-proxy-support": Resource not accessible by integration - https://docs.github.com/rest/branches/branch-protection\#get-branch-protection. Reading classic branch protection requires a GitHub App installation token or fine-grained PAT with Administration: read repository permission; GITHUB_TOKEN cannot provide this permission. Push blocked to prevent accidental writes to protected branches.. The code changes were not applied.

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (146 new lines under pkg/workflow/, above the 100-line threshold) but does not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/76236-scope-openai-wif-to-detector-engine.md. Review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR committed to your branch. It was generated from the PR diff and the linked issue OpenAI WIF follow-up: AWF proxy support, version check and unaddressed #75927 review items #76221.

  2. Complete the missing sections. Confirm or revise the alternatives and consequences. The AWF minimum-version gate (Alternative 3) was a close call and is deferred.

  3. Commit the finalized ADR to docs/adr/ on your branch.

  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-76236: Scope OpenAI WIF Validation, Permissions, and Egress to the Detector Engine (link unavailable: invalid HTTPS URL)

Once an ADR is linked in the PR body, this gate will re-run and verify that the implementation matches the decision.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete: Context, Decision, Alternatives Considered, and Consequences. The draft has all four.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · routed: haiku55 xhigh · ~3 AIC · ⌖ ~2 AIC · ⊞ 8.6K · ◷
Comment /review to run again

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-09T14:47:11Z
review_event: REQUEST_CHANGES
top_themes: [detector-only OpenAI WIF validation must match runtime provider setup]
files_reviewed: [pkg/workflow/compiler_validators.go, pkg/workflow/threat_detection_job.go, pkg/workflow/threat_detection_helpers.go, pkg/workflow/codex_engine.go, pkg/workflow/codex_azure_oidc_test.go]
comment_count: 1

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~6 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷
Comment /review to run again

@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.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~6 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again

detectionData := *workflowData
detectionData.EngineConfig = cloneThreatDetectionEngineConfig(engineID, detectionConfig)
if workflowData.SafeOutputs.ThreatDetection.Model != "" {
detectionData.Model = workflowData.SafeOutputs.ThreatDetection.Model

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.

When the detector override omits model, this validator copies workflowData.Model directly, but the runtime path in buildExternalDetectorWorkflowData subsequently forces EngineConfig.LLMProvider = openai for a Codex detector whose effective provider is not GitHub. For example, a Copilot main workflow with a Codex detector and an inherited copilot/... model is rejected here as requiring the OpenAI provider, even though the generated detector config is explicitly OpenAI at runtime. Please derive the effective provider/model using the same detector setup as the runtime before validating, and add a regression test for a cross-engine detector.

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.

Detector validation now uses the selected detector’s runtime configuration, including its effective model and provider normalization. Added cross-engine inherited-model coverage in faed3e0.

@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.

Found one correctness issue in detection-only OpenAI WIF validation: cross-engine Codex detectors can be rejected based on the main workflow model/provider even though runtime setup forces the detector provider to OpenAI. Please align validation with runtime detector configuration and add coverage.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~6 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again

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

Same-engine detector overrides without explicit auth can omit the required OIDC token permission despite inheriting OIDC settings, causing detector authentication to fail.

3 open issues
What changed in this PR

Hardens OpenAI workload identity federation (WIF) configuration in gh-aw’s compiler for agents and threat detectors. End-to-end authentication still depends on a supporting AWF release.

Changes:

  • Validate detector-only OpenAI WIF settings and derive token permissions from detector configuration.
  • Add auth.openai.com to agent and detector firewall allowlists.
  • Extend regression coverage and document the current AWF limitation.
File Description
pkg/​workflow/​threat_detection_job.go Derives OIDC permissions from detector authentication.
pkg/​workflow/​threat_detection_helpers.go Adds the OpenAI exchange host to detector allowlists.
pkg/​workflow/​threat_detection_firewall_test.go Tests exchange-host access for inherited WIF.
pkg/​workflow/​compiler_validators.go Validates detector-only OpenAI WIF configuration.
pkg/​workflow/​codex_engine.go Allows the exchange host for Codex WIF.
pkg/​workflow/​codex_azure_oidc_test.go Tests detector validation, permissions, and firewall wiring.
docs/​src/​content/​docs/​reference/​auth.mdx Updates the allowlist example and explains the AWF support blocker.

Review effort: Max (auto)

Comment on lines +221 to 223
if detectionAuthData.EngineConfig != nil && detectionAuthData.EngineConfig.Auth != nil && detectionAuthData.EngineConfig.Auth.Type == "github-oidc" {
perms.Set(PermissionIdToken, PermissionWrite)
}
Comment thread pkg/workflow/compiler_validators.go Outdated
Comment on lines +787 to +788
detectionData := *workflowData
detectionData.EngineConfig = cloneThreatDetectionEngineConfig(engineID, detectionConfig)
Comment thread pkg/workflow/compiler_validators.go Outdated
detectionData.Model = workflowData.SafeOutputs.ThreatDetection.Model
}
if err := validateOpenAIWIFEngineAuth(&detectionData); err != nil {
return fmt.Errorf("safe-outputs.threat-detection.engine.auth: %w", err)

@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.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd. Two inline comments, no blocking issues.

📋 Key Themes & Highlights

Key Themes

  • Possible false positive: a copilot/ main model with a codex detector and no threat-detection.model is rejected at compile time. The error does not name the fix.
  • Test gap: the new WIF table always includes a main engine: codex block, so the detector-only config is not tested.

Positive Highlights

  • ✅ Detection job sets id-token: write from the resolved detector config, so the main-job OIDC validator does not need to change.
  • ✅ Detector-only compile output checked: id-token: write, auth.openai.com in the AWF allowlist, and AWF_AUTH_OPENAI_* env mapping are all present.
  • ✅ Docs note that AWF v0.29.10 does not support OpenAI WIF.

Verification

Targeted WIF/threat-detection tests and gofmt pass. Five unrelated pkg/workflow tests fail in this sandbox for environmental reasons (temp-dir permissions, inherited token, clock-dependent expiry, fixture mismatches). I did not confirm they also fail on main.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 6.3K
Comment /matt to run again

Comment thread pkg/workflow/compiler_validators.go Outdated
if engineID == "" {
engineID = ResolveEngineID(workflowData)
}
detectionData := *workflowData

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.

[/diagnosing-bugs] Possible false positive. With engine: copilot/gpt-5 on the main workflow and a codex detector that has no threat-detection.model, compile fails with engine.auth with provider=openai requires the OpenAI inference provider. The cause is inheritedDetectionModel (threat_detection_helpers.go:356), which passes the main copilot/ model to a codex detector. The detection job inherits the same value, so validator and job agree, but the error does not say to set threat-detection.model. Setting an explicit detector model compiles successfully.

💡 Suggested fix

Confirm whether cross-engine model inheritance is intended. If not, skip inheritance when the detector engine differs from the main engine. If it is intended, make the error name threat-detection.model as the fix.

@copilot please address this.

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.

Validation now mirrors the runtime detector path and applies inherited or explicit detector models before checking the effective provider. The cross-engine inherited-model regression is in faed3e0.

assert.NotContains(t, detectionSection, `env_key = "CODEX_API_KEY"`)
}

func TestCodexOpenAIWIFDetectionValidationAndPermissions(t *testing.T) {

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.

[/tdd] The table covers detector-only OpenAI WIF only with a main engine: codex block, so the detector-only config from the PR description is untested. Add a case with no main engine: block and threat-detection.engine set to codex with github-oidc/openai auth.

💡 Suggested test cases
  • No main engine: block, detector-only codex + github-oidc/openai: expect id-token: write on the detection job and auth.openai.com in the AWF allowlist.
  • Main engine: copilot with model: copilot/gpt-5, plus an explicit threat-detection.model: pins the model-override path that the validator uses.

@copilot please address this.

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 compile regressions for detector-only OpenAI WIF without a main engine and for a Copilot main model with an explicit detector model override. Both verify the exchange host and id-token: write; included in faed3e0.

Copilot AI commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot also support configuring evals

I checked the evals path: it calls the Decisions API directly and does not run through the AWF proxy. The current OpenAI WIF setup only supplies auth to that proxy, and the proxy version in this PR does not yet support the OpenAI exchange. Should evals gain their own auth configuration while remaining blocked on proxy support, or should this include moving eval requests through a proxy/token-exchange path?

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (pkg/workflow/compiler_validators.go:790): address unresolved feedback - Review comment
  3. Review (pkg/workflow/compiler_validators.go:787): address unresolved feedback - Review comment
  4. Review (pkg/workflow/codex_azure_oidc_test.go:265): address unresolved feedback - Review comment
  5. Fix failing check impacted-go-tests (FAILURE): Check run.
  6. Fix failing check safe_outputs (FAILURE): Check run.

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "c7d6a6937f2d73317af1ecd914a303d4ae455cfa",
  "kind": "requested",
  "schema_version": "1",
  "state": "1fe2cf1d267a91f9ed3dcfd3c507a2fbd44b88523895abf24c300157d1704264",
  "work": [
    "42e5d572d9d75b7168fe7d0aeda0717cc07e65ed240f6d299e6fec661214f1ac",
    "54e83072828b730faf5010a08defba4f2d09dbb12954885c809a5b3befded107",
    "646435ee7eaf3e1c5252b57d8812bff2f706af1b1652808403fbfa3847f3e9f8",
    "8a6e43333bbf52c6d9abed08a730eccd6366fa323c6fd74324d5e2c31b88662e",
    "c7cf93e497befdd5e698d00101b0703e4101fe4133d86d433f7c170d07402b7e"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · haiku45 · ~15 AIC · ⌖ ~13 AIC · ⊞ 1.3K · ◷
Comment /souschef to run again

Copilot AI requested a review from gh-aw-bot November 9, 2026 16:02
@pelikhan
pelikhan merged commit 4b41e5a into main Nov 9, 2026
76 checks passed
@pelikhan
pelikhan deleted the copilot/openai-wif-proxy-support branch November 9, 2026 18:07
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.2

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.

OpenAI WIF follow-up: AWF proxy support, version check and unaddressed #75927 review items

4 participants