Skip to content

api-proxy: bind cloud OIDC credentials to the configured upstream - #12000

Merged
lpcox merged 2 commits into
mainfrom
fix/api-proxy-cloud-oidc-host-binding
Nov 23, 2026
Merged

lpcox merged 2 commits into
mainfrom
fix/api-proxy-cloud-oidc-host-binding

Conversation

@lpcox

@lpcox lpcox commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

When AWF_AUTH_TYPE=github-oidc is used with a cloud provider (AWF_AUTH_PROVIDER=azure|aws|gcp), every adapter resolved the same global OIDC configuration. That included adapters whose upstream was left at its default (api.openai.com, api.anthropic.com, the derived GitHub Copilot host). In BYOK setups, those adapters attached a credential meant for the BYOK gateway and also became "enabled", so startup discovery contacted providers the workflow never configured.

This PR binds cloud OIDC credentials to the upstream they were configured for.

Changes

  • providers/cloud-oidc-init.js
    • Cloud providers (Azure/AWS/GCP) are now opt-in per adapter through a new allowCloudOidc option, and they are checked against the adapter's targetHost.
    • New isCloudOidcTargetAllowed() rejects first-party hosts (api.openai.com, api.anthropic.com, *.githubcopilot.com, copilot-api.*.ghe.com) and empty or unparseable targets. Refusals are logged (cloud_oidc_not_bound / cloud_oidc_target_refused).
    • The Azure branch is now explicit (authProvider === 'azure'). It no longer acts as the fallback for other providers such as anthropic, or openai without WIF enabled.
  • Adapters
    • adapter-factory.js passes targetHost/adapterName automatically.
    • OpenAI binds only with an explicit OPENAI_API_TARGET or the Azure BYOK provider URL.
    • Anthropic binds only with an explicit ANTHROPIC_API_TARGET.
    • Copilot binds only with an explicit COPILOT_API_TARGET, which the CLI already sets from COPILOT_PROVIDER_BASE_URL.
    • Gemini/Vertex bind when AWF_AUTH_PROVIDER=gcp.
  • Native OpenAI WIF (openai) and Anthropic WIF (anthropic) are unchanged.
  • Docs: added a "Cloud OIDC target binding" section to docs/api-proxy-sidecar.md.

Compatibility

The CLI already sets COPILOT_API_TARGET (and OPENAI_API_TARGET for COPILOT_PROVIDER_TYPE=azure) from the BYOK provider URL, so supported BYOK + cloud OIDC configurations keep working. Tests that built adapters with cloud OIDC and no explicit target now set the target, matching what the CLI produces.

Tests

  • New isCloudOidcTargetAllowed and target-binding unit tests in providers/cloud-oidc-init.test.js.
  • New Auth Matrix — cloud OIDC target binding suite covering Azure, AWS and GCP across the OpenAI, Anthropic and Copilot adapters (default targets and explicit first-party targets), plus a positive case for an explicitly configured gateway. These fail on main and pass with this change.
  • cd containers/api-proxy && npm test: 177/180 suites pass. The 3 remaining suites (catalogue-proxy, model-information-contract, protocol-compatibility.packaging) need root-level dependencies (ajv, typescript) that were not installed locally. They are unrelated to this change.

Azure/AWS/GCP workload identity credentials are now initialized only by
adapters whose upstream is explicitly configured (COPILOT_API_TARGET,
OPENAI_API_TARGET or the Azure BYOK provider URL, ANTHROPIC_API_TARGET,
or the Gemini/Vertex adapters for GCP). Adapters left at their default
upstream no longer pick up the global cloud OIDC configuration, and the
sidecar refuses to bind these credentials to first-party OpenAI,
Anthropic and GitHub Copilot hosts.

The Azure branch in resolveCloudOidcProviders is now explicit so it only
runs for AWF_AUTH_PROVIDER=azure (or unset).

Co-authored-by: Copilot App <[email protected]>
Copilot AI adaptive review requested due to automatic review settings November 23, 2026 15:50
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Documentation has been built for this PR.

Download preview artifact

To view locally:

  1. Download the docs-preview-pr-12000 artifact from the workflow run
  2. Unzip and open index.html in your browser

Built from commit f7be9eb

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

Cloud OIDC tokens and inherited Azure BYOK keys can be sent to unrelated upstreams because credential selection is not correctly bound to the effective target.

4 open issues
What changed in this PR

This PR narrows cloud OIDC credential use in AWF’s API proxy, aiming to prevent default provider adapters from receiving BYOK gateway credentials or triggering unwanted startup discovery.

Changes:

  • Adds per-adapter cloud OIDC opt-in, upstream checks, and refusal logging.
  • Updates adapter binding rules while preserving native OpenAI and Anthropic workload identity paths.
  • Adds binding regression tests, updates credential fixtures, and documents the new behavior.
