Skip to content

Commit 894245e

Browse files
evictcamdencheek
andauthored
security: add allowlist documentation (#862)
This adds documentation about the new allowlist for "untrusted" external connections, released in 5.11. --------- Co-authored-by: Camden Cheek <[email protected]>
1 parent aef4046 commit 894245e

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed
Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
# Outoing Connection Filtering
2-
It’s possible for the Sourcegraph instance to deny access to hosts by setting the environment variable `EXTERNAL_DENY_LIST` on the deployment. If you want to only prevent codemonitors and other frontend services to connect to arbitrary hosts, you can set the variable only on the frontend deployment.
3-
The external denylist supports a comma separated list of IP ranges, hostnames and keywords. To block all the internal connections use the “private” keyword, this would block all RFC 1918 (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) and RFC 4193 (FC00::/7) IP addresses. Keywords can be combined with ranges and IP addresses so it's very customizable.
2+
Sourcegraph supports outbound connection filtering. Both for regular external connections and so-called "untrusted" connections, where a regular user can provide a URL to make an outbound connection to.
3+
4+
The allow- and denylist support a comma separated list of IP ranges, hostnames and keywords. To block or allow all the internal connections use the “private” keyword, this would block all RFC 1918 (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) and RFC 4193 (FC00::/7) IP addresses. Keywords can be combined with ranges and IP addresses so it's very customizable.
5+
6+
## Trusted External Connections
7+
It’s possible for the Sourcegraph instance to deny access to external hosts by setting the environment variable `EXTERNAL_DENY_LIST` on the deployment.
48

59
The default denylist is set up to only block localhost and the Cloud metadata service IP address. Expanding the denylist could interfere with internal authentication providers, and they might need to be excluded from the denylist.
610

7-
## Example Configuration
11+
### Example Configuration
12+
13+
Adding a denylist can be done by setting the environment variable `EXTERNAL_DENY_LIST` on the deployment.
814

915
```
1016
EXTERNAL_DENY_LIST="private,github.com"
1117
```
1218

1319
This would deny all connections to hosts in the private network and github.com.
1420

21+
## Untrusted External Connections
22+
Codemonitors, webhooks and Cody URL context are limited to only be able to access public IP addresses by default. This behavior can be changed with the `UNTRUSTED_EXTERNAL_ALLOW_LIST` environment variable, which configures the allowlist.
23+
24+
### Example Configuration
25+
If you want Cody to use context from an internal server in addition to internet access, you can add the internal server's IP address to the allowlist:
26+
27+
```
28+
UNTRUSTED_EXTERNAL_ALLOW_LIST="external,192.168.1.53"
29+
```
30+
1531
## Implementation Details
1632
To achieve this, we use [gitea's hostmatcher](https://github.com/go-gitea/gitea/blob/v1.22.6/modules/hostmatcher/hostmatcher.go#L39). This is configured by default for the `ExternalClient`, which is used for all external requests. The common options and configuration can be found [here](https://github.com/sourcegraph/sourcegraph-public-snapshot/blob/main/internal/httpcli/client.go#L406C1-L423C2).

0 commit comments

Comments
 (0)