External users can perform SSRF via Gitlab import
External users, who should have no permissions, could access GitLab import features that make server-side HTTP requests. An attacker could use these to send requests to internal network addresses, leading to SSRF.
GitLab
Originally disclosed on GitLab
- Fixed in 37 hours
- Disclosed after 37 hours
HackerOne report #1818556 by shells3c on 2022-12-29, assigned to Ottilia Westerlund:
Report | How To Reproduce
Report
Similar to #1236965 and #1817851
(Import of #1236965: https://gitlab.com/gitlab-org/gitlab/-/issues/346187)
From the expectation, external users, as long as they are not added to a specific project/group, should not be able to bring any risk to the local network even if the Gitlab instance allows "server-side requests from webhooks and services", because external users are not allowed to do ANYTHING until they get invited to a project/group. However, I found that external users could still access some functions of several Gitlab import methods (despite having no permission to import any project), and 3 of them allow performing HTTP requests that can be exploited:
- List Bitbucket Server repositories (GET)
- List Gitea Server repositories (GET)
- Map FogBugz users and projects (POST)
Steps to reproduce
- As the Gitlab admin, enable sign-ups and enable requests to the local network
- Under Account and limit, set
New users set to external
Newly registered users will by default be external
- Start listening on port
8000 - From the attacker side, sign up with a dummy email, now you are an external user with no permission.
- Using the attacker account, go to
http://<instance>/projects/new#import_projectand choose FogBugz - Fill in an internal URL (in this case, it's
http://127.0.0.1:8000/controlled/path?foo), a dummy username and a dummy password - You have successfully sent an [HTTP] POST request to the localhost, you can receive the request from the listener used in step 3
You can do the same with 2 other import methods, which will allow you to perform GET requests
What is the current bug behavior?
Gitlab doesn't forbid external users from accessing the importing feature in spite of the permission, and some import methods have functions that allow sending HTTP requests, therefore leading to SSRF risk
What is the expected correct behavior?
Gitlab should refuse any import-related actions if the user is an external user
Output of checks
System information
System: Ubuntu 20.04
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 2.7.6p219
Gem Version: 3.1.6
Bundler Version:2.3.15
Rake Version: 13.0.6
Redis Version: 6.2.7
Sidekiq Version:6.5.7
Go Version: go1.13.8 linux/amd64
GitLab information
Version: 15.6.3-ee
Revision: 511d324e54d
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 12.12
URL: http://gitlab.local
HTTP Clone URL: http://gitlab.local/some-group/some-project.git
SSH Clone URL: [email protected]:some-group/some-project.git
Elasticsearch: no
Geo: no
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:
GitLab Shell
Version: 14.13.0
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Impact
Same as #1236965, external users can perform SSRF when the admin whitelists server-side requests
How To Reproduce
Please add reproducibility information to this section:
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely, GitLab did not properly restrict external users from accessing import features that perform server-side HTTP requests.
Impact
External users could perform SSRF when the admin allows server-side requests to the local network, potentially accessing internal services.
What the attacker needed
Sign-ups enabled; new users set to external; local network requests allowed by admin
The fix
GitLab should refuse any import-related actions if the user is an external user.
How it was found
- As admin, enable sign-ups and allow requests to the local network.
- Set new users to be external by default.
- Start a listener on port 8000.
- Sign up as a new external user.
- Go to the new project import page and choose FogBugz.
- Enter an internal URL, dummy username and password, then submit to trigger a POST request to localhost.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
An external user is a GitLab account with very limited permissions, meant to be harmless until invited to a project. The import feature lets users pull data from other services, and some import methods make the GitLab server send HTTP requests to a URL the user provides. Because external users could still use these import methods, they could make the server send requests to internal addresses, which is called server-side request forgery (SSRF).
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.