|
1 | 1 | --- |
2 | | -title: Landlock & TLS |
| 2 | +title: General Security |
3 | 3 | description: Landlock sandboxing, TLS protocol settings, cipher suites, address restrictions. |
4 | 4 | weight: 10 |
5 | 5 | --- |
6 | 6 |
|
7 | | -Ghostunnel's TLS settings and Landlock sandboxing. |
| 7 | +Ghostunnel's TLS settings, address restrictions, and Landlock sandboxing. |
8 | 8 |
|
9 | | -## TLS Configuration |
| 9 | +## TLS Settings |
10 | 10 |
|
11 | | -Ghostunnel enforces a minimum TLS version of **TLS 1.2**. Earlier versions are |
12 | | -not supported. TLS 1.3 is supported and will be negotiated when both sides |
13 | | -support it. |
| 11 | +Ghostunnel enforces a minimum TLS version of TLS 1.2, and TLS 1.3 is supported |
| 12 | +and will be negotiated when both sides support it. Earlier versions of TLS are |
| 13 | +not supported. |
14 | 14 |
|
15 | 15 | ### Cipher Suites |
16 | 16 |
|
17 | | -The following cipher suites are enabled by default, in order of preference: |
18 | | - |
19 | | -**AES-GCM:** |
20 | | -- `TLS_AES_128_GCM_SHA256` (TLS 1.3) |
21 | | -- `TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256` |
22 | | -- `TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256` |
23 | | -- `TLS_AES_256_GCM_SHA384` (TLS 1.3) |
24 | | -- `TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384` |
25 | | -- `TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384` |
26 | | - |
27 | | -**ChaCha20-Poly1305:** |
28 | | -- `TLS_CHACHA20_POLY1305_SHA256` (TLS 1.3) |
29 | | -- `TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305` |
30 | | -- `TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305` |
31 | | - |
32 | | -All suites use authenticated encryption (AEAD). CBC-mode ciphers are not |
33 | | -enabled. ECDSA suites are listed before RSA to prefer ECDSA when both |
34 | | -certificate types are available. |
35 | | - |
36 | | -To check which cipher suite and protocol version were negotiated for a |
37 | | -connection: |
38 | | - |
39 | | -```bash |
40 | | -openssl s_client -connect localhost:8443 \ |
41 | | - -cert client-cert.pem -key client-key.pem -CAfile cacert.pem \ |
42 | | - </dev/null 2>/dev/null | grep -E 'Protocol|Cipher' |
43 | | -``` |
44 | | - |
45 | 17 | In TLS 1.3, cipher suite selection is handled by Go's [`crypto/tls`][crypto-tls] |
46 | | -and cannot be configured by the application. The TLS 1.3 suites listed above are always |
47 | | -available when TLS 1.3 is negotiated. The configurable cipher suite list only |
48 | | -affects TLS 1.2 connections. |
49 | | - |
50 | | -### Curve Preferences |
51 | | - |
52 | | -In server mode, key exchange prefers the following elliptic curves: |
53 | | - |
54 | | -1. **X25519**: fast, constant-time, widely supported |
55 | | -2. **P-256 (secp256r1)**: hardware-accelerated on most platforms |
| 18 | +and cannot be configured by the application. For TLS 1.2, the configured cipher |
| 19 | +suites all use authenticated encryption (AEAD). Older CBC-mode ciphers are not |
| 20 | +enabled. |
56 | 21 |
|
57 | 22 | ### Client Authentication |
58 | 23 |
|
59 | 24 | In server mode, Ghostunnel requires and verifies client certificates by |
60 | | -default (`RequireAndVerifyClientCert`). This can be disabled with |
61 | | -`--disable-authentication`, in which case no client certificate is requested. |
| 25 | +default. This can be disabled with `--disable-authentication`, in which case no |
| 26 | +client certificate is requested. |
62 | 27 |
|
63 | 28 | The status port (`--status`) is optional and does not require client |
64 | 29 | certificates. It is typically consumed by monitoring systems that may not |
@@ -96,6 +61,34 @@ To accept connections from remote hosts, pass `--unsafe-listen`. The listen |
96 | 61 | side of client mode accepts plaintext connections, so exposing it beyond |
97 | 62 | localhost risks unauthorized access to the proxied service. |
98 | 63 |
|
| 64 | +### Restricting to specific local users |
| 65 | + |
| 66 | +Binding to `localhost` (or `127.0.0.1` / `[::1]`) blocks the network, but on a |
| 67 | +shared host any local user can still connect to the port. If you need to |
| 68 | +restrict access to a specific UID (for example, only `root` may reach the |
| 69 | +plaintext side of a tunnel), bind to a UNIX domain socket and use |
| 70 | +filesystem permissions: |
| 71 | + |
| 72 | +```bash |
| 73 | +ghostunnel client \ |
| 74 | + --listen=unix:/var/run/ghostunnel/client.sock \ |
| 75 | + --target=backend.example.com:8443 \ |
| 76 | + ... |
| 77 | +``` |
| 78 | + |
| 79 | +Set the socket's owner and mode so only the intended user can `connect(2)` to |
| 80 | +it. With socket activation, the service manager creates the socket and applies |
| 81 | +the permissions for you; see [Systemd]({{< ref "systemd.md" >}}) and |
| 82 | +[Launchd]({{< ref "launchd.md" >}}). Otherwise, ensure the socket's parent |
| 83 | +directory is `chmod 0700` and `chown` it to the intended user, since the path |
| 84 | +must be traversable to connect. |
| 85 | + |
| 86 | +Firewall-based UID filtering exists but is fragile. On Linux, `iptables` |
| 87 | +supports `-m owner --uid-owner` and `nftables` supports `skuid`. On macOS, `pf` |
| 88 | +accepts `user =` rules, but Apple has formally stated that `pf` is not a stable |
| 89 | +API; see [TN3165: Packet Filter is not API][tn3165]. Prefer UNIX socket |
| 90 | +permissions, which are kernel-enforced via VFS and survive OS upgrades. |
| 91 | + |
99 | 92 | ## Landlock sandboxing |
100 | 93 |
|
101 | 94 | *Available since v1.8.0. Enabled by default since v1.9.0.* |
@@ -133,3 +126,4 @@ libraries that may require access to arbitrary files and sockets. |
133 | 126 |
|
134 | 127 | [crypto-tls]: https://pkg.go.dev/crypto/tls |
135 | 128 | [landlock]: https://docs.kernel.org/userspace-api/landlock.html |
| 129 | +[tn3165]: https://developer.apple.com/documentation/technotes/tn3165-packet-filter-is-not-api |
0 commit comments