Skip to content

Commit dfb02b8

Browse files
committed
WIP
1 parent 0c568c7 commit dfb02b8

21 files changed

Lines changed: 291 additions & 563 deletions

README.md

Lines changed: 3 additions & 337 deletions
Large diffs are not rendered by default.

docs/SUMMARY.md

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,21 @@
66

77
- [Installation](./guide/installation.md)
88
- [Quick Start](./guide/quick-start.md)
9-
- [Command Line Options](./reference/cli.md)
109
- [Configuration](./guide/configuration.md)
1110
- [Rule Engines](./guide/rule-engines/index.md)
1211
- [JavaScript](./guide/rule-engines/javascript.md)
1312
- [Shell](./guide/rule-engines/shell.md)
1413
- [Line Processor](./guide/rule-engines/line-processor.md)
15-
- [Request Logging](./guide/request-logging.md)
1614
- [Platform Support](./guide/platform-support.md)
17-
- [Linux](./guide/linux.md)
18-
- [macOS](./guide/macos.md)
19-
- [Security](./guide/security.md)
20-
21-
# Reference
22-
23-
- [Environment Variables](./reference/environment.md)
24-
- [JavaScript API](./reference/javascript-api.md)
25-
- [Exit Codes](./reference/exit-codes.md)
15+
- [Request Logging](./guide/request-logging.md)
2616

2717
# Advanced
2818

29-
- [Architecture](./advanced/architecture.md)
3019
- [TLS Interception](./advanced/tls-interception.md)
31-
- [Network Namespaces](./advanced/network-namespaces.md)
32-
- [DNS Protection](./advanced/dns-protection.md)
20+
- [DNS Exfiltration](./advanced/dns-protection.md)
3321
- [Server Mode](./advanced/server-mode.md)
3422

35-
# Development
36-
37-
- [Building from Source](./development/building.md)
38-
- [Testing](./development/testing.md)
39-
- [Contributing](./development/contributing.md)
40-
- [CI/CD](./development/ci-cd.md)
41-
4223
---
4324

4425
[Security Policy](./security-policy.md)
45-
[License](./license.md)
26+
[License](./license.md)

docs/advanced/dns-protection.md

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,66 @@
1-
# DNS Protection
1+
# DNS Exfiltration
2+
3+
httpjail prevents DNS exfiltration attacks by intercepting all DNS queries in isolated environments.
4+
5+
## The Attack
6+
7+
Malicious code can exfiltrate sensitive data by encoding it in DNS queries:
8+
9+
- `secret-data.attacker.com`
10+
- `env-var-contents.evil.com`
11+
- `api-key-12345.tunnel.io`
12+
13+
These queries reach public DNS servers even when HTTP/HTTPS traffic is blocked.
14+
15+
## How Protection Works
16+
17+
In Linux strong mode, httpjail:
18+
19+
1. **Intercepts all DNS queries** from the jailed process
20+
2. **Returns dummy response** (6.6.6.6) for every query
21+
3. **Prevents external DNS access** - queries never reach public resolvers
22+
4. **Maintains HTTP/HTTPS functionality** through transparent proxy redirection
23+
24+
## Traffic Flow
25+
26+
```mermaid
27+
sequenceDiagram
28+
participant J as Jailed Process
29+
participant S as Jail Server
30+
participant D as Public DNS Resolvers
31+
32+
Note over J,D: DNS Exfiltration Attempt
33+
J->>S: DNS Query: secret-data.attacker.com
34+
S-->>J: Response: 6.6.6.6 (dummy)
35+
Note over S,D: ❌ Query never reaches public resolvers
36+
37+
Note over J,D: Blocked HTTP Flow
38+
J->>S: HTTP GET http://blocked.com
39+
Note over S: Rule evaluation: denied
40+
S-->>J: 403 Forbidden
41+
Note over S,D: ❌ No DNS resolution needed
42+
43+
Note over J,D: Allowed HTTP Flow
44+
J->>S: HTTP GET http://example.com
45+
Note over S: Rule evaluation: allowed
46+
S->>D: DNS Query: example.com (only if needed)
47+
D-->>S: Real IP address
48+
S->>S: Forward to upstream server
49+
S-->>J: HTTP response
50+
```
51+
52+
The diagram shows three scenarios:
53+
54+
1. **DNS Exfiltration Prevention**: All DNS queries receive dummy response, never reaching public resolvers
55+
2. **Blocked HTTP Traffic**: Requests denied by rules without any DNS resolution
56+
3. **Allowed HTTP Traffic**: Only when rules permit, httpjail performs actual DNS resolution
57+
58+
## Platform Support
59+
60+
- **Linux (Strong Mode)**: Full DNS interception and protection
61+
- **macOS (Weak Mode)**: No DNS interception - applications resolve normally
62+
- **Windows**: Planned
63+
64+
## Why 6.6.6.6?
65+
66+
The choice of 6.6.6.6 is arbitrary - any non-lookback IP would work.

