Skip to content

Auto-allow topology-attached container hostnames in Squid ACL#6473

Merged
lpcox merged 4 commits into
mainfrom
copilot/fix-firewall-blocking-awfmcpg
Jul 21, 2026
Merged

Auto-allow topology-attached container hostnames in Squid ACL#6473
lpcox merged 4 commits into
mainfrom
copilot/fix-firewall-blocking-awfmcpg

Conversation

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

In network-isolation mode, topology-attached containers (e.g. awmg-mcpg) were added to NO_PROXY so proxy-aware clients bypass Squid. But tools that honour HTTP(S)_PROXY while ignoring NO_PROXY still route requests through Squid — which blocked them, since the container hostname wasn't in the allowed-domain ACL. This is the last-mile fix for the NO_PROXY-based series (#6189, #6438, #6401) that resolved #6467.

Changes

  • src/commands/preflight.ts — In resolveAllowedDomains(), when network-isolation is active, topology peer hostnames are auto-appended to allowedDomains (deduplicated, with a debug log) so Squid permits them for NO_PROXY-ignoring proxy clients. This pairs with the existing NO_PROXY addition in proxy-environment.ts.

    The gating and peer set now mirror buildProxyEnvironment() exactly:

    • Runtime gating — addition is gated on runtimeUsesComposeAgent() in addition to networkIsolation. microVM backends (Docker sbx) run the agent off awf-net and reach peers via their own proxy-chaining path, so topology hostnames are skipped there too, keeping the ACL and NO_PROXY code paths consistent.
    • DIFC/cli-proxy hostdifcProxyHost is also auto-allowed through Squid (scheme/port stripped via parseDifcProxyHost), mirroring the NO_PROXY entry added in fix: exempt DIFC/cli-proxy host from proxy routing in isolation mode #6438, so it isn't silently blocked for NO_PROXY-ignoring clients.
    • Squid semantics documented — these names are emitted as dstdomain entries via formatDomainForSquid, which prepends a leading dot (awmg-mcpg.awmg-mcpg), matching the host and its subdomains. Safe for internal Docker hostnames (a bare label like github matches host github, not github.com); operators should avoid topology names that collide with trusted public labels.
  • src/commands/preflight.test.ts — Unit tests covering: auto-add when isolation is on, no-op when isolation is off, no duplication if already listed, no-op for empty attach list, skip for a non-compose runtime (sbx), add for an explicit compose runtime (runc), and difcProxyHost auto-allow when not listed in topologyAttach.

// Before: awmg-mcpg blocked by Squid → TCP_DENIED in access log
// After:  awmg-mcpg auto-added to allowedDomains → allowed through Squid
resolveAllowedDomains({
  networkIsolation: true,
  containerRuntime: 'runc',
  topologyAttach: ['awmg-mcpg'],
});
// result.allowedDomains includes 'awmg-mcpg'

Copilot AI linked an issue Jul 21, 2026 that may be closed by this pull request
In network-isolation mode, topology-attached containers (e.g. awmg-mcpg)
are already added to NO_PROXY so proxy-aware clients connect to them
directly. However, tools that honour HTTP(S)_PROXY but ignore NO_PROXY
route those requests through Squid, which blocks them because the
container hostname is not in the allowed-domain ACL.

Fix: in resolveAllowedDomains(), when networkIsolation is true and
topologyAttach container names are present, automatically add each name
to allowedDomains so Squid permits those requests.
Copilot AI changed the title [WIP] Fix firewall reports blocking awfmcpg issue Auto-allow topology-attached container hostnames in Squid ACL Jul 21, 2026
Copilot AI requested a review from lpcox July 21, 2026 12:39
Copilot finished work on behalf of lpcox July 21, 2026 12:39
@lpcox
lpcox marked this pull request as ready for review July 21, 2026 13:44
Copilot AI review requested due to automatic review settings July 21, 2026 13:44

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.

Pull request overview

Adds topology-attached container hostnames to Squid’s allowlist in network-isolation mode.

Changes:

  • Automatically appends and deduplicates topology peer names.
  • Adds unit tests for enabled, disabled, duplicate, and empty cases.
  • However, Squid still cannot resolve these names or access common nonstandard ports.
Show a summary per file
File Description
src/commands/preflight.ts Adds topology peer hostnames to allowed domains.
src/commands/preflight.test.ts Tests hostname auto-add behavior.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Medium

