Skip to content

fix: add bare API proxy targets as https:// only to prevent over-broad allowlisting#5130

Merged
lpcox merged 3 commits into
mainfrom
copilot/bare-api-targets-allowlist-fix
Jun 16, 2026
Merged

fix: add bare API proxy targets as https:// only to prevent over-broad allowlisting#5130
lpcox merged 3 commits into
mainfrom
copilot/bare-api-targets-allowlist-fix

Conversation

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Bare custom API proxy targets (e.g. custom.openai.com) were being added to the Squid allowlist as both the raw hostname and https://custom.openai.com. Because bare entries match both HTTP and HTTPS in the Squid ACL, this was broader than intended.

Changes

  • src/api-proxy-config.ts — Collapse the two-pass logic in resolveApiTargetsToAllowedDomains into a single pass:

    • Bare hostnames → added as https://<host> only
    • Explicit http:// targets → preserved as-is (intentional HTTP deployments)
    • Explicit https:// targets → preserved as-is (no double-prefix)
  • src/api-proxy-config-domains.test.ts — Update assertions to verify bare hostnames are not inserted and only the https:// form appears.

  • tests/integration/api-target-allowlist.test.ts — Update debug-message string to match the new log format.

Before/after behaviour:

# Before — both entries added for bare target "custom.openai.com":
allowedDomains = ["custom.openai.com", "https://custom.openai.com"]
#                  ^^^^ matches HTTP *and* HTTPS (too broad)

# After — only the scoped https:// entry:
allowedDomains = ["https://custom.openai.com"]

Explicit http://custom.openai.com inputs are preserved as-is for deployments that intentionally target an HTTP endpoint.

Bare custom API proxy targets (e.g. custom.openai.com) were being
added to the allowed domains list twice: once as the raw hostname and
once as https://custom.openai.com. Because bare entries are treated
as both HTTP and HTTPS by the Squid ACL, this was more permissive than
intended.

This change updates resolveApiTargetsToAllowedDomains so that:
- Bare hostnames are promoted to https:// only
- Explicit http:// targets are preserved as-is (intentional HTTP)
- Explicit https:// targets are preserved as-is (no double-prefix)

Tests and the integration test debug-message assertion are updated to
match the new behaviour.
Copilot AI changed the title [WIP] Fix bare API targets auto-allowlisting as both HTTP and HTTPS fix: add bare API proxy targets as https:// only to prevent over-broad allowlisting Jun 16, 2026
Copilot finished work on behalf of lpcox June 16, 2026 19:01
Copilot AI requested a review from lpcox June 16, 2026 19:01
@lpcox lpcox marked this pull request as ready for review June 16, 2026 19:55
Copilot AI review requested due to automatic review settings June 16, 2026 19:55
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 97.27% 97.31% 📈 +0.04%
Statements 97.15% 97.18% 📈 +0.03%
Functions 98.81% 98.81% ➡️ +0.00%
Branches 91.95% 91.97% 📈 +0.02%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/workdir-setup.ts 92.6% → 94.4% (+1.85%) 92.6% → 94.4% (+1.85%)

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

This PR tightens Squid allowlisting for custom API proxy targets by ensuring bare hostnames are only allowlisted as https://<host> (rather than also allowlisting the bare hostname, which implicitly permits both HTTP and HTTPS).

Changes:

  • Update resolveApiTargetsToAllowedDomains() to normalize API targets in a single pass and promote bare hostnames to https:// only.
  • Adjust unit tests to assert bare hostnames are not inserted into allowedDomains.
  • Update an integration test assertion to match the new debug log message.
Show a summary per file
File Description
src/api-proxy-config.ts Changes API target → allowedDomains normalization to avoid over-broad allowlisting and updates debug logging.
src/api-proxy-config-domains.test.ts Updates assertions so bare hostnames are no longer expected in allowedDomains.
tests/integration/api-target-allowlist.test.ts Updates debug-log string expectation for auto-added API targets.

Copilot's findings

