Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ sudo awf --help

- [Quick start](docs/quickstart.md) — install, verify, and run your first command
- [Usage guide](docs/usage.md) — CLI flags, domain allowlists, Docker-in-Docker examples
- [SSL Bump](docs/ssl-bump.md) — HTTPS content inspection for URL path filtering
- [Logging quick reference](docs/logging_quickref.md) and [Squid log filtering](docs/squid_log_filtering.md) — view and filter traffic
- [Security model](docs/security.md) — what the firewall protects and how
- [Architecture](docs/architecture.md) — how Squid, Docker, and iptables fit together
Expand Down
13 changes: 13 additions & 0 deletions containers/agent/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ if [ -f /etc/resolv.conf ]; then
echo "[entrypoint] DNS configured with Docker embedded DNS (127.0.0.11) and trusted servers: $DNS_SERVERS"
fi

# Update CA certificates if SSL Bump is enabled
# The CA certificate is mounted at /usr/local/share/ca-certificates/awf-ca.crt
if [ "${AWF_SSL_BUMP_ENABLED}" = "true" ]; then
echo "[entrypoint] SSL Bump mode detected - updating CA certificates..."
if [ -f /usr/local/share/ca-certificates/awf-ca.crt ]; then
update-ca-certificates 2>/dev/null
echo "[entrypoint] CA certificates updated for SSL Bump"
echo "[entrypoint] ⚠️ WARNING: HTTPS traffic will be intercepted for URL inspection"
else
echo "[entrypoint][WARN] SSL Bump enabled but CA certificate not found"
fi
fi

# Setup Docker socket permissions if Docker socket is mounted
# This allows MCP servers that run as Docker containers to work
# Store DOCKER_GID once to avoid redundant stat calls
Expand Down
11 changes: 7 additions & 4 deletions containers/squid/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
FROM ubuntu/squid:latest

