Authenticated users can find other users by their private email
GitLab
Originally disclosed on GitLab
- Fixed in 5 months
- Disclosed after 5 months
HackerOne report #1794713 by shells3c on 2022-12-06, assigned to @rshambhuni:
Report | How To Reproduce
Report
Summary
Since GitLab 14.7.1, 14.6.4, and 14.5.4, you can no longer find users by their non-public email, it's the fix for CVE-2022-0371. This is also documented in the official documentation. However, I found that I could still do it just by using a commit trailer, this happens because lib/banzai/filter/commit_trailers_filter.rb uses User.find_by_any_email to find user handle from an email address, and User.find_by_any_email doesn't respect the email policy at all:
def trailer_filter(text)
text.lines.map! do |line|
trailer, rest = line.split(':', 2)
next line unless trailer.downcase.end_with?('-by') && rest.present?
chunks = rest.split
author_email = chunks.pop.delete_prefix('<').delete_suffix('>')
next line unless Devise.email_regexp.match(author_email)
author_name = chunks.join(' ').strip
trailer = "#{trailer.strip}:"
"#{trailer} #{link_to_user_or_email(author_name, author_email, trailer)}\n"
end.join
end
def link_to_user_or_email(name, email, trailer)
link_to_user User.find_by_any_email(email),
name: name,
email: email,
trailer: trailer
end
Something like below:
commit cd330155a136985ada2c350c854a835afed1fb11 (HEAD -> h1test, origin/h1test)
Author: me <[email protected]>
Date: Tue Dec 6 14:36:00 2022 +0700
Commit message
Co-authored-by: foo <[email protected]>
will be converted to:
<a href="https://gitlab.com/USERNAME" title="[email protected]">
{{media:0}}
</a>
<a href="https://gitlab.com/USERNAME" title="[email protected]">foo</a>
<<a href="mailto:[email protected]" title="[email protected]">[email protected]</a> >
Steps to reproduce
I will use my own email address in this test: [email protected]
- Confirm that the email isn't public and can't be searched via the API by visiting
https://gitlab.com/api/v4/[email protected]
Response:
[]
- Create a repository, clone it and do the following:
$ echo test > a.txt
$ git add -A
$ git commit -m '.
>
> Co-authored-by: a <[email protected]>'
$ git checkout -b h1test
$ git push origin h1test
...
- Visit the repository, view Commits and you will find the commit
- Expand the commit and click on the avatar, you will be redirected to my Gitlab account
Output of checks
This bug happens on GitLab.com
Impact
Similar to CVE-2022-0371, users can look up accounts with private email addresses
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.
What is known
A high-severity info disclosure bug in gitlab.com. GitLab made it public on 2 May 2023. Fixed in version 15.11.
About Info disclosure
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.