File Description
docs/​api-proxy-sidecar.md Documents cloud OIDC target binding.
containers/​api-proxy/​server.custom-auth-header.test.js Adds explicit Azure targets to header tests.
containers/​api-proxy/​server.auth-matrix.test.js Adds default-target and first-party-host binding tests.
containers/​api-proxy/​routing-catalogue.test.js Configures an explicit target for OIDC catalogue tests.
containers/​api-proxy/​providers/​openai.js Enables cloud OIDC for explicit or Azure BYOK targets.
containers/​api-proxy/​providers/​google-adapter.js Enables cloud OIDC for Google adapters in GCP mode.
containers/​api-proxy/​providers/​copilot.js Requires an explicit target for cloud OIDC.
containers/​api-proxy/​providers/​cloud-oidc-init.test.js Tests opt-in requirements and host refusals.
containers/​api-proxy/​providers/​cloud-oidc-init.js Enforces binding checks and explicit Azure selection.
containers/​api-proxy/​providers/​anthropic.js Enables cloud OIDC for explicitly configured targets.
containers/​api-proxy/​oidc-token-provider.test.js Updates Azure OIDC fixtures with explicit targets.
containers/​api-proxy/​copilot-adapter-enterprise.test.js Updates Copilot OIDC fixtures with gateway targets.
containers/​api-proxy/​aws-oidc-token-provider.test.js Adds explicit targets to AWS/GCP adapter fixtures.
containers/​api-proxy/​adapter-factory.js Supplies target and adapter identity to OIDC resolution.

Review effort: Max (adaptive)

Comment on lines +73 to +74
if (authType === 'github-oidc' && !skipWhen && CLOUD_OIDC_PROVIDERS.has(authProvider)) {
if (!allowCloudOidc) {
allowOpenAiWif: openAiWifRequested,
// Cloud OIDC tokens are only bound to an explicitly configured upstream
// (OPENAI_API_TARGET or the Azure BYOK provider URL), never the default.
allowCloudOidc: !!(env[OPENAI_ENV.TARGET] || (copilotAzureByokEnabled && copilotByokTarget)),
const provider = injectOidcToken(adapter, 'entra-token');
expect(adapter.getAuthHeaders(fakeReq()).Authorization).toBe('Bearer entra-token');
provider.shutdown();
});
@lpcox

lpcox commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address review feedback

Copilot AI commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Addressed in d83d992. All 180 API proxy suites passed across the full run and a rerun of three suites after installing root dependencies. CodeQL analysis was skipped because its database was too large.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@lpcox Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅

🛡️ Egress verdict from Smoke Copilot Network Isolation

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

Warning

Threat detection engine error

Threat detection could not complete its analysis due to a tooling error. This is not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs to troubleshoot the error.

🔌 Service connectivity validated by Smoke Services

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

Warning

Threat detection engine error

Threat detection could not complete its analysis due to a tooling error. This is not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs to troubleshoot the error.

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ Security Guard completed successfully!

Security Guard

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 by Security Guard for #12000 · copilot · routed: gpt61 high · ~6 AIC · ⊞ 3.4K · ◷

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Claude passed

Generated by Smoke Claude for #12000 · claude · haiku45 · ~36 AIC · ⊞ 6.4K · ◷

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

Smoke Chroot

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Tested by Smoke Chroot

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Smoke Cloud Hypervisor completed. Cloud Hypervisor + Copilot passed.

Cloud Hypervisor + Copilot smoke test by Smoke Cloud Hypervisor

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ Build Test Suite 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 happened

The threat detection engine failed to produce results.

Review the workflow run logs to troubleshoot the error.

Build Test Suite

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • 169.254.169.254

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "169.254.169.254"

See Network Configuration for more information.

Generated by Build Test Suite for #12000 · copilot · routed: haiku55 xhigh · ~4 AIC · ⊞ 6.1K · ◷

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

Smoke Codex

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🔮 The oracle has spoken through Smoke Codex

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

Check Result
API status ✅ PASS
GitHub check ✅ PASS
File status ✅ PASS

Overall result: PASS

Generated by Smoke Claude for #12000 · claude · haiku45 · ~36 AIC · ⊞ 6.4K · ◷
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test

  • Refactor upstream dispatch into focused guard and transport modules ✅ GitHub merged PR review
  • Split Squid configuration generation into focused modules ✅ GitHub PR detail lookup
  • Playwright title check ❌
  • Temp file write/read ✅
  • AWF build ✅
  • Overall: FAIL

🔮 The oracle has spoken through Smoke Codex
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Cloud Hypervisor + Copilot smoke test

  1. Merged PR lookup: PASS
  2. github.com connectivity: PASS (HTTP 200)
  3. File write/read: PASS
  4. example.com blocked: PASS (HTTP 000)

Overall: PASS

