Skip to content

Commit 110b633

Browse files
CopilotMossakaclaude
authored
feat: add SSL Bump support for HTTPS content inspection (#131)
* Initial plan * feat: add SSL Bump support for HTTPS content inspection Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com> * docs: add SSL Bump documentation Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com> * refactor: remove unused generateSslBumpConfig function Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com> * fix: address SSL Bump issues and improve documentation Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com> * fix: resolve SSL Bump initialization and config ordering issues - Fix SSL database initialization: security_file_certgen requires the directory to NOT exist, but Docker volume mounts create it. Now initSslDb() creates the complete DB structure (certs/, index.txt, size) directly on the host. - Simplify entrypoint.sh: Since DB is pre-initialized on host, the entrypoint only needs to fix permissions for the proxy user. - Fix Squid config ordering: ACL definitions must appear before ssl_bump rules that reference them. Moved ${aclSection} before ${sslBumpSection} in the config template. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * 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> * fix: address SSL Bump security review findings Security improvements based on review feedback: 1. URL Pattern Validation (cli.ts): - Reject patterns not starting with https:// - Block overly broad patterns like https://* or .* - Require path component in URL patterns - Add helpful error messages guiding users to correct usage 2. Container Hardening (docker-manager.ts): - Drop unnecessary capabilities from Squid container: NET_RAW, SYS_ADMIN, SYS_PTRACE, SYS_MODULE, MKNOD, AUDIT_WRITE, SETFCAP - Reduces attack surface if Squid process is compromised 3. Enhanced Security Documentation (docs/ssl-bump.md): - Added prominent security warnings about threat model change - Documented when NOT to use SSL Bump: - Multi-tenant environments - Untrusted workloads - Multi-user systems - Detailed CA private key exposure risks - Listed all implemented mitigations Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com> Co-authored-by: Jiaxiao (mossaka) Zhou <duibao55328@gmail.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7fe0a36 commit 110b633

18 files changed

Lines changed: 1588 additions & 15 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ sudo awf --help
114114

115115
- [Quick start](docs/quickstart.md) — install, verify, and run your first command
116116
- [Usage guide](docs/usage.md) — CLI flags, domain allowlists, Docker-in-Docker examples
117+
- [SSL Bump](docs/ssl-bump.md) — HTTPS content inspection for URL path filtering
117118
- [Logging quick reference](docs/logging_quickref.md) and [Squid log filtering](docs/squid_log_filtering.md) — view and filter traffic
118119
- [Security model](docs/security.md) — what the firewall protects and how
119120
- [Architecture](docs/architecture.md) — how Squid, Docker, and iptables fit together

containers/agent/entrypoint.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,19 @@ if [ -f /etc/resolv.conf ]; then
9898
echo "[entrypoint] DNS configured with Docker embedded DNS (127.0.0.11) and trusted servers: $DNS_SERVERS"
9999
fi
100100

101+
# Update CA certificates if SSL Bump is enabled
102+
# The CA certificate is mounted at /usr/local/share/ca-certificates/awf-ca.crt
103+
if [ "${AWF_SSL_BUMP_ENABLED}" = "true" ]; then
104+
echo "[entrypoint] SSL Bump mode detected - updating CA certificates..."
105+
if [ -f /usr/local/share/ca-certificates/awf-ca.crt ]; then
106+
update-ca-certificates 2>/dev/null
107+
echo "[entrypoint] CA certificates updated for SSL Bump"
108+
echo "[entrypoint] ⚠️ WARNING: HTTPS traffic will be intercepted for URL inspection"
109+
else
110+
echo "[entrypoint][WARN] SSL Bump enabled but CA certificate not found"
111+
fi
112+
fi
113+
101114
# Setup Docker socket permissions if Docker socket is mounted
102115
# This allows MCP servers that run as Docker containers to work
103116
# Store DOCKER_GID once to avoid redundant stat calls

containers/squid/Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
FROM ubuntu/squid:latest
22

3-
# Install additional tools for debugging and healthcheck
3+
# Install additional tools for debugging, healthcheck, and SSL Bump
44
RUN apt-get update && \
55
apt-get install -y --no-install-recommends \
66
curl \
77
dnsutils \
88
net-tools \
9-
netcat-openbsd && \
9+
netcat-openbsd \
10+
openssl \
11+
squid-openssl && \
1012
rm -rf /var/lib/apt/lists/*
1113

12-
# Create log directory
14+
# Create log directory and SSL database directory
1315
RUN mkdir -p /var/log/squid && \
1416
chown -R proxy:proxy /var/log/squid
1517

1618
# Copy entrypoint script
1719
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
1820
RUN chmod +x /usr/local/bin/entrypoint.sh
1921

20-
# Expose Squid port
22+
# Expose Squid port (3128 for HTTP, 3129 for HTTPS with SSL Bump)
2123
EXPOSE 3128
24+
EXPOSE 3129
2225

2326
# Use entrypoint to fix permissions before starting Squid
2427
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

containers/squid/entrypoint.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,18 @@ set -e
66
chown -R proxy:proxy /var/log/squid
77
chmod -R 755 /var/log/squid
88

9+
# Fix permissions on SSL certificate database if SSL Bump is enabled
10+
# The database is initialized on the host side by awf, but the permissions
11+
# need to be fixed for the proxy user inside the container.
12+
if [ -d "/var/spool/squid_ssl_db" ]; then
13+
echo "[squid-entrypoint] SSL Bump mode detected - fixing SSL database permissions..."
14+
15+
# Fix ownership for Squid (runs as proxy user)
16+
chown -R proxy:proxy /var/spool/squid_ssl_db
17+
chmod -R 700 /var/spool/squid_ssl_db
18+
19+
echo "[squid-entrypoint] SSL certificate database ready"
20+
fi
21+
922
# Start Squid
1023
exec squid -N -d 1

docs-site/src/content/docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ When AI agents like GitHub Copilot CLI run with access to tools and MCP servers,
1515

1616
**Key Capabilities:**
1717
- **Domain Allowlist & Blocklist**: Allow specific domains and block exceptions with wildcard pattern support
18+
- **URL Path Filtering**: Restrict access to specific URL paths with [SSL Bump](/gh-aw-firewall/reference/ssl-bump/)
1819
- **Docker-in-Docker Enforcement**: Spawned containers inherit firewall restrictions
1920
- **Host-Level Protection**: Uses iptables DOCKER-USER chain for defense-in-depth
2021
- **Zero Trust**: Block all traffic by default, allow only what you explicitly permit

docs-site/src/content/docs/reference/cli-reference.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ awf [options] -- <command>
2323
| `--allow-domains-file <path>` | string || Path to file containing allowed domains |
2424
| `--block-domains <domains>` | string || Comma-separated list of blocked domains (takes precedence over allowed) |
2525
| `--block-domains-file <path>` | string || Path to file containing blocked domains |
26+
| `--ssl-bump` | flag | `false` | Enable SSL Bump for HTTPS content inspection |
27+
| `--allow-urls <urls>` | string || Comma-separated list of allowed URL patterns (requires `--ssl-bump`) |
2628
| `--log-level <level>` | string | `info` | Logging verbosity: `debug`, `info`, `warn`, `error` |
2729
| `--keep-containers` | flag | `false` | Keep containers running after command exits |
2830
| `--tty` | flag | `false` | Allocate pseudo-TTY for interactive tools |
@@ -98,6 +100,47 @@ Path to file with blocked domains. Supports the same format as `--allow-domains-
98100
--block-domains-file ./blocked-domains.txt
99101
```
100102

103+
### `--ssl-bump`
104+
105+
Enable SSL Bump for HTTPS content inspection. When enabled, the firewall generates a per-session CA certificate and intercepts HTTPS connections, allowing URL path filtering.
106+
107+
```bash
108+
--ssl-bump --allow-urls "https://github.com/githubnext/*"
109+
```
110+
111+
:::caution[HTTPS Interception]
112+
SSL Bump decrypts HTTPS traffic at the proxy. The proxy can see full URLs, headers, and request bodies. Applications with certificate pinning will fail to connect.
113+
:::
114+
115+
**How it works:**
116+
1. A unique CA certificate is generated (valid for 1 day)
117+
2. The CA is injected into the agent container's trust store
118+
3. Squid intercepts HTTPS using SSL Bump (peek, stare, bump)
119+
4. Full URLs become visible for filtering via `--allow-urls`
120+
121+
**See also:** [SSL Bump Reference](/gh-aw-firewall/reference/ssl-bump/) for complete documentation.
122+
123+
### `--allow-urls <urls>`
124+
125+
Comma-separated list of allowed URL patterns for HTTPS traffic. Requires `--ssl-bump`.
126+
127+
```bash
128+
# Single pattern
129+
--allow-urls "https://github.com/githubnext/*"
130+
131+
# Multiple patterns
132+
--allow-urls "https://github.com/org1/*,https://api.github.com/repos/*"
133+
```
134+
135+
**Pattern syntax:**
136+
- Must include scheme (`https://`)
137+
- `*` matches any characters in a path segment
138+
- Patterns are matched against the full request URL
139+
140+
:::note
141+
Without `--ssl-bump`, the firewall can only see domain names (via SNI). Enable `--ssl-bump` to filter by URL path.
142+
:::
143+
101144
### `--log-level <level>`
102145

103146
Set logging verbosity.
@@ -397,4 +440,8 @@ awf logs summary --format pretty
397440
## See Also
398441

399442
- [Domain Filtering Guide](/gh-aw-firewall/guides/domain-filtering) - Allowlists, blocklists, and wildcards
443+
- [SSL Bump Reference](/gh-aw-firewall/reference/ssl-bump/) - HTTPS content inspection and URL filtering
444+
- [Quick Start Guide](/gh-aw-firewall/quickstart) - Getting started with examples
445+
- [Usage Guide](/gh-aw-firewall/usage) - Detailed usage patterns and examples
446+
- [Troubleshooting](/gh-aw-firewall/troubleshooting) - Common issues and solutions
400447
- [Security Architecture](/gh-aw-firewall/reference/security-architecture) - How the firewall works internally

docs-site/src/content/docs/reference/security-architecture.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,63 @@ We considered isolating the agent in a network namespace with zero external conn
186186

187187
mitmproxy would let us inspect HTTPS payloads, potentially catching exfiltration in POST bodies. But it requires injecting a CA certificate and breaks certificate pinning (common in security-sensitive clients). Squid's CONNECT method reads SNI without decryption—less powerful but zero client-side changes, and we maintain end-to-end encryption.
188188

189+
:::tip[SSL Bump for URL Filtering]
190+
When you need URL path filtering (not just domain filtering), enable `--ssl-bump`. This uses Squid's SSL Bump feature with a per-session CA certificate, providing full URL visibility while maintaining security through short-lived, session-specific certificates.
191+
:::
192+
193+
---
194+
195+
## SSL Bump Security Model
196+
197+
When `--ssl-bump` is enabled, the firewall intercepts HTTPS traffic for URL path filtering. This changes the security model significantly.
198+
199+
### How SSL Bump Works
200+
201+
1. **CA Generation**: A unique CA key pair is generated at session start
202+
2. **Trust Store Injection**: The CA certificate is added to the agent container's trust store
203+
3. **TLS Interception**: Squid terminates TLS and re-establishes encrypted connections to destinations
204+
4. **URL Filtering**: Full request URLs (including paths) become visible for ACL matching
205+
206+
### Security Safeguards
207+
208+
| Safeguard | Description |
209+
|-----------|-------------|
210+
| **Per-session CA** | Each awf execution generates a unique CA certificate |
211+
| **Short validity** | CA certificate valid for 1 day maximum |
212+
| **Ephemeral key storage** | CA private key exists only in temp directory, deleted on cleanup |
213+
| **Container-only trust** | CA injected only into agent container, not host system |
214+
215+
### Trade-offs vs. SNI-Only Mode
216+
217+
| Aspect | SNI-Only (Default) | SSL Bump |
218+
|--------|-------------------|----------|
219+
| Filtering granularity | Domain only | Full URL path |
220+
| End-to-end encryption | ✓ Preserved | Modified (proxy-terminated) |
221+
| Certificate pinning | Works | Broken |
222+
| Proxy visibility | Domain:port | Full request (URL, headers) |
223+
| Performance | Faster | Slight overhead |
224+
225+
:::caution[When to Use SSL Bump]
226+
Only enable SSL Bump when you specifically need URL path filtering. For most use cases, domain-based filtering provides sufficient control with stronger encryption guarantees.
227+
:::
228+
229+
### SSL Bump Threat Considerations
230+
231+
**What SSL Bump enables:**
232+
- Fine-grained access control (e.g., allow only `/githubnext/*` paths)
233+
- Better audit logging with full URLs
234+
- Detection of path-based exfiltration attempts
235+
236+
**What SSL Bump exposes:**
237+
- Full HTTP request/response content visible to proxy
238+
- Applications with certificate pinning will fail
239+
- Slightly increased attack surface (CA key compromise)
240+
241+
**Mitigations:**
242+
- CA key never leaves the temporary work directory
243+
- Session isolation: each execution uses a fresh CA
244+
- Automatic cleanup removes all key material
245+
189246
---
190247

191248
## Failure Modes

0 commit comments

Comments
 (0)