Skip to content

fix(dns): filter non-portable DNS in network-isolation + Tailscale - #6705

Merged
lpcox merged 3 commits into
mainfrom
copilot/awf-network-isolation-fix
Jul 29, 2026
Merged

fix(dns): filter non-portable DNS in network-isolation + Tailscale#6705
lpcox merged 3 commits into
mainfrom
copilot/awf-network-isolation-fix

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

In network-isolation mode + Tailscale, every Squid CONNECT to api.githubcopilot.com fails with 503 TCP_TUNNEL:HIER_NONE (server field -:-, indicating DNS never resolved). When Tailscale starts as a later workflow step it modifies the host's policy routing table 52 — if a Tailscale exit node or accepted subnet route covers 0.0.0.0/0, Docker bridge traffic on awf-ext follows the from all lookup 52 rule through the Tailscale tunnel. Azure DHCP DNS (168.63.129.16) is Azure-hypervisor-intercepted and unreachable via Tailscale, so all Squid DNS queries black-hole.

Changes

src/dns-resolver.ts — new exports

  • isNonPortableDns(ip) — identifies DNS servers that depend on host-specific routing paths Tailscale can capture: Azure DHCP DNS (168.63.129.16), Tailscale Magic DNS (100.100.100.100), link-local 169.254.x.x
  • filterForNetworkIsolation(servers, logger) — strips non-portable servers with a warning; falls back to 8.8.8.8/8.8.4.4 if all detected servers are non-portable

src/config-writer.ts — apply filter in isolation mode

Before generating squid.conf, apply filterForNetworkIsolation() when config.networkIsolation is true:

const resolvedDnsServers = config.dnsServers ?? DEFAULT_DNS_SERVERS;
const squidDnsServers = config.networkIsolation
  ? filterForNetworkIsolation(resolvedDnsServers, logger)
  : resolvedDnsServers;

Users requiring specific DNS in isolation mode can still override via --dns-servers.

src/dns-resolver.test.ts

15 new unit tests covering portable/non-portable detection, mixed lists, all-non-portable fallback, and RFC1918 corporate DNS passthrough.

Copilot AI changed the title [WIP] Fix 503 TCP_TUNNEL:HIER_NONE error with Tailscale fix(dns): filter non-portable DNS in network-isolation + Tailscale Jul 29, 2026
Copilot finished work on behalf of lpcox July 29, 2026 00:39
Copilot AI requested a review from lpcox July 29, 2026 00:39
@lpcox
lpcox marked this pull request as ready for review July 29, 2026 04:06
Copilot AI review requested due to automatic review settings July 29, 2026 04:06
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Coverage Regression Detected

This PR decreases test coverage. Please add tests to maintain coverage levels.

Overall Coverage

Metric Base PR Delta
Lines 99.10% 99.13% 📈 +0.03%
Statements 98.99% 99.02% 📈 +0.03%
Functions 99.14% 99.14% ➡️ +0.00%
Branches 95.62% 95.61% 📉 -0.01%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/config-writer.ts 95.1% → 95.2% (+0.11%) 95.1% → 95.2% (+0.11%)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)

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

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

Filters host-specific DNS resolvers in network-isolation mode to prevent Tailscale-related Squid DNS failures.

Changes:

  • Detects Azure, Tailscale, and link-local DNS addresses.
  • Falls back to public DNS when necessary.
  • Adds resolver unit tests.
Show a summary per file
File Description
src/dns-resolver.ts Adds DNS classification and filtering.
src/dns-resolver.test.ts Tests filtering behavior.
src/config-writer.ts Applies filtering to Squid configuration.

Review details

Tip

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

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

Comment thread src/config-writer.ts
Comment on lines +330 to +333
const resolvedDnsServers = config.dnsServers ?? DEFAULT_DNS_SERVERS;
const squidDnsServers = config.networkIsolation
? filterForNetworkIsolation(resolvedDnsServers, logger)
: resolvedDnsServers;
Comment thread src/config-writer.ts Outdated
Comment on lines +331 to +333
const squidDnsServers = config.networkIsolation
? filterForNetworkIsolation(resolvedDnsServers, logger)
: resolvedDnsServers;
Comment thread src/config-writer.ts
allowHostPorts: config.allowHostPorts,
enableDlp: config.enableDlp,
dnsServers: config.dnsServers,
dnsServers: squidDnsServers,
@lpcox

lpcox commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

@copilot Fix the code for all comments in this review thread.

When a review comment includes a suggested change, apply the suggestion exactly.

Do not make changes beyond what is described in the linked review thread.

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Fix the code for all comments in this review thread.

When a review comment includes a suggested change, app...

All three review points are addressed in the latest commit (fix(dns): preserve explicit DNS; fix audit manifest and add tests):

  1. Explicit DNS no longer filtered — Added dnsServersExplicit?: boolean to NetworkOptions / WrapperConfig. resolveNetworkConfig now sets it true when --dns-servers (or network.dnsServers in a config file) was supplied, false when auto-detected. The isolation-mode filter guard in config-writer.ts now checks !config.dnsServersExplicit before calling filterForNetworkIsolation, so an operator-specified resolver such as 168.63.129.16 is respected as-is.

  2. Audit manifest reflects enforced DNSwriteAuditArtifacts now accepts squidDnsServers as an optional parameter and uses it (squidDnsServers ?? config.dnsServers) for generatePolicyManifest, so policy-manifest.json reports the servers Squid actually uses rather than the raw detected list.

  3. Config-writer integration testssrc/config-writer-dns-isolation.test.ts (9 tests) verifies: non-portable servers are filtered only when networkIsolation: true + dnsServersExplicit: false; the filtered list reaches both generateSquidConfig and generatePolicyManifest; and explicitly-supplied non-portable servers are never filtered.

