Skip to content

Enforce AWF domain policy on Codex hosted web search - #8945

Merged
lpcox merged 6 commits into
mainfrom
copilot/enforce-awf-domain-policy
Sep 24, 2026
Merged

lpcox merged 6 commits into
mainfrom
copilot/enforce-awf-domain-policy

Conversation

Copilot AI commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex hosted search runs outside AWF’s network boundary, bypassing Squid domain enforcement. This adds fail-closed policy enforcement for OpenAI Responses web-search tools and /v1/alpha/search.

  • Configuration

    • Adds the closed apiProxy.hostedWeb.codex contract.
    • Shares normalization and validation with Claude policy.
    • Preserves JSON/YAML file and stdin parity.
  • Proxy enforcement

    • Injects or narrows request-level allowlists and blocklists.
    • Enforces per-query domain scopes and literal URL hosts.
    • Validates access modes and clamps Responses max_uses.
    • Rejects unsupported standalone limits and unknown request shapes.
    • Leaves ordinary OpenAI requests unchanged.
  • Security

    • Treats configured policy as an immutable upper bound.
    • Keeps sensitive network domains out of provider requests.
    • Returns stable errors without exposing prompts, queries, URLs, or bodies.
  • Documentation

    • Documents precedence, cross-mode behavior, route coverage, limits, compatibility, and error codes.
apiProxy:
  hostedWeb:
    codex:
      enabled: true
      allowedDomains:
        - docs.github.com
        - nodejs.org
      maxUses: 5

Copilot AI changed the title [WIP] Add AWF domain policy enforcement for Codex hosted web search Enforce AWF domain policy on Codex hosted web search Sep 24, 2026
Copilot AI requested a review from lpcox September 24, 2026 01:40
@lpcox
lpcox marked this pull request as ready for review September 24, 2026 01:41
Copilot AI balanced review requested due to automatic review settings September 24, 2026 01:41

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

Critical image-packaging and URL-policy bypass issues remain, along with request-validation and schema inconsistencies.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 2 High severity · 2 Medium severity

Open (4)
What changed in this PR

Adds config-driven Codex hosted-web policy enforcement for OpenAI Responses tools and /v1/alpha/search.

Changes:

  • Adds shared policy configuration, normalization, schemas, and documentation.
  • Enforces domain filters, URL hosts, access modes, and usage limits.
  • Adds unit and proxy integration coverage.
File Description
src/​types/​api-proxy-diagnostics-options.ts Adds Codex policy typing.
src/​services/​api-proxy-env-config.ts Serializes normalized policy.
src/​hosted-web-policy.ts Provides shared policy validation.
src/​config-mapper.ts Maps Codex configuration.
src/​config-file.ts Adds Codex configuration shape.
src/​commands/​build-config.ts Includes Codex policy in runtime configuration.
src/​codex-hosted-web-policy.ts Adds Codex normalization.
src/​codex-hosted-web-policy.test.ts Tests configuration and environment behavior.
src/​claude-hosted-web-policy.ts Uses shared normalization.
src/​awf-config-schema.json Adds runtime schema support.
README.md Documents hosted-web policy support.
docs/​awf-config.schema.json Updates the published schema.
docs/​awf-config-spec.md Defines Codex policy behavior.
docs/​api-proxy-sidecar.md Documents sidecar enforcement.
containers/​api-proxy/​server.models.test.js Tests transform context propagation.
containers/​api-proxy/​proxy-utils.js Forwards context through transforms.
containers/​api-proxy/​providers/​openai.js Installs Codex enforcement.
containers/​api-proxy/​hosted-web-policy.js Adds shared sidecar policy utilities.
containers/​api-proxy/​codex-hosted-web.test.js Tests enforcement logic.
containers/​api-proxy/​codex-hosted-web.server.test.js Tests proxy integration.
containers/​api-proxy/​codex-hosted-web.js Implements Codex policy enforcement.
containers/​api-proxy/​claude-hosted-web.js Uses shared sidecar utilities.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@@ -1,5 +1,7 @@
'use strict';

