Skip to content

Commit 10c59d3

Browse files
Mossakaclaude
andcommitted
fix: remove lowercase http_proxy to prevent HTTP forward-proxy bypass
Some curl builds (Ubuntu 22.04) ignore uppercase HTTP_PROXY for HTTP URLs as an httpoxy mitigation. This means HTTP traffic correctly falls through to iptables DNAT interception where Squid blocks at the connection level. Setting lowercase http_proxy causes curl to use the forward proxy, where Squid's 403 error page returns exit code 0 — breaking security expectations. Only https_proxy (lowercase) is needed for Yarn 4/undici/Corepack compatibility since these tools connect to registries via HTTPS. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 07dad56 commit 10c59d3

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/docker-manager.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,20 +490,20 @@ describe('docker-manager', () => {
490490

491491
expect(env.HTTP_PROXY).toBe('http://172.30.0.10:3128');
492492
expect(env.HTTPS_PROXY).toBe('http://172.30.0.10:3128');
493-
expect(env.http_proxy).toBe('http://172.30.0.10:3128');
494493
expect(env.https_proxy).toBe('http://172.30.0.10:3128');
495494
expect(env.SQUID_PROXY_HOST).toBe('squid-proxy');
496495
expect(env.SQUID_PROXY_PORT).toBe('3128');
497496
});
498497

499-
it('should set lowercase proxy env vars for Yarn 4 and Corepack compatibility', () => {
498+
it('should set lowercase https_proxy for Yarn 4 and Corepack compatibility', () => {
500499
const result = generateDockerCompose(mockConfig, mockNetworkConfig);
501500
const agent = result.services.agent;
502501
const env = agent.environment as Record<string, string>;
503502

504503
// Yarn 4 (undici), Corepack, and some Node.js HTTP clients only check lowercase
505-
expect(env.http_proxy).toBe(env.HTTP_PROXY);
506504
expect(env.https_proxy).toBe(env.HTTPS_PROXY);
505+
// http_proxy is intentionally NOT set - see comment in docker-manager.ts
506+
expect(env.http_proxy).toBeUndefined();
507507
});
508508

509509
it('should set NODE_EXTRA_CA_CERTS when SSL Bump is enabled', () => {

src/docker-manager.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,12 @@ export function generateDockerCompose(
343343
const environment: Record<string, string> = {
344344
HTTP_PROXY: `http://${networkConfig.squidIp}:${SQUID_PORT}`,
345345
HTTPS_PROXY: `http://${networkConfig.squidIp}:${SQUID_PORT}`,
346-
// Lowercase variants for tools that only check lowercase (e.g., Yarn 4/undici, Corepack)
347-
http_proxy: `http://${networkConfig.squidIp}:${SQUID_PORT}`,
346+
// Lowercase https_proxy for tools that only check lowercase (e.g., Yarn 4/undici, Corepack).
347+
// NOTE: We intentionally do NOT set lowercase http_proxy. Some curl builds (Ubuntu 22.04)
348+
// ignore uppercase HTTP_PROXY for HTTP URLs (httpoxy mitigation), which means HTTP traffic
349+
// falls through to iptables DNAT interception — the correct behavior for connection-level
350+
// blocking. Setting http_proxy would route HTTP through the forward proxy where Squid's
351+
// 403 error page returns exit code 0, breaking security expectations.
348352
https_proxy: `http://${networkConfig.squidIp}:${SQUID_PORT}`,
349353
SQUID_PROXY_HOST: 'squid-proxy',
350354
SQUID_PROXY_PORT: SQUID_PORT.toString(),
@@ -1022,7 +1026,6 @@ export function generateDockerCompose(
10221026
// Route through Squid to respect domain whitelisting
10231027
HTTP_PROXY: `http://${networkConfig.squidIp}:${SQUID_PORT}`,
10241028
HTTPS_PROXY: `http://${networkConfig.squidIp}:${SQUID_PORT}`,
1025-
http_proxy: `http://${networkConfig.squidIp}:${SQUID_PORT}`,
10261029
https_proxy: `http://${networkConfig.squidIp}:${SQUID_PORT}`,
10271030
// Prevent curl health check from routing localhost through Squid
10281031
NO_PROXY: `localhost,127.0.0.1,::1`,

0 commit comments

Comments
 (0)