Copilot finished work on behalf of lpcox July 29, 2026 05:31
@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.

@lpcox
lpcox enabled auto-merge (squash) July 29, 2026 05:45
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jul 29, 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 29, 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 29, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 29, 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 29, 2026

Copy link
Copy Markdown
Contributor

Contribution Check completed successfully!

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (api-key) reports failed. AOAI BYOK (api-key) mode investigation needed...

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

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

@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 #6705 · haiku45 · 54.5 AIC · ⊞ 3.3K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 99.10% 99.13% 📈 +0.03%
Statements 98.99% 99.02% 📈 +0.03%
Functions 99.14% 99.14% ➡️ +0.00%
Branches 95.62% 95.64% 📈 +0.02%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/config-writer.ts 95.1% → 95.2% (+0.11%) 95.1% → 95.2% (+0.11%)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)

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

@github-actions

Copy link
Copy Markdown
Contributor

@lpcox — Smoke test results for network isolation egress enforcement:

EGRESS_RESULT allow=pass deny=pass
  • ✅ Allowed domain (api.github.com): HTTP 200
  • ✅ Blocked domain (example.com): blocked by proxy (403)

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 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Services Connectivity

Check Result
Redis PING ❌ Name resolution failed for host.docker.internal
PostgreSQL pg_isready ❌ No response
PostgreSQL SELECT 1 ❌ Name resolution failed

Overall: FAILhost.docker.internal is not resolvable in this environment.

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

@github-actions

Copy link
Copy Markdown
Contributor

Looks good overall, but I think this PR still needs a small docs update for the new network-isolation DNS behavior. CONTRIBUTING.md asks contributors to update documentation for new features/behavior changes (Documentation and Pull Request Process sections), and this change adds a new filtering/fallback path that users may want to know about in the README or DNS/network-isolation docs.

The PR description is clear and already references the related issue, and the new tests are in the right place.

Generated by Contribution Check for #6705 · gpt54mini · 3.93 AIC · ⊞ 22.5K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🔬 Smoke Test Results

Test Status
GitHub MCP Connectivity ✅ Connected (secrecy policy filtered data)
GitHub.com HTTP ⚠️ Pre-step data unavailable (template vars unexpanded)
File Write/Read ⚠️ Pre-step data unavailable (template vars unexpanded)

Overall: PARTIAL — MCP connectivity verified; pre-computed test data was not injected (workflow template variables unexpanded).

cc @lpcox

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) — PR #6705

Test Status
GitHub MCP connectivity ✅ (filtered by secrecy policy, but MCP responded)
GitHub.com connectivity ⚠️ Pre-fetched data not available (template vars unresolved)
File write/read ⚠️ Pre-fetched data not available (template vars unresolved)
BYOK inference (api-proxy → api.githubcopilot.com)

Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY) via api-proxy → api.githubcopilot.com.

@lpcox — Overall status: PARTIAL (pre-computed step outputs were not resolved; BYOK inference confirmed working)

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results

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

🔭 Smoke Test: API Proxy OpenTelemetry Tracing

Scenario Result Notes
1. Module Loading otel.js loads successfully; exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled + test helpers
2. Test Suite 39/39 tests passed (otel.test.js) in 1.5s
3. Env Var Forwarding src/services/api-proxy-env-config.ts forwards GH_AW_OTLP_ENDPOINTS, 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 Integration onUsage callback exists in token-tracker-http.js (line 348/406) as the OTEL hook point
5. OTEL Diagnostics Fallback file exporter writes spans to /var/log/api-proxy/otel.jsonl when no OTLP endpoint configured; graceful degradation confirmed

All scenarios pass. OTEL tracing integration is fully functional.

📡 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 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 #6705 · sonnet46 · 33.1 AIC · ⊞ 8.4K ·
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.13 Python 3.12.13 ✅ YES
Node.js v24.18.0 v22.23.1 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Result: ❌ FAILED — Node.js version mismatch (host: v24.18.0, chroot: v22.23.1).

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test

Reviewed: feat(api-proxy): use runtime model metadata and pricing overlays
Reviewed: Deduplicate main-action Jest harness setup across coverage-gap suites
Results: GitHub PRs ✅ | SafeInputs GH CLI ✅ | Playwright ✅ | File ✅ | Discussion ✅ | Build ❌
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 ✅ Connected (2 PRs listed)
GitHub.com HTTP ⚠️ Pre-step output unavailable (template vars not expanded)
File write/read ⚠️ Pre-step output unavailable (template vars not expanded)

Overall: ⚠️ PARTIAL — MCP works, but pre-computed step outputs were not injected into the prompt.

@lpcox — smoke test ran but pre-step outputs (steps.smoke-data.outputs.*) were not substituted. The workflow may need to pass these values differently.

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

@lpcox
lpcox merged commit 7b6a767 into main Jul 29, 2026
136 of 139 checks passed
@lpcox
lpcox deleted the copilot/awf-network-isolation-fix branch July 29, 2026 05:57
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.

[awf] network: isolation/topology mode + Tailscale → Squid 503 TCP_TUNNEL:HIER_NONE on api.githubcopilot.com egress

3 participants