Ecosyste.ms: Advisories

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

Security Advisories: GSA_kwCzR0hTQS05YzV3LTlxM2YtM2h2N84AA70G

Minder's GitHub Webhook Handler vulnerable to DoS from un-validated requests

Minder's HandleGithubWebhook is susceptible to a denial of service attack from an untrusted HTTP request. The vulnerability exists before the request has been validated, and as such the request is still untrusted at the point of failure. This allows an attacker with the ability to send requests to HandleGithubWebhook to crash the Minder controlplane and deny other users from using it.

One of the first things that HandleGithubWebhook does is to validate the payload signature. This is done by way of the internal helper validatePayloadSignature:

https://github.com/stacklok/minder/blob/ee66f6c0763212503c898cfefb65ce1450c7f5ac/internal/controlplane/handlers_githubwebhooks.go#L213-L218

validatePayloadSignature generates a reader from the incoming request by way of the internal helper readerFromRequest:

https://github.com/stacklok/minder/blob/ee66f6c0763212503c898cfefb65ce1450c7f5ac/internal/controlplane/handlers_githubwebhooks.go#L337-L342

To create a reader from the incoming request, readerFromRequest first reads the request body entirely into memory on line 368:

https://github.com/stacklok/minder/blob/ee66f6c0763212503c898cfefb65ce1450c7f5ac/internal/controlplane/handlers_githubwebhooks.go#L367-L377

This is a vulnerability, since an HTTP request with a large body can exhaust the memory of the machine running Minder and cause the Go runtime to crash Minder.

Note that this occurs before Minder has validated the request, and as such, the request is still untrusted.

To test this out, we can use the existing TestHandleWebHookRepository unit test and modify the HTTP request body to be large.

To do that, change these lines:

https://github.com/stacklok/minder/blob/ee66f6c0763212503c898cfefb65ce1450c7f5ac/internal/controlplane/handlers_githubwebhooks_test.go#L278-L283

... to these lines:

	packageJson, err := json.Marshal(event)
	require.NoError(t, err, "failed to marshal package event")

        maliciousBody := strings.NewReader(strings.Repeat("1337", 1000000000))
        maliciousBodyReader := io.MultiReader(maliciousBody, maliciousBody, maliciousBody, maliciousBody, maliciousBody)
        _ = packageJson

	client := &http.Client{}
	req, err := http.NewRequest("POST", fmt.Sprintf("http://%s", addr), maliciousBodyReader)
	require.NoError(t, err, "failed to create request")

Then run the unit test again. WARNING, SAVE ALL WORK BEFORE DOING THIS.

On my local machine, this causes the machine to freeze, and Go finally performs a sigkill:

signal: killed
FAIL      github.com/stacklok/minder/internal/controlplane          30.759s
FAIL
Permalink: https://github.com/advisories/GHSA-9c5w-9q3f-3hv7
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS05YzV3LTlxM2YtM2h2N84AA70G
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: 12 days ago
Updated: 9 days ago


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

Identifiers: GHSA-9c5w-9q3f-3hv7, CVE-2024-34084
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.48
Fixed in: 0.0.48
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, 0.0.33, 0.0.34
All unaffected versions: