Disclosure of private repository names
The GitLab LFS endpoint returned a 500 error when a repository did not exist, but a 404 when it did, allowing an attacker to determine if a private repository name exists. This could be used to enumerate private repository names, which might contain sensitive information.
GitLab
Originally disclosed on GitLab
- Fixed in 4 months
- Disclosed after 4 months
HackerOne report #636952 by mclaren650sspider on 2019-07-06, assigned to estrike:
Summary
This bug exists due to this line https://gitlab.com/gitlab-org/gitlab-ce/blob/108c3cf16bed5733ffae086fb62c226961356560/app/controllers/concerns/lfs_request.rb#L95
When an user submits request to upload file to LFS, it is first checked that LFS is enabled on the given repository. However, if the repository does not exist, this line causes exception, resulting 500 Internal Server Error to be shown to the client. If the repository exists, no exception is raised and this endpoint returns 404 Not Found.
Steps to reproduce
- Use any GitLab account. This account is our target, let's say that its username is
target. Create private repository with this account. Let's say that the URL of the repository ishttps://gitlab.com/target/secretrepo - Use another GitLab account, let's say that its username is
attacker. Add SSH key to this account. - Create new repository with
attackeraccount (does not matter if it is private or not), let's say that this repo is located athttps://gitlab.com/attacker/randomrepo. This is necessary to obtain the authorization token in the next step. - With previously added SSH key, execute the command
ssh [email protected] -x "git-lfs-authenticate attacker/randomrepo.git upload".
Replace attacker/randomrepo accordingly.
5. The executed command should produce JSON output. Copy the value of Authorization header.
6. Replace AUTHORIZATION_TOKEN in the script below with the token obtained in step 5. Replace target/secretrepo according to your target's username and private repository name.
Execute the script.
curl -i -X POST \
-H 'Authorization: AUTHORIZATION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"operation":"upload","transfers":["basic"],"ref":{"name":"refs/heads/master"},"objects":[{"oid":"f6eae78dc35680d85254d68750fb702e464097ab3c2e4c4daf811dd973d5ac60","size":9}]}' \
'https://gitlab.com/target/secretrepo.git/info/lfs/objects/batch'
- Observe that the script returns 404.
- Now replace the
secretrepoin the script with any other repository name. Execute the script again and observe that it produces error 500 instead of 404.
What is the current bug behavior?
The endpoint returns different error depending on whether or not the repository exists.
What is the expected correct behavior?
The error that the endpoint produces should always the same, regardless of whether repository exists or not.
Output of checks
This bug happens on GitLab.com, but can be reproduced in CE/EE as well.
Impact
This vulnerability can be used to know whether user has private repository with given name or not. Attacker can utilize this vulnerability to enumerate the list of private repositories that one user or organization has. Names of private repositories could contain sensitive information or business secrets.
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 code did not handle the case where the repository is nil, causing an exception and a 500 error instead of a consistent 404 response.
Impact
An attacker could determine whether a private repository with a given name exists, potentially enumerating private repository names that may contain sensitive information.
What the attacker needed
A GitLab account; SSH key added to account; ability to create a repository
The fix
The endpoint should return the same error regardless of whether the repository exists or not.
How it was found
- Create a private repository with a target account.
- Create another account and add an SSH key to it.
- Create a new repository with the attacker account to obtain an authorization token.
- Use the SSH key to run a command that returns a JSON with an Authorization header.
- Copy the Authorization token and use it in a script that sends a request to the target's private repository LFS endpoint.
- Observe that the script returns 404 for an existing repository and 500 for a non-existing one.
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.
GitLab lets users store large files using a system called LFS. When you ask to upload a file, the server first checks if the repository exists. If it doesn't, the server crashes with a 500 error; if it does, it returns a 404. By looking at which error you get, an attacker can tell if a private repository name exists, even though they can't access it.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.