Unauthorized read for conan repository
HackerOne report #901473 by fushbey
on 2020-06-18, assigned to @jeremymatos:
Summary
Hi, I want to report an unauthorized read related to conan packages, I was not quite familiar with Conan so I had doubts but after several trying, I am confident the bug is there, please confirm to me if I am right.
The bug is, a user that is Guest in a private group, can list Conan packages available in the registry despite not having enough access level, indeed the web restricts access:
- When accessing the Web page for the group > Packages & Registries . Surprisingly this menu item is shown, however on clicking on it the page shows an error message:
Something went wrong while fetching the packages list.
, Inspecting the network calls we see indeed we got a 403 response. to/api/v4/groups/6/packages?page=1&per_page=20&sort=desc&order_by=created_at&package_name=
. I come back to this API call later.
-When accessing the Web page for our project The menu item "Packages & repositories" is not even shown, accessing it directly with the URL returns a 404.
However, using conan search
does return results.
Steps to reproduce
I am gonna assume you installed conan successfully (which by the way did not install very easily on my Gitlab EE container)
1 - userA creates a private group: cpp-group
1 - userA creates a private project in that group: cpp-hello
1 - userA invites userB as guest
1 - userA: Create a Conan package as explained here
* conan new Hello/1.0 -t
* conan create . cpp-group+cpp-hello/beta
2 - userA: Add our Conan registry to remote:
conan remote add gitlab https://gitlab.example.com/api/v4/packages/conan
3 - Upload the package with the owner of the private group
CONAN_LOGIN_USERNAME=userA CONAN_PASSWORD=<userA PAT> conan upload Hello/0.1@cpp-group+cpp-hello/beta --all
4 - Search for Hello package using userA
CONAN_LOGIN_USERNAME=userA CONAN_PASSWORD=<userA PAT> conan search Hello* -r gitlab
Existing package recipes:
Hello/1.0@cpp-group+cpp-hello/beta
5 - Delete userA from cache, make sure it worked:
conan user && conan user --clean && conan user
6 - search for packages using userB
CONAN_LOGIN_USERNAME=userB CONAN_PASSWORD=<userB PAT> conan search Hello* -r gitlab
Existing package recipes:
Hello/1.0@cpp-group+cpp-hello/beta
7 - Compare that with the API call:
curl -s -H 'Authorization: Bearer <userB'sPAT>' 'http://gitlab.example.com/api/v4/groups/<PROJECT_ID>/packages?page=1&per_page=20&sort=desc&order_by=created_at&package_name=' | jq
{
"message": "403 Forbidden"
}
To prove myself there is a bug and not some caching problem I tested outside the container with userB and still worked.
Impact
The user can list recipes from a private Conan registry although the Web does not show them.
What is the current bug behavior?
Allowing unauthorized users to know the packages used in a repository with a private Conan registry.
What is the expected correct behavior?
Same as the Web UI (and API), return a forbidden response instead of showing the package name.
Impact
Read above.