Transferring a public group to a private group doesn't remove code from the Elastichsearch API search result
When a public group with public projects is transferred to a private group, the code and wiki content remain searchable via the Elasticsearch API, even though the interface shows no results. An attacker could retrieve private code and wiki information through the search API.
- Triaged in under an hour
- Fixed in 12 days
- Paid in 4 days
- Disclosed after 10 months
Summary
When a public group with public projects is transferred to a private group, the code and the wiki of the public project, although now should be private, it is still reachable through search APIs.
I set the severity as "medium" and not "high", because any new action over the project issues a re indexing (or some actions, not sure), so if the transfer is for "archiving" purposes it is a problem, but if after the transfer other activities happen, then it is not a problem, cause the project will be removed from the index.
Steps to reproduce
Alice creates the public group "Example", and a public project named "Example-project" inside the group. In the readme of the project, Alice writes "Example".
Now, Alice creates a private group called "private", and transfer all the "Example" group to the "private" group.
If Bob (totally unrelated to Alice), search for "Example" instance-wide, will not find anything on the interface, but the count of the results will be "1" (see screenshot).
If he uses the APIs (e.g. http://localhost/api/v4/search?search=password&scope=blobs), he will receive the results back with the information that should be private.
This happens also with wiki_blobs.
This doesn't happen transferring single projects, but only transferring entire groups
Output of checks
Results of GitLab environment info
System information
System:
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 2.6.3p62
Gem Version: 2.7.9
Bundler Version:1.17.3
Rake Version: 12.3.3
Redis Version: 3.2.12
Git Version: 2.22.0
Sidekiq Version:5.2.7
Go Version: unknown
GitLab information
Version: 12.5.2-ee
Revision: c1b3929bc67
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 10.9
URL: http://aldebaran
HTTP Clone URL: http://aldebaran/some-group/some-project.git
SSH Clone URL: git@aldebaran:some-group/some-project.git
Elasticsearch: yes
Geo: no
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:
GitLab Shell
Version: 10.2.0
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Git: /opt/gitlab/embedded/bin/git
Impact
Alice thinks her code is now private, but it is not, unless she continues working on the project
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 the search index was not updated to remove or restrict documents when a group's visibility changed via transfer, so stale entries remained accessible through the API.
Impact
Private code and wiki content could be exposed to unauthorised users through the search API, but only until the project is re-indexed by further activity.
What the attacker needed
Elasticsearch enabled; public group with public projects; group transferred to a private group; no subsequent activity on the project
The fix
A development issue and merge request are linked, but the text does not confirm the fix was applied.
How it was found
- Alice creates a public group and a public project inside it, with a readme containing a unique word.
- Alice creates a private group and transfers the entire public group into it.
- Bob, unrelated to Alice, searches for the unique word instance-wide; the interface shows no results but the result count is 1.
- Bob uses the search API to retrieve the code and wiki content that should now be private.
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.
A public group in GitLab can contain projects whose code is visible to everyone. When that group is moved into a private group, the code should become private. However, the search system (Elasticsearch) still kept the old data, so anyone could use the search API to read the supposedly private code.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.