# Install additional tools for debugging and healthcheck
# Install additional tools for debugging, healthcheck, and SSL Bump
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
dnsutils \
net-tools \
netcat-openbsd && \
netcat-openbsd \
openssl \
squid-openssl && \
rm -rf /var/lib/apt/lists/*

# Create log directory
# Create log directory and SSL database directory
RUN mkdir -p /var/log/squid && \
chown -R proxy:proxy /var/log/squid

# Copy entrypoint script
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

# Expose Squid port
# Expose Squid port (3128 for HTTP, 3129 for HTTPS with SSL Bump)
EXPOSE 3128
EXPOSE 3129

# Use entrypoint to fix permissions before starting Squid
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
13 changes: 13 additions & 0 deletions containers/squid/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,18 @@ set -e
chown -R proxy:proxy /var/log/squid
chmod -R 755 /var/log/squid

# Fix permissions on SSL certificate database if SSL Bump is enabled
# The database is initialized on the host side by awf, but the permissions
# need to be fixed for the proxy user inside the container.
if [ -d "/var/spool/squid_ssl_db" ]; then
echo "[squid-entrypoint] SSL Bump mode detected - fixing SSL database permissions..."

# Fix ownership for Squid (runs as proxy user)
chown -R proxy:proxy /var/spool/squid_ssl_db
chmod -R 700 /var/spool/squid_ssl_db

echo "[squid-entrypoint] SSL certificate database ready"
fi

# Start Squid
exec squid -N -d 1
1 change: 1 addition & 0 deletions docs-site/src/content/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ When AI agents like GitHub Copilot CLI run with access to tools and MCP servers,

**Key Capabilities:**
- **Domain Whitelisting**: Allow only specific domains (automatically includes subdomains)
- **URL Path Filtering**: Restrict access to specific URL paths with [SSL Bump](/gh-aw-firewall/reference/ssl-bump/)
- **Docker-in-Docker Enforcement**: Spawned containers inherit firewall restrictions
- **Host-Level Protection**: Uses iptables DOCKER-USER chain for defense-in-depth
- **Zero Trust**: Block all traffic by default, allow only what you explicitly permit
Expand Down
44 changes: 44 additions & 0 deletions docs-site/src/content/docs/reference/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ awf [options] -- <command>
| `--allow-domains-file <path>` | string | — | Path to file containing allowed domains |
| `--block-domains <domains>` | string | — | Comma-separated list of blocked domains (takes precedence over allowed) |
| `--block-domains-file <path>` | string | — | Path to file containing blocked domains |
| `--ssl-bump` | flag | `false` | Enable SSL Bump for HTTPS content inspection |
| `--allow-urls <urls>` | string | — | Comma-separated list of allowed URL patterns (requires `--ssl-bump`) |
| `--log-level <level>` | string | `info` | Logging verbosity: `debug`, `info`, `warn`, `error` |
| `--keep-containers` | flag | `false` | Keep containers running after command exits |
| `--tty` | flag | `false` | Allocate pseudo-TTY for interactive tools |
Expand Down Expand Up @@ -77,6 +79,47 @@ Path to file with blocked domains. Supports the same format as `--allow-domains-
--block-domains-file ./blocked-domains.txt
```

### `--ssl-bump`

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.

```bash
--ssl-bump --allow-urls "https://github.com/githubnext/*"
```

:::caution[HTTPS Interception]
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.
:::

**How it works:**
1. A unique CA certificate is generated (valid for 1 day)
2. The CA is injected into the agent container's trust store
3. Squid intercepts HTTPS using SSL Bump (peek, stare, bump)
4. Full URLs become visible for filtering via `--allow-urls`

**See also:** [SSL Bump Reference](/gh-aw-firewall/reference/ssl-bump/) for complete documentation.

### `--allow-urls <urls>`

Comma-separated list of allowed URL patterns for HTTPS traffic. Requires `--ssl-bump`.

```bash
# Single pattern
--allow-urls "https://github.com/githubnext/*"

# Multiple patterns
--allow-urls "https://github.com/org1/*,https://api.github.com/repos/*"
```

**Pattern syntax:**
- Must include scheme (`https://`)
- `*` matches any characters in a path segment
- Patterns are matched against the full request URL

:::note
Without `--ssl-bump`, the firewall can only see domain names (via SNI). Enable `--ssl-bump` to filter by URL path.
:::

### `--log-level <level>`

Set logging verbosity.
Expand Down Expand Up @@ -234,6 +277,7 @@ Log sources are auto-discovered in this order: running containers, `AWF_LOGS_DIR

## See Also

- [SSL Bump Reference](/gh-aw-firewall/reference/ssl-bump/) - HTTPS content inspection and URL filtering
- [Quick Start Guide](/gh-aw-firewall/quickstart) - Getting started with examples
- [Usage Guide](/gh-aw-firewall/usage) - Detailed usage patterns and examples
- [Troubleshooting](/gh-aw-firewall/troubleshooting) - Common issues and solutions
Expand Down
57 changes: 57 additions & 0 deletions docs-site/src/content/docs/reference/security-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,63 @@ We considered isolating the agent in a network namespace with zero external conn

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.

:::tip[SSL Bump for URL Filtering]
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.
:::

---

## SSL Bump Security Model

When `--ssl-bump` is enabled, the firewall intercepts HTTPS traffic for URL path filtering. This changes the security model significantly.

### How SSL Bump Works

1. **CA Generation**: A unique CA key pair is generated at session start
2. **Trust Store Injection**: The CA certificate is added to the agent container's trust store
3. **TLS Interception**: Squid terminates TLS and re-establishes encrypted connections to destinations
4. **URL Filtering**: Full request URLs (including paths) become visible for ACL matching

### Security Safeguards

| Safeguard | Description |
|-----------|-------------|
| **Per-session CA** | Each awf execution generates a unique CA certificate |
| **Short validity** | CA certificate valid for 1 day maximum |
| **Ephemeral key storage** | CA private key exists only in temp directory, deleted on cleanup |
| **Container-only trust** | CA injected only into agent container, not host system |

### Trade-offs vs. SNI-Only Mode

| Aspect | SNI-Only (Default) | SSL Bump |
|--------|-------------------|----------|
| Filtering granularity | Domain only | Full URL path |
| End-to-end encryption | ✓ Preserved | Modified (proxy-terminated) |
| Certificate pinning | Works | Broken |
| Proxy visibility | Domain:port | Full request (URL, headers) |
| Performance | Faster | Slight overhead |

:::caution[When to Use SSL Bump]
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.
:::

### SSL Bump Threat Considerations

**What SSL Bump enables:**
- Fine-grained access control (e.g., allow only `/githubnext/*` paths)
- Better audit logging with full URLs
- Detection of path-based exfiltration attempts

**What SSL Bump exposes:**
- Full HTTP request/response content visible to proxy
- Applications with certificate pinning will fail
- Slightly increased attack surface (CA key compromise)

**Mitigations:**
- CA key never leaves the temporary work directory
- Session isolation: each execution uses a fresh CA
- Automatic cleanup removes all key material

---

## Failure Modes
Expand Down
Loading