docs/advanced/server-mode.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
11
# Server Mode
2+
3+
Run httpjail as a standalone proxy server without executing any commands. Useful for proxying multiple applications through the same httpjail instance.
4+
5+
The server binds to localhost (127.0.0.1) by default for security.
6+
7+
```bash
8+
# Start server with default ports (8080 for HTTP, 8443 for HTTPS) on localhost
9+
httpjail --server --js "true"
10+
11+
# Start server with custom ports using environment variables
12+
HTTPJAIL_HTTP_BIND=3128 HTTPJAIL_HTTPS_BIND=3129 httpjail --server --js "true"
13+
14+
# Bind to all interfaces (use with caution - exposes proxy to network)
15+
HTTPJAIL_HTTP_BIND=0.0.0.0:8080 HTTPJAIL_HTTPS_BIND=0.0.0.0:8443 httpjail --server --js "true"
16+
17+
# Configure your applications to use the proxy:
18+
export HTTP_PROXY=http://localhost:8080
19+
export HTTPS_PROXY=http://localhost:8443
20+
curl https://github.com # This request will go through httpjail
21+
```
22+
23+
**Note**: In server mode, httpjail does not create network isolation. Applications must be configured to use the proxy via environment variables or application-specific proxy settings.

docs/advanced/tls-interception.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,52 @@
11
# TLS Interception
2+
3+
httpjail intercepts HTTPS traffic using a locally-generated Certificate Authority (CA) to inspect and filter encrypted requests.
4+
5+
## How It Works
6+
7+
1. **CA Generation**: On first run, httpjail creates a unique CA keypair
8+
2. **Certificate Storage**: CA files are stored in your config directory:
9+
- Linux: `~/.config/httpjail/`
10+
- macOS: `~/Library/Application Support/httpjail/`
11+
- Windows: `%APPDATA%\httpjail\` (planned)
12+
3. **Process Trust**: The jailed process trusts the CA via environment variables
13+
4. **Per-Host Certificates**: Each HTTPS connection gets a certificate signed by the httpjail CA
14+
5. **No System Changes**: Your system trust store is never modified
15+
16+
## Certificate Trust
17+
18+
httpjail sets these environment variables for the child process:
19+
20+
- `SSL_CERT_FILE` / `SSL_CERT_DIR` - OpenSSL and most tools
21+
- `CURL_CA_BUNDLE` - curl
22+
- `REQUESTS_CA_BUNDLE` - Python requests
23+
- `NODE_EXTRA_CA_CERTS` - Node.js
24+
- `CARGO_HTTP_CAINFO` - Cargo
25+
- `GIT_SSL_CAINFO` - Git
26+
27+
## Platform Differences
28+
29+
### Linux (Strong Mode)
30+
31+
- Transparently redirects TCP port 443 to the proxy
32+
- Extracts SNI from TLS ClientHello
33+
- No application cooperation needed
34+
35+
### macOS (Weak Mode)
36+
37+
- Uses `HTTP_PROXY`/`HTTPS_PROXY` environment variables
38+
- HTTPS negotiated via CONNECT method
39+
- Applications must respect proxy settings
40+
41+
## Application Support
42+
43+
| Platform | Environment Variables | System Trust Store |
44+
| -------- | --------------------- | ------------------ |
45+
| Linux | 🟢 Vast majority | N/A |
46+
| macOS | 🟠 Some | 🟢 Vast majority |
47+
48+
Most CLI tools and libraries respect the CA environment variables that httpjail sets. On macOS, some tools (e.g. those built with Go) ignore these variables and require system trust. As
49+
Linux doesn't have a concept of a "system trust store" the environment variables are
50+
well supported.
51+
52+
On macOS, you can install the CA certificate to the keychain using `httpjail trust --install`.

docs/development/building.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/development/ci-cd.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/development/contributing.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/development/testing.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/guide/configuration.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Choose how requests are evaluated:
2020
- **Shell Script** (`--sh`) - System integration, external tools
2121
- **Line Processor** (`--proc`) - Stateful, streaming evaluation
2222

23-
Only one rule engine can be active at a time. See [Rule Engines](./rule-engines.md) for detailed comparison.
23+
Only one rule engine can be active at a time. See [Rule Engines](./rule-engines/index.md) for detailed comparison.
2424

2525
### Network Mode
2626

@@ -153,7 +153,6 @@ openssl x509 -in ~/.config/httpjail/ca-cert.pem -text -noout
153153

154154
## Next Steps
155155

156-
- [Command Line Options](../reference/cli.md) - Complete CLI reference
157-
- [Rule Engines](./rule-engines.md) - Choose the right evaluation method
156+
- [Rule Engines](./rule-engines/index.md) - Choose the right evaluation method
158157
- [Request Logging](./request-logging.md) - Monitor and audit requests
159158
- [Platform Support](./platform-support.md) - Platform-specific details

0 commit comments

Comments
 (0)