Tip

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

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Comment thread src/api-proxy-config.ts
Comment on lines 382 to +386
for (const target of normalizedApiTargets) {

// Ensure auto-added API targets are explicitly HTTPS to avoid over-broad HTTP+HTTPS allowlisting
const normalizedTarget = /^https?:\/\//.test(target) ? target : `https://${target}`;

if (!allowedDomains.includes(normalizedTarget)) {
allowedDomains.push(normalizedTarget);
debug(`Automatically added API target to allowlist: ${normalizedTarget}`);
debug(`Auto-added API target to allowed domains: ${normalizedTarget}`);
Comment thread src/api-proxy-config.ts
Comment on lines 382 to 384
for (const target of normalizedApiTargets) {

// Ensure auto-added API targets are explicitly HTTPS to avoid over-broad HTTP+HTTPS allowlisting
const normalizedTarget = /^https?:\/\//.test(target) ? target : `https://${target}`;

if (!allowedDomains.includes(normalizedTarget)) {
@lpcox

lpcox commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback and make sure linting tests pass

@github-actions

Copy link
Copy Markdown
Contributor

⏳ Copilot review left inline comments.

@copilot To proceed:

  1. Ask @copilot to address the review feedback (reply to this comment or the review thread)
  2. Once the fix is pushed, add the ready-for-aw label to trigger agentic CI smoke tests

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback and make sure linting tests pass

Both review findings addressed in commit 1c13fbd:

  1. Whitespace trimming (src/api-proxy-config.ts:382-384): target.trim() is now applied before the scheme check and URL construction, so leading/trailing whitespace can't produce entries like https://example.com .

  2. Protocol prefix stripping in validator (src/api-proxy-config.ts:99-103): validateApiTargetInAllowedDomains now strips any https?:// prefix from allowedDomains entries before comparing hostnames. This prevents spurious "not in --allow-domains" warnings when the domain was auto-added as https://custom.example.com by resolveApiTargetsToAllowedDomains.

Tests covering both cases were added; all 95 unit tests pass and lint is clean.

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Contribution Check failed. Please review the logs for details.

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

Testing safeoutputs

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 16, 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 Jun 16, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude failed

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓

@github-actions

github-actions Bot commented Jun 16, 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: PAT Auth — PASS

Test Result
GitHub MCP connectivity
GitHub.com HTTP
File write/read

Auth mode: PAT (COPILOT_GITHUB_TOKEN)
PR: fix: add bare API proxy targets as https:// only to prevent over-broad allowlisting
Author: @Copilot | Assignees: @lpcox @Copilot

🔑 PAT report filed by Smoke Copilot PAT

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

Copy link
Copy Markdown
Contributor

🔬 Smoke Test Results

PR: fix: add bare API proxy targets as https:// only to prevent over-broad allowlisting
Author: @Copilot | Assignees: @lpcox @Copilot

Test Result
GitHub MCP connectivity
GitHub.com HTTP ❌ (pre-computed data unavailable)
File write/read ❌ (pre-computed data unavailable)

Overall: FAIL — pre-step template variables were not resolved (SMOKE_HTTP_CODE, SMOKE_FILE_PATH, SMOKE_FILE_CONTENT)

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

Copy link
Copy Markdown
Contributor

@lpcox @Copilot

fix: add bare API proxy targets as https:// only to prevent over-broad allowlisting

✅ MCP connectivity
✅ HTTP 200 from github.com
✅ File I/O smoke-test
✅ Direct BYOK inference working

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

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Merged PRs: docs: sync schemas and specs with source changes; [Test Coverage] Improve test coverage for network-options, environment-builder, log-parser, workspace-mounts
Queried PRs: fix: add bare API proxy targets as https:// only to prevent over-broad allowlisting; refactor(agent-service): extract resolveAgentImageConfig from buildAgentService
GitHub: ✅
File write: ✅
Discussion: ✅
Build: ❌
Overall: FAIL

🔮 The oracle has spoken through Smoke Codex

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results for Gemini

  • GitHub MCP Testing: ❌ (Read tools not found)
  • GitHub.com Connectivity: ❌ (SSL Error 35)
  • File Writing Testing: ✅
  • Bash Tool Testing: ✅

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

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smoke Test: API Proxy OTEL Tracing — Results

Scenario Status Detail
1. Module Loading otel.js loaded; exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled
2. Test Suite 59/59 tests passed across otel.test.js + otel-fanout.test.js (2 suites, 0 failures)
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 to the api-proxy container
4. Token Tracker Integration onUsage callback exists in token-tracker-http.js (line 324); wired to otel.setTokenAttributes() via upstream-response.js for gen_ai.usage.* span attributes
5. OTLP Export 23 successful POST requests to o205451.ingest.us.sentry.io via Squid proxy (HTTP 200) during this run

All scenarios pass. 🎉

📡 OTel tracing validated by Smoke OTel Tracing

@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 1/1 passed ✅ PASS
Node.js execa 1/1 passed ✅ PASS
Node.js p-limit 1/1 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 issue #5130 ·

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results — FAIL

Check Result
Redis PING ❌ Connection timed out
PostgreSQL pg_isready ❌ No response
PostgreSQL SELECT 1 ❌ No response

host.docker.internal resolves to 172.17.0.1 but ports 6379 and 5432 are unreachable (timeout). Service containers may not be running or network routing to the host is blocked.

🔌 Service connectivity validated by Smoke Services

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct Mode) ✅ PASS

Test Result
1. MCP Connectivity
2. GitHub.com (HTTP 200)
3. File Write/Read
4. BYOK Inference

Mode: Direct BYOK (COPILOT_PROVIDER_API_KEY) → api-proxy sidecar → api.githubcopilot.com

All systems operational.

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Runtime Version Comparison

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.16.0 v22.22.3
Go go1.22.12 go1.22.12

Result: Not all versions match — smoke-chroot label not added.

Tested by Smoke Chroot

@github-actions

Copy link
Copy Markdown
Contributor

@lpcox @Copilot

  • MCP connectivity: ✅
  • GitHub.com HTTP: ✅
  • File write/read: ✅
  • 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) authenticated via Microsoft Entra

Overall: PASS

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)

@lpcox lpcox merged commit 9ec4654 into main Jun 16, 2026
83 of 85 checks passed
@lpcox lpcox deleted the copilot/bare-api-targets-allowlist-fix branch June 16, 2026 21:57
@github-actions github-actions Bot mentioned this pull request Jun 17, 2026
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