Cloud Hypervisor + Copilot smoke test by Smoke Cloud Hypervisor
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot Engine (PR #12000, author @lpcox, assignees: none)

Recent merged PRs: #11992 (wildcard blocklist deny test pin), #11977 (auth docs fix)

Overall: PASS

📰 BREAKING: Report filed by Smoke Copilot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot Network Isolation ✅

Result: PASS

Check Status
Allowlist (api.github.com) ✅ HTTP 200
Deny list (example.com) ✅ Blocked (SSL error)
EGRESS_RESULT allow=pass deny=pass

The firewall correctly permits allowlisted domains and blocks non-allowlisted domains.

🛡️ Egress verdict from Smoke Copilot Network Isolation
Add label ready-for-aw to run again

@github-actions github-actions Bot added the smoke-copilot-network-isolation Copilot network-isolation egress smoke test label Nov 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Warning

Threat detection engine error

Threat detection could not complete its analysis due to a tooling error. This is not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs to troubleshoot the error.

Smoke Test: Copilot BYOK (Direct Mode) ✅

Results:

Status: PASS — Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY) via api-proxy sidecar.

/cc @lpcox

🔑 BYOK report filed by Smoke Copilot BYOK
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

📡 OTel tracing smoke test: PR #12000

  • ✅ 1. Module loading: containers/api-proxy/otel.js loads, isEnabled: true. Exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, routerCallTracing, shutdown, isEnabled (plus _-prefixed test hooks).
  • ⚠️ 2. Test suite: 75/75 pass across 3 suites (otel, otel-fanout, otel-workload-identity) when run with --testPathPatterns. The workflow's --testPathPattern flag is rejected by Jest 30, and || true hides the error, so no tests actually run.
  • ✅ 3. Env forwarding: GITHUB_AW_OTEL_TRACE_ID and GITHUB_AW_OTEL_PARENT_SPAN_ID are in src/services/agent-environment/env-passthrough.ts. GH_AW_OTLP_ENDPOINTS, OTEL_EXPORTER_OTLP_ENDPOINT, and the trace IDs are in src/services/api-proxy-env-config.ts.
  • ✅ 4. Token tracker: onUsage hook present in containers/api-proxy/token-tracker-http.js.
  • ❌ 5. Diagnostics: /tmp/gh-aw/sandbox/firewall/logs/api-proxy/otel.jsonl does not exist. /tmp/gh-aw/otel.jsonl has 1 span (gh-aw.agent.setup) and no api-proxy request span.

Filed an issue for items 2 and 5. Docker image build was not re-run locally (Docker-in-Docker is unsupported here).

📡 OTel tracing validated by Smoke OTel Tracing
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Version Comparison

Runtime Host Version Chroot Version Match?
Python Python 3.12.16 Python 3.12.16 ✅ YES
Node.js v24.22.3 v2.98.0 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Result: FAILED (ALL_TESTS_PASSED=false). The smoke-chroot label was not added.

The Node.js mismatch needs investigation. v2.98.0 is not a Node.js version format, so the node resolved inside the chroot is probably a different binary than the host's Node.js 24.22.3.

Tested by Smoke Chroot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Warning

Threat detection engine error

Threat detection could not complete its analysis due to a tooling error. This is not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs to troubleshoot the error.

Services smoke test: ✅ Redis PONG, ✅ pg_isready accepting connections, ✅ SELECT 1 = 1. PASS

🔌 Service connectivity validated by Smoke Services
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Warning

Threat detection engine error

Threat detection could not complete its analysis due to a tooling error. This is not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs to troubleshoot the error.

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia ✅ 1/1 passed ✅ PASS
Bun hono ✅ 1/1 passed ✅ PASS
C++ fmt ✅ N/A ✅ PASS
C++ json ✅ N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world ✅ N/A (run OK) ✅ PASS
.NET json-parse ✅ N/A (run OK) ✅ PASS
Go color ✅ 1/1 passed ✅ PASS
Go env ✅ 1/1 passed ✅ PASS
Go uuid ✅ 1/1 passed ✅ PASS
Java gson ✅ 1/1 passed ✅ PASS
Java caffeine ✅ 1/1 passed ✅ PASS
Node.js clsx ✅ 1/1 suite ("All tests passed!") ✅ PASS
Node.js execa ✅ 1/1 suite ("All tests passed!") ✅ PASS
Node.js p-limit ✅ 1/1 suite ("All tests passed!") ✅ PASS
Rust fd ✅ 1/1 passed ✅ PASS
Rust zoxide ✅ 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — PASS

Environment workarounds (test code unchanged; TLS verification stayed on):

  • .NET: the first run failed because /run/user/1001 doesn't exist on the runner. Re-ran with XDG_RUNTIME_DIR set to a private temp dir.
  • Java: ~/.m2 is root-owned, so Maven used -Dmaven.repo.local in a temp dir. The JDK cacerts symlink is dangling (no trust anchors), so Maven used a truststore built from the system CA bundle.
  • Node.js: the suites print "All tests passed!" without per-test counts, so the table shows suite-level results.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • 169.254.169.254

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "169.254.169.254"

See Network Configuration for more information.

Generated by Build Test Suite for #12000 · copilot · routed: haiku55 xhigh · ~4 AIC · ⊞ 6.1K · ◷
Add label ready-for-aw to run again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants