2019-06-07 14:33:31 +00:00
---
2020-10-30 18:08:56 +00:00
stage: none
group: unassigned
2020-11-26 06:09:20 +00:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2019-06-07 14:33:31 +00:00
type: concepts, reference, howto
---
2019-07-16 07:02:20 +00:00
2021-06-13 21:10:11 +00:00
# Webhooks and insecure internal web services **(FREE SELF)**
2015-02-07 00:17:23 +00:00
2020-12-04 21:09:29 +00:00
NOTE:
2020-08-12 15:10:02 +00:00
On GitLab.com, the [maximum number of webhooks and their size ](../user/gitlab_com/index.md#webhooks ) per project, and per group, is limited.
2020-02-28 00:09:08 +00:00
2019-06-07 14:33:31 +00:00
If you have non-GitLab web services running on your GitLab server or within its
local network, these may be vulnerable to exploitation via Webhooks.
2015-02-07 00:17:23 +00:00
2019-06-07 14:33:31 +00:00
With [Webhooks ](../user/project/integrations/webhooks.md ), you and your project
2019-06-07 19:27:48 +00:00
maintainers and owners can set up URLs to be triggered when specific changes
2019-10-23 09:06:03 +00:00
occur in your projects. Normally, these requests are sent to external web
services specifically set up for this purpose, that process the request and its
attached data in some appropriate way.
2015-02-07 00:17:23 +00:00
2019-06-07 14:33:31 +00:00
Things get hairy, however, when a Webhook is set up with a URL that doesn't
point to an external, but to an internal service, that may do something
completely unintended when the webhook is triggered and the POST request is
sent.
2015-02-07 00:17:23 +00:00
2019-10-23 09:06:03 +00:00
Webhook requests are made by the GitLab server itself and use a single
(optional) secret token per hook for authorization (instead of a user or
2020-12-22 18:10:05 +00:00
repository-specific token). As a result, these may have broader access than
2019-10-23 09:06:03 +00:00
intended to everything running on the server hosting the webhook (which
may include the GitLab server or API itself, e.g., `http://localhost:123` ).
Depending on the called webhook, this may also result in network access
to other servers within that webhook server's local network (e.g.,
`http://192.168.1.12:345` ), even if these services are otherwise protected
and inaccessible from the outside world.
2015-02-07 00:17:23 +00:00
2019-06-07 14:33:31 +00:00
If a web service does not require authentication, Webhooks can be used to
trigger destructive commands by getting the GitLab server to make POST requests
to endpoints like `http://localhost:123/some-resource/delete` .
2015-02-07 00:17:23 +00:00
2019-06-07 14:33:31 +00:00
To prevent this type of exploitation from happening, starting with GitLab 10.6,
all Webhook requests to the current GitLab instance server address and/or in a
2020-12-07 18:10:36 +00:00
private network are forbidden by default. That means that all requests made
2020-01-07 18:07:34 +00:00
to `127.0.0.1` , `::1` and `0.0.0.0` , as well as IPv4 `10.0.0.0/8` , `172.16.0.0/12` ,
2020-12-07 18:10:36 +00:00
`192.168.0.0/16` and IPv6 site-local (`ffc0::/10`) addresses aren't allowed.
2018-04-24 10:21:50 +00:00
2021-06-15 03:10:34 +00:00
This behavior can be overridden:
2018-04-24 10:21:50 +00:00
2021-08-26 09:11:15 +00:00
1. On the top bar, select **Menu > Admin** .
2021-09-08 18:11:23 +00:00
1. On the left sidebar, select **Settings > Network** .
2021-06-15 03:10:34 +00:00
1. Expand the **Outbound requests** section:
![Outbound requests admin settings ](img/outbound_requests_section_v12_2.png )
1. Select **Allow requests to the local network from web hooks and services** .
2018-04-24 10:21:50 +00:00
2020-12-04 21:09:29 +00:00
NOTE:
2019-07-30 10:53:23 +00:00
*System hooks* are enabled to make requests to local network by default since they are
set up by administrators. However, you can turn this off by disabling the
**Allow requests to the local network from system hooks** option.
2019-06-07 14:33:31 +00:00
2020-06-05 18:08:19 +00:00
## Allowlist for local requests
2019-08-08 16:54:52 +00:00
2020-05-21 03:08:00 +00:00
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/44496) in GitLab 12.2
2019-08-08 16:54:52 +00:00
You can allow certain domains and IP addresses to be accessible to both *system hooks*
and *webhooks* even when local requests are not allowed by adding them to the
2021-06-15 03:10:34 +00:00
allowlist:
2019-08-08 16:54:52 +00:00
2021-08-26 09:11:15 +00:00
1. On the top bar, select **Menu > Admin** .
2021-09-08 18:11:23 +00:00
1. On the left sidebar, select **Settings > Network** (`/admin/application_settings/network`)
2021-06-15 03:10:34 +00:00
and expand **Outbound requests** :
![Outbound local requests allowlist ](img/allowlist_v13_0.png )
2019-08-08 16:54:52 +00:00
2020-06-05 18:08:19 +00:00
The allowed entries can be separated by semicolons, commas or whitespaces
2019-08-08 16:54:52 +00:00
(including newlines) and be in different formats like hostnames, IP addresses and/or
2020-06-12 03:08:22 +00:00
IP ranges. IPv6 is supported. Hostnames that contain Unicode characters should
2019-08-08 16:54:52 +00:00
use IDNA encoding.
2020-06-05 18:08:19 +00:00
The allowlist can hold a maximum of 1000 entries. Each entry can be a maximum of
2019-08-08 16:54:52 +00:00
255 characters.
2020-06-05 18:08:19 +00:00
You can allow a particular port by specifying it in the allowlist entry.
2020-12-07 18:10:36 +00:00
For example `127.0.0.1:8080` only allows connections to port 8080 on `127.0.0.1` .
2020-06-05 18:08:19 +00:00
If no port is mentioned, all ports on that IP/domain are allowed. An IP range
2020-12-07 18:10:36 +00:00
allows all ports on all IPs in that range.
2020-03-16 03:09:14 +00:00
2019-08-08 16:54:52 +00:00
Example:
2020-05-20 03:08:04 +00:00
```plaintext
2019-08-08 16:54:52 +00:00
example.com;gitlab.example.com
127.0.0.1,1:0:0:0:0:0:0:1
127.0.0.0/8 1:0:0:0:0:0:0:0/124
2020-03-16 03:09:14 +00:00
[1:0:0:0:0:0:0:1]:8080
127.0.0.1:8080
example.com:8080
2019-08-08 16:54:52 +00:00
```
2020-12-04 21:09:29 +00:00
NOTE:
2020-03-16 03:09:14 +00:00
Wildcards (`*.example.com`) are not currently supported.
2019-08-08 16:54:52 +00:00
2019-06-07 14:33:31 +00:00
<!-- ## Troubleshooting
Include any troubleshooting steps that you can foresee. If you know beforehand what issues
one might have when setting this up, or when something is changed, or on upgrading, it's
important to describe those, too. Think of things that may go wrong and include them here.
This is important to minimize requests for support, and to avoid doc comments with
questions that you know someone might ask.
Each scenario can be a third-level heading, e.g. `### Getting error message X` .
If you have none to add when creating a doc, leave this section in place
but commented out to help encourage others to add to it in the future. -->