Comment thread src/commands/preflight.ts Outdated
if (options.networkIsolation && Array.isArray(options.topologyAttach)) {
for (const containerName of options.topologyAttach as string[]) {
if (!allowedDomains.includes(containerName)) {
allowedDomains.push(containerName);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — fixed in 9de869d. patchComposeWithTopologyHosts now also patches the squid-proxy service extra_hosts with the discovered peer name→IP mappings. Squid consults /etc/hosts (its default hosts_file) before falling back to dns_nameservers, so it can now resolve Docker-only names like awmg-mcpg. The phased startup applies this patch during onNetworkReady (before the full docker compose up), which recreates squid-proxy so it picks up the new hosts entries. Added a unit test asserting the squid-proxy service gets the entries.

Comment thread src/commands/preflight.ts Outdated
for (const containerName of options.topologyAttach as string[]) {
if (!allowedDomains.includes(containerName)) {
allowedDomains.push(containerName);
logger.debug(`Network-isolation: auto-allowing topology peer "${containerName}" in Squid ACL`);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9de869d. Added a dedicated SquidConfig.topologyPeers that emits a per-peer http_access allow (dstdomain) placed before the deny !Safe_ports and raw-IP deny rules, so trusted topology peers are reachable on any port (e.g. http://awmg-mcpg:8080). This mirrors the existing apiProxyIp/apiProxyPorts precedent and is narrowly scoped by dstdomain to the exact peer hostnames, so it does not widen access to arbitrary destinations. Since these peers are operator-attached and already directly reachable via NO_PROXY, allowing any port to them through Squid keeps the same trust level. Added tests asserting the allow rule is generated and ordered before both the Safe_ports and raw-IP denies.

Address review feedback on auto-allowing topology peers in the Squid ACL:

- Gate the ACL addition on runtimeUsesComposeAgent() in addition to
  networkIsolation, mirroring buildProxyEnvironment() exactly. microVM
  backends (Docker sbx) run the agent off awf-net and reach peers via
  their own proxy-chaining path, so topology hostnames are skipped there
  too, keeping the ACL and NO_PROXY code paths consistent.
- Also auto-allow the DIFC/cli-proxy host (difcProxyHost) through Squid,
  mirroring the NO_PROXY entry added in #6438, so NO_PROXY-ignoring proxy
  clients can reach it. The scheme/port are stripped via parseDifcProxyHost.
- Document Squid dstdomain wildcard semantics (formatDomainForSquid
  prepends a leading dot, matching the host and its subdomains).
- Add tests: non-compose runtime skip, explicit compose runtime add, and
  difcProxyHost auto-allow.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5f6caa3b-9079-4d7f-a752-524b0f990e0c
@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 Jul 21, 2026

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 98.74% 98.78% 📈 +0.04%
Statements 98.69% 98.72% 📈 +0.03%
Functions 99.28% 99.29% 📈 +0.01%
Branches 94.95% 94.96% ➡️ +0.01%
📁 Per-file Coverage Changes (3 files)
File Lines (Before → After) Statements (Before → After)
src/config-writer.ts 95.1% → 95.1% (+0.04%) 95.1% → 95.1% (+0.04%)
src/topology.ts 98.8% → 98.9% (+0.10%) 98.8% → 98.9% (+0.08%)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)
✨ New Files (1 files)
  • src/topology-peers.ts: 100.0% lines

Coverage comparison generated by scripts/ci/compare-coverage.ts

Address reviewer feedback that adding topology peer hostnames to the
domain allowlist alone does not make them reachable through Squid:

1. DNS: Squid resolves proxied destinations via external `dns_nameservers`,
   which cannot resolve Docker-only peer names (e.g. `awmg-mcpg`).
   `patchComposeWithTopologyHosts` now also patches the `squid-proxy`
   service `extra_hosts` (Squid reads /etc/hosts before DNS). The phased
   startup applies this before the full `docker compose up`, which recreates
   squid-proxy to pick up the entries.

2. Ports: `http_access deny !Safe_ports` (80/443) fires before the domain
   allowlist, so `http://awmg-mcpg:8080` was denied on the port. A new
   `SquidConfig.topologyPeers` emits a per-peer `http_access allow`
   (dstdomain) *before* the Safe_ports and raw-IP deny rules, permitting any
   port to these operator-attached, trusted peers. This mirrors the existing
   apiProxyIp/apiProxyPorts precedent.

Also extract `resolveTopologyPeerHosts()` (topology-peers.ts) shared by
preflight (domain ACL) and config-writer (Squid allow), so the peer set and
compose-runtime gating stay in sync with buildProxyEnvironment().

Tests: topology-peers helper, Squid topology-peer section + rule ordering,
and squid-proxy extra_hosts patching. Full suite: 3986 passing.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5f6caa3b-9079-4d7f-a752-524b0f990e0c
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

Smoke test completed. Connectivity and MCP tests failed. File writing and bash verification passed.

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Contribution Check failed. Please review the logs for details.

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

Copy link
Copy Markdown
Contributor

🔥 AWF Smoke Test — Copilot Network Isolation

@lpcox

EGRESS_RESULT allow=pass deny=pass

  • ✅ Allowed domain (api.github.com): HTTP 200
  • ✅ Blocked domain (example.com): connection denied (403 from proxy)

Overall: PASS

Warning

Firewall blocked 1 domain

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

  • example.com

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

network:
  allowed:
    - defaults
    - "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 the smoke-copilot-network-isolation Copilot network-isolation egress smoke test label Jul 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results — Services Connectivity

  • Redis PING: ❌ (host.docker.internal DNS resolution failed)
  • PostgreSQL pg_isready: ❌ (no response)
  • PostgreSQL SELECT 1: ❌ (DNS resolution failed)

Overall: FAILhost.docker.internal is not resolvable in this environment. The AWF sandbox cannot reach GitHub Actions service containers.

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results: Copilot BYOK (Direct Mode) ✅

  • ✅ GitHub MCP: Connected (filtered by secrecy policy)
  • ✅ GitHub.com: HTTP 200
  • ✅ File I/O: Read/write working
  • ✅ BYOK Inference: Direct mode active → api-proxy → api.githubcopilot.com

Status: PASS — Agent verified in direct BYOK mode with inference connectivity confirmed.

🔑 BYOK report filed by Smoke Copilot BYOK
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.13 Python 3.12.13
Node.js v24.18.0 v24.18.0
Go go1.22.12 go1.22.12

All runtimes match between host and chroot environments.

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

@github-actions

Copy link
Copy Markdown
Contributor

🔬 Smoke Test: Copilot PAT Auth — PR #6473

Test Result
GitHub MCP connectivity ✅ Connected (secrecy policy active)
GitHub.com HTTP ✅ 200 OK
File write/read ⚠️ Template vars unresolved (pre-step data unavailable)

Overall: PARTIAL — core connectivity PASS; pre-computed data not injected.

Auth mode: PAT (COPILOT_GITHUB_TOKEN)

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

@github-actions

Copy link
Copy Markdown
Contributor

@lpcox

  • GitHub MCP: ✅
  • github.com: ✅
  • File I/O: ✅
  • BYOK inference: ✅

Running in direct BYOK mode (AWF_AUTH_TYPE=github-oidc + AWF_AUTH_AZURE_* + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) via Microsoft Entra

Overall: PASS

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)
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

Generated by Smoke Claude for #6473 · 54.4 AIC · ⊞ 3.3K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smoke Test Results

Test Status
GitHub MCP connectivity ✅ Connected
GitHub.com HTTP ⚠️ Data unavailable (template vars unresolved)
File write/read ⚠️ Data unavailable (template vars unresolved)

Overall: PARTIAL — MCP connectivity confirmed; pre-step smoke data was not passed through (workflow template expressions not substituted).

Triggered on PR #6473 by @lpcox

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: API Proxy OpenTelemetry Tracing — Results

Scenario Status Notes
1. Module Loading otel.js loads; exports startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled + internal helpers
2. Test Suite 59/59 tests pass across 2 suites (otel.test.js, otel-fanout.test.js)
3. Env Var Forwarding api-proxy-service-config.ts forwards OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, GITHUB_AW_OTEL_TRACE_ID, GITHUB_AW_OTEL_PARENT_SPAN_ID, OTEL_SERVICE_NAME
4. Token Tracker onUsage onUsage callback exists in token-tracker-http.js (line 343) as the OTEL hook point
5. OTEL Diagnostics Trace context present in run env (GITHUB_AW_OTEL_TRACE_ID, GITHUB_AW_OTEL_PARENT_SPAN_ID); isEnabled() returns true

All scenarios pass. OTEL tracing integration is working correctly.

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results: Gemini

  • GitHub MCP Testing: ❌ (Unable to reach GitHub/Tools not found)
  • GitHub.com Connectivity: ❌ (HTTP 000)
  • File Writing Testing: ✅
  • Bash Tool Testing: ✅

Merged PRs reviewed:

Overall Status: FAIL

Warning

Firewall blocked 1 domain

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

  • localhost

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

network:
  allowed:
    - defaults
    - "localhost"

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

@lpcox

  • List merged PRs: ✅
  • GitHub.com connectivity: ✅
  • Agent file I/O: ✅
  • BYOK inference: ✅

Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw)

Overall: PASS

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)
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 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 all passed ✅ PASS
Node.js execa all passed ✅ PASS
Node.js p-limit all passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for #6473 · 42.3 AIC · ⊞ 8.3K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Merged PRs:

  • Expose RHEL/Amazon Linux CA roots in chroot mode
  • fix(docs-site): migrate to astro v6 content collections config

Checks:

  • GitHub PR list ✅
  • GitHub.com title ✅
  • Temp file ✅
  • npm ci && npm run build
  • Discussion comment ❌

Overall: FAIL

Warning

Firewall blocked 1 domain

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

  • registry.npmjs.org

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

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results — Docker Sbx

Test Status
GitHub MCP connectivity ✅ PASS (response received)
GitHub.com HTTP ⚠️ N/A (template vars unresolved)
File write/read ⚠️ N/A (template vars unresolved)

Overall: PARTIAL — MCP connectivity verified; pre-step data was not substituted (template variables literal in prompt).

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

@lpcox
lpcox merged commit b798aca into main Jul 21, 2026
142 of 144 checks passed
@lpcox
lpcox deleted the copilot/fix-firewall-blocking-awfmcpg branch July 21, 2026 16:47
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.

firewall reports blocking awfmcpg

3 participants