You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve clarity and accuracy of security documentation
- Reorder sections logically: Network Isolation → DNS → Proxy → Direct IP
- Clarify DNS redirect, HTTP proxy, and iptables descriptions
- Add missing Host header rejection to proxy control section
- Split Direct IP section into traffic redirection and IP allowlist check
- Fix variable names and add audit mode link
Copy file name to clipboardExpand all lines: docs/security.md
+16-14Lines changed: 16 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,30 +6,32 @@ For a high-level overview, see the [Security Considerations](../README.md#securi
6
6
7
7
## Security Mechanisms
8
8
9
-
### Direct IP Address Connections
9
+
### Network Isolation
10
10
11
-
-**Direct IP blocked by iptables**: Connections to raw IP addresses (e.g., `curl http://1.2.3.4/`) bypass DNS and attempt to reach the IP directly, which iptables drops. Connections using domain names go through the proxy and are checked against the allowlist via Host header (HTTP) or SNI (HTTPS).
11
+
-**CNI configuration**: Places temporary containers from BuildKit RUN steps into isolated-net (buildkit0 bridge, 172.20.0.0/24).
12
+
-**iptables**: Drops all FORWARD from buildkit0, also blocks direct access to buildkitd API.
13
+
-**Gateway enforcement**: All traffic must go through the proxy on 172.20.0.1.
12
14
13
15
### DNS-Level Control
14
16
15
-
-**Full redirect**: Returns the proxy IP for all DNS queries.
17
+
-**Universal DNS redirect**: All domain name queries return the proxy IP (172.20.0.1), forcing all traffic through the proxy regardless of the requested domain.
16
18
-**ECH prevention**: The internal DNS server operates without any upstream resolvers, so DNS HTTPS (type 65) records — required to initiate Encrypted Client Hello (ECH) — are never returned to build containers.
17
19
18
20
### HTTP/HTTPS Proxy Control
19
21
20
22
-**HTTPS**: Determines the target server name by reading the SNI field, without terminating TLS. Certificate validation is unaffected.
21
-
-**HTTP**: Domain determination via Host header.
22
-
-**Dynamic allowlist**: Controlled via environment variables.
23
+
-**HTTP**: Determines the target domain by inspecting the Host header, then checks it against the allowlist.
24
+
-**Dynamic allowlist**: Controlled via `allowed_https_rules`, `allowed_http_rules`, and `allowed_ip_rules` environment variables.
25
+
-**Missing Host header rejection**: HTTP requests without a valid Host header are rejected with HTTP 400, preventing requests that cannot be checked against the allowlist.
23
26
24
-
### Network Isolation
27
+
### Direct IP Address Connections
25
28
26
-
-**CNI configuration**: Places temporary containers from BuildKit RUN steps into isolated-net (buildkit0 bridge, 172.20.0.0/24).
27
-
-**iptables**: Drops all FORWARD from buildkit0, also blocks direct access to buildkitd API.
28
-
-**Gateway enforcement**: All traffic must go through the proxy on 172.20.0.1.
29
+
-**Traffic redirection**: All TCP traffic from the isolated network is redirected to HAProxy via an iptables `PREROUTING REDIRECT` rule.
30
+
-**IP allowlist check**: Connections to raw IP addresses (e.g., `curl http://1.2.3.4/`) are checked against `allowed_ip_rules`. If no `allowed_ip_rules` are configured, all direct IP connections are blocked.
29
31
30
32
## Attack Resistance
31
33
32
-
The following attack vectors are defended against by buildcage's architecture.
34
+
buildcage's architecture defends against the following attack vectors.
33
35
34
36
### SNI Spoofing
35
37
@@ -47,7 +49,7 @@ TLS 1.3 Encrypted Client Hello (ECH) encrypts the true SNI, which could theoreti
47
49
48
50
An attacker may attempt to encode data into DNS queries to exfiltrate information or establish communication with external servers.
49
51
50
-
**Why this is prevented:** The internal DNS server has no upstream resolvers and answers all queries locally. Additionally, iptables rules block direct DNS traffic to any external server. With no path for DNS queries to reach the outside, encoded data has no route to an attacker's infrastructure.
52
+
**Why this is prevented:** The internal DNS server has no upstream resolvers and answers all queries locally. Additionally, all forwarded traffic from the isolated network is dropped by iptables — including any attempt to reach external DNS servers directly. With no path for DNS queries to reach the outside, encoded data has no route to an attacker's infrastructure.
51
53
52
54
### Non-TCP Protocol Tunneling (ICMP, UDP, QUIC)
53
55
@@ -59,7 +61,7 @@ An attacker may attempt to tunnel data using non-TCP protocols such as ICMP echo
59
61
60
62
An attacker may attempt to use IPv6 to circumvent IPv4-based iptables rules.
61
63
62
-
**Why this is prevented:** Equivalent ip6tables rules drop all forwarded IPv6 traffic from the isolated network. Additionally, the internal DNS server returns an empty IPv6 address for all queries, effectively disabling IPv6 name resolution within build containers.
64
+
**Why this is prevented:** Equivalent ip6tables rules drop all forwarded IPv6 traffic from the isolated network. Additionally, the internal DNS server returns the IPv6 unspecified address (::) for all queries, effectively disabling IPv6 name resolution within build containers.
63
65
64
66
### Alternative DNS Transports (DoH / DoT)
65
67
@@ -96,8 +98,8 @@ Given these implementation costs versus the strict preconditions for the attack
96
98
97
99
**Mitigation strategies:**
98
100
99
-
-**Keep allowed domains to a minimum** — Only specify the domains you need in `allowed_http_domains` / `allowed_https_domains`.
101
+
-**Keep allowed domains to a minimum** — Only specify the domains you need in `allowed_http_rules` / `allowed_https_rules`.
100
102
-**Be specific with allowed domains** — Avoid broad wildcard CDN domains (e.g., `*.cdn.example.com`) when possible.
-**Major CDN countermeasures** — Major CDN providers like CloudFront and Cloudflare have already introduced measures to restrict domain fronting. Consult your CDN provider's documentation for current details.
103
-
-**Regular audits** — Periodically run in audit mode to detect anomalies in connection patterns.
105
+
-**Regular audits** — Periodically run in [audit mode](../README.md#operation-modes) to detect anomalies in connection patterns.
0 commit comments