List SSH keys API for user leaks comments for SSH Keys to anyone else the authenticated user
The GitLab API endpoint that lists a user's SSH keys returned the comment field of each key to any authenticated user, including anonymous users. An attacker could obtain usernames and hostnames embedded in those comments, which might aid further attacks.
GitLab
Originally disclosed on GitLab
- Fixed in 3 months
- Disclosed after 3 months
HackerOne report #1088753 by tnir on 2021-01-27, assigned to @vdesousa:
Report | How To Reproduce
Report
Summary
List SSH keys for user API leaks comments for SSH Keys to anyone else the authenticated user, including an anonymous user.
Steps to reproduce
- Prepare GitLab CE or EE 13.8 (or 13.x, 12.x, etc.) without restricting "public" visibility level at instance level on any VM or Kubernetes etc. GitLab.com is a one of candidate as of 2021-01-27.
- Add a (normal) user with one or more SSH Keys to the instance. Suppose their user URL is
https://gitlab.example.com/ABCand their SSH public key isssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGxHKibQ8waefwkJtNa6JkhgljEnOluSnKT/VNlhDFAw [email protected] - Confirm
https://gitlab.example.com/ABC.keysshowing all SSH public keys in a list - With another user credential and/or without any credential, execute
curl https://gitlab.example.com/api/v4/users/ABC/keysand then receive every part of SSH public keys as well as registration datetime of each key. [email protected]part of the SSH public key is just a comment, but potentially and often it can contain username and hostname that key generated. This can be a leak for another attack vector.
Impact
[email protected] part of the SSH public key is just a comment, but potentially and often it can contain username and hostname that key generated. This can be a leak for another attack vector.
Also User ABC does not expect to disclose the comment usually including username and hostname or something they like.
Examples
https://gitlab.com/api/v4/users/stanhu/keys is one of the examples.
What is the current bug behavior?
Anyone even anonymous user can get all data around SSH keys.
What is the expected correct behavior?
Only the authenticate user (and instance admin) can get these data, and anyone else cannot get data except for a list of public keys.
That is, anyone else should not get .id, .title, .created_at, .expires_at, and the comment part of .key.
Relevant logs and/or screenshots
https://gitlab.com/api/v4/users/stanhu/keys is one of the examples.
Output of checks
This security bug happens on GitLab.com.
Impact
[email protected] part of the SSH public key is just a comment, but potentially and often it can contain username and hostname that key generated. This can be a leak for another attack vector.
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 the API endpoint did not properly restrict access to the comment portion of SSH keys, returning full key data to unauthenticated users.
Impact
An attacker could obtain usernames and hostnames from SSH key comments, which might be used in further attacks; the report does not claim direct compromise.
What the attacker needed
GitLab instance with public visibility; A user with SSH keys; No authentication needed
The fix
The API should be changed so that only the authenticated user (and instance admin) can access the comment and metadata of SSH keys, while others see only the public key list.
How it was found
- Set up a GitLab instance with public visibility allowed.
- Add a user with at least one SSH key.
- View the user's public keys page to confirm the keys are listed.
- Using another account or no account, call the API endpoint for the user's keys.
- Observe that the full SSH public keys and their comments are returned.
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.
SSH keys often have a comment at the end, like an email address, that can reveal who created the key and on which machine. GitLab's API was giving out these comments to anyone who asked, even without logging in. This means personal information could be collected by anyone.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.