Skip to content

Commit 6bcee3e

Browse files
Mossakaclaude
andcommitted
fix: correct URL pattern filtering for SSL Bump mode
Two issues fixed: 1. URL pattern deny rule was blocking CONNECT requests: - The deny rule `http_access deny allowed_domains` was evaluated for CONNECT requests, blocking SSL bump before the URL check - Added `!CONNECT` to only deny actual HTTP requests after bump - CONNECT requests now pass through for domain-allowed hosts 2. URL pattern regex escaping was corrupting .* wildcards: - Input `https://api.github.com/users/.*` was becoming `^https://api\.github\.com/users/\..*` (incorrect) - Now preserves .* patterns using placeholder before escaping - Output is correctly `^https://api\.github\.com/users/.*` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c526c6e commit 6bcee3e

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

src/squid-config.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,24 @@ function generateSslBumpSection(
9393
urlAclSection = `\n# URL pattern ACLs for HTTPS content inspection\n${urlAcls}\n`;
9494

9595
// Build access rules for URL patterns
96+
// When URL patterns are specified, we:
97+
// 1. Allow requests matching the URL patterns
98+
// 2. Deny all other requests to allowed_domains (they didn't match URL patterns)
9699
const urlAccessLines = urlPatterns
97100
.map((_, i) => `http_access allow allowed_url_${i}`)
98101
.join('\n');
99-
urlAccessRules = `\n# Allow HTTPS requests matching URL patterns\n${urlAccessLines}\n`;
102+
103+
// Deny requests to allowed domains that don't match URL patterns
104+
// This ensures URL-level filtering is enforced
105+
// IMPORTANT: Use !CONNECT to only deny actual HTTP requests after bump,
106+
// not the CONNECT request itself (which must be allowed for SSL bump to work)
107+
const denyNonMatching = hasPlainDomains
108+
? 'http_access deny !CONNECT allowed_domains'
109+
: hasPatterns
110+
? 'http_access deny !CONNECT allowed_domains_regex'
111+
: '';
112+
113+
urlAccessRules = `\n# Allow HTTPS requests matching URL patterns\n${urlAccessLines}\n\n# Deny requests that don't match URL patterns\n${denyNonMatching}\n`;
100114
}
101115

102116
return `

src/ssl-bump.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,19 @@ export function parseUrlPatterns(patterns: string[]): string[] {
184184
// Remove trailing slash for consistency
185185
let p = pattern.replace(/\/$/, '');
186186

187+
// Preserve .* patterns by using a placeholder before escaping
188+
const WILDCARD_PLACEHOLDER = '\x00WILDCARD\x00';
189+
p = p.replace(/\.\*/g, WILDCARD_PLACEHOLDER);
190+
187191
// Escape regex special characters except *
188192
p = p.replace(/[.+?^${}()|[\]\\]/g, '\\$&');
189193

190194
// Convert * wildcards to .* regex
191195
p = p.replace(/\*/g, '.*');
192196

197+
// Restore .* patterns from placeholder
198+
p = p.replace(new RegExp(WILDCARD_PLACEHOLDER, 'g'), '.*');
199+
193200
// Anchor the pattern
194201
// If pattern ends with .* (from wildcard), don't add end anchor
195202
if (p.endsWith('.*')) {

0 commit comments

Comments
 (0)