const { isValidDomain, parseHostedWebPolicy } = require('./hosted-web-policy');
}

function checkLiteralUrl(value, filters) {
if (typeof value !== 'string' || !value.includes('://')) return;
'Codex standalone hosted search cannot enforce the configured maxUses limit.',
);
}
if (!body || typeof body !== 'object' || Array.isArray(body)) {
]
},
"codex": {
"$ref": "#/properties/apiProxy/properties/hostedWeb/properties/claude",
@lpcox

lpcox commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

Copilot AI commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback

Addressed the review feedback in a9e935c. Targeted API-proxy and schema tests pass; CodeQL reported no alerts.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

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

@github-actions

github-actions Bot commented Sep 24, 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-8945 artifact from the workflow run
  2. Unzip and open index.html in your browser

Built from commit a432154

@lpcox

lpcox commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Copilot AI commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix the build and lint ci check errors https://github.com/github/gh-aw-firewall/actions/runs/35945075766/job/107461593961?pr=8945

Fixed in the latest commit. The API-proxy test failure was caused by STANDALONE_FIELDS (added in a9e935c to reject unknown top-level fields) not including the legitimate id and model fields sent in /v1/alpha/search requests, so valid requests were rejected with codex_hosted_web_shape_invalid. Added id and model to the allowlist; the full containers/api-proxy suite (1911 tests), root lint, and build now pass locally.

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Smoke Cloud Hypervisor completed. Cloud Hypervisor + Copilot passed.

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • example.com
  • github.com

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

network:
  allowed:
    - defaults
    - "example.com"
    - "github.com"

See Network Configuration for more information.

Cloud Hypervisor + Copilot smoke test by Smoke Cloud Hypervisor

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • api.github.com
  • example.com

[!TIP]
api.github.com is blocked because GitHub API access uses the built-in GitHub tools by default. Instead of adding api.github.com to network.allowed, use tools.github.mode: gh-proxy for direct pre-authenticated GitHub CLI access without requiring network access to api.github.com:

tools:
  github:
    mode: gh-proxy

See GitHub Tools for more information on gh-proxy mode.

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

network:
  allowed:
    - defaults
    - "api.github.com"
    - "example.com"

See Network Configuration for more information.

🛡️ Egress verdict from Smoke Copilot Network Isolation

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation...

Warning

Firewall blocked 11 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • api.github.com
  • clients2.google.com
  • collector.github.com
  • contentautofill.googleapis.com
  • github.com
  • github.githubassets.com
  • msfeed25.pkgs.visualstudio.com
  • update.googleapis.com
  • www.google.com
  • www.gstatic.com

[!TIP]
api.github.com is blocked because GitHub API access uses the built-in GitHub tools by default. Instead of adding api.github.com to network.allowed, use tools.github.mode: gh-proxy for direct pre-authenticated GitHub CLI access without requiring network access to api.github.com:

tools:
  github:
    mode: gh-proxy

See GitHub Tools for more information on gh-proxy mode.

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

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "api.github.com"
    - "clients2.google.com"
    - "collector.github.com"
    - "contentautofill.googleapis.com"
    - "github.com"
    - "github.githubassets.com"
    - "msfeed25.pkgs.visualstudio.com"
    - "update.googleapis.com"
    - "www.google.com"
    - "www.gstatic.com"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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

Warning

Firewall blocked 1 domain

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

  • o205451.ingest.us.sentry.io

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

network:
  allowed:
    - defaults
    - "o205451.ingest.us.sentry.io"

See Network Configuration for more information.

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

🔌 Service connectivity validated by Smoke Services

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

❌ Security Guard failed. Please review the logs for details.

Generated by Security Guard for #8945

@github-actions

github-actions Bot commented Sep 24, 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 Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ Smoke Claude passed

Warning

Firewall blocked 1 domain

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

  • api.anthropic.com

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

network:
  allowed:
    - defaults
    - "api.anthropic.com"

See Network Configuration for more information.

Generated by Smoke Claude for #8945

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Cloud Hypervisor + Copilot

Check Result
1. List merged PRs (gh-aw-firewall) PASS
2. curl https://github.com -> 200/301 PASS (200)
3. Write/read unique file in /tmp/gh-aw/agent/ PASS
4. curl (example.com/redacted) blocked (000/403) PASS (000, connection timeout)

Overall: PASS - firewall correctly allowed GitHub and blocked example.com.

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • example.com
  • github.com

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

network:
  allowed:
    - defaults
    - "example.com"
    - "github.com"

See Network Configuration for more information.

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

@github-actions

Copy link
Copy Markdown
Contributor

@lpcox Smoke test: Copilot Network Isolation Egress Enforcement

EGRESS_RESULT allow=pass deny=pass

✅ Allowed domain (github.com) reachable (HTTP 200)
✅ Blocked domain (example.com) denied

Overall: PASS

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • api.github.com
  • example.com

[!TIP]
api.github.com is blocked because GitHub API access uses the built-in GitHub tools by default. Instead of adding api.github.com to network.allowed, use tools.github.mode: gh-proxy for direct pre-authenticated GitHub CLI access without requiring network access to api.github.com:

tools:
  github:
    mode: gh-proxy

See GitHub Tools for more information on gh-proxy mode.

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

network:
  allowed:
    - defaults
    - "api.github.com"
    - "example.com"

See Network Configuration for more information.

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

@github-actions github-actions Bot added smoke-copilot-network-isolation Copilot network-isolation egress smoke test smoke-copilot-byok labels Sep 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

smoke-copilot-byok: PASS ✅

  1. GitHub MCP: ✅ Connected (fetched merged PRs)
  2. github.com: ✅ HTTP 200
  3. File I/O: ✅ Read successful
  4. BYOK Inference: ✅ Direct mode active (COPILOT_PROVIDER_API_KEY → api-proxy → api.githubcopilot.com)

Running in direct BYOK mode via api-proxy sidecar.

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot Engine — @lpcox

  • ✅ GitHub MCP connectivity
  • ✅ github.com connectivity (HTTP 200)
  • ✅ File write/read test

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: Claude Engine Validation

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

Overall result: PASS

Warning

Firewall blocked 1 domain

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

  • api.anthropic.com

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

network:
  allowed:
    - defaults
    - "api.anthropic.com"

See Network Configuration for more information.

Generated by Smoke Claude for #8945 · claude · haiku45 · 55.8 AIC · ⊞ 4.7K · ◷
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Services Connectivity Smoke Test

  • Redis PING: ✅ (PONG)
  • Postgres pg_isready: ✅ (accepting connections)
  • Postgres SELECT 1: ✅ (1)

Overall: PASS

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

@lpcox
lpcox deployed to aoai-model September 24, 2026 02:33 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

Gemini Engine Validation Smoke Test Results

Overall Status: PASS

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • github.com
  • play.googleapis.com

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

network:
  allowed:
    - defaults
    - "github.com"
    - "play.googleapis.com"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.14 Python 3.12.14 ✅ YES
Node.js v24.21.0 v22.23.2 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

⚠️ Not all versions matched (Node.js differs between host and chroot environment), so the smoke-chroot label was not added.

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

@github-actions

Copy link
Copy Markdown
Contributor

📡 Smoke Test Results: API Proxy OTel Tracing

Scenario Result
1. Module Loading ✅ otel.js loaded; isEnabled() → true; exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled, plus internal exporter/parsing helpers
2. Test Suite ✅ 68/68 tests passed across otel.test.js, otel-fanout.test.js, otel-workload-identity.test.js. Note: the workflow's own Run api-proxy OTEL tests step used the deprecated --testPathPattern CLI flag (rejected by installed Jest 30, masked by || true); re-ran with --testPathPatterns to get real results
3. Env Var Forwarding ✅ env-passthrough.ts forwards GITHUB_AW_OTEL_TRACE_ID/GITHUB_AW_OTEL_PARENT_SPAN_ID to the agent; api-proxy-env-config.ts forwards GH_AW_OTLP_ENDPOINTS, OTEL_EXPORTER_OTLP_ENDPOINT, and the trace context to api-proxy
4. Token Tracker Integration ✅ onUsage callback present in token-tracker-http.js as the OTEL hook point
5. OTLP Export ✅ Live export confirmed: Squid access log shows 17 successful CONNECT/TCP_TUNNEL requests from the api-proxy container (172.30.0.30) to o205451.ingest.us.sentry.io:443 during this run (real OTLP endpoint configured via secrets, so the local otel.jsonl fallback file was not used — that's expected/correct behavior)

Overall: all 5 scenarios pass. One minor finding: the workflow step "Run api-proxy OTEL tests" silently produces no real signal due to an outdated Jest CLI flag — worth updating to --testPathPatterns so future regressions in these 68 tests aren't masked by || true.

Warning

Firewall blocked 1 domain

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

  • o205451.ingest.us.sentry.io

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

network:
  allowed:
    - defaults
    - "o205451.ingest.us.sentry.io"

See Network Configuration for more information.

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

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ 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 ✅ PASS
.NET json-parse ✅ N/A ✅ PASS
Go color ✅ ok ✅ PASS
Go env ✅ ok ✅ PASS
Go uuid ✅ ok ✅ PASS
Java gson ✅ 1/1 passed ✅ PASS
Java caffeine ✅ 1/1 passed ✅ PASS
Node.js clsx ✅ passed ✅ PASS
Node.js execa ✅ passed ✅ PASS
Node.js p-limit ✅ passed ✅ PASS
Rust fd ✅ 1/1 passed ✅ PASS
Rust zoxide ✅ 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — PASS

Note: Java's initial mvn compile/test run failed with Could not create local repository at /home/runner/.m2/repository because ~/.m2 is owned by root (not writable by the runner user) in this sandbox. Re-running with -Dmaven.repo.local=/tmp/gh-aw/agent/m2-repo succeeded for both gson and caffeine, confirming the firewall/proxy configuration itself was not the cause. This is an environment permissions quirk unrelated to AWF's egress filtering — flagging in case CI runners hit the same ~/.m2 ownership issue.

All other ecosystems (Bun, C++, Deno, .NET, Go, Node.js, Rust) built and passed on the first attempt with no errors.

Warning

Firewall blocked 8 domains

The following domains were blocked by the firewall during workflow execution:

  • api.nuget.org
  • bun.sh
  • dc.services.visualstudio.com
  • deno.land
  • dl.deno.land
  • github.com
  • releaseassets.githubusercontent.com
  • repo.maven.apache.org

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

network:
  allowed:
    - defaults
    - "api.nuget.org"
    - "bun.sh"
    - "dc.services.visualstudio.com"
    - "deno.land"
    - "dl.deno.land"
    - "github.com"
    - "releaseassets.githubusercontent.com"
    - "repo.maven.apache.org"

See Network Configuration for more information.

Generated by Build Test Suite for #8945 · copilot · auto · 39.6 AIC · ⊞ 11.8K · ◷
Add label ready-for-aw to run again

@lpcox
lpcox merged commit 2343346 into main Sep 24, 2026
147 of 153 checks passed
@lpcox
lpcox deleted the copilot/enforce-awf-domain-policy branch September 24, 2026 03:00

This branch was successfully deployed

1 active deployment
aoai-model — a46c8916 Deployed Sep 24, 2026 by lpcox via conclusion #1756
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.

Enforce AWF domain policy on Codex hosted web search (blocked on Claude support)

3 participants