GHSA-9C5W-9Q3F-3HV7

Vulnerability from github – Published: 2024-05-07 13:02 – Updated: 2024-05-10 21:33
VLAI?
Summary
Minder's GitHub Webhook Handler vulnerable to DoS from un-validated requests
Details

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
Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Go",
        "name": "github.com/stacklok/minder"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "0.0.48"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2024-34084"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-400"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2024-05-07T13:02:42Z",
    "nvd_published_at": "2024-05-07T15:15:09Z",
    "severity": "HIGH"
  },
  "details": "Minder\u0027s `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.\n\nOne of the first things that `HandleGithubWebhook` does is to validate the payload signature. This is done by way of the internal helper `validatePayloadSignature`:\n\nhttps://github.com/stacklok/minder/blob/ee66f6c0763212503c898cfefb65ce1450c7f5ac/internal/controlplane/handlers_githubwebhooks.go#L213-L218\n\n`validatePayloadSignature` generates a reader from the incoming request by way of the internal helper `readerFromRequest`:\n\nhttps://github.com/stacklok/minder/blob/ee66f6c0763212503c898cfefb65ce1450c7f5ac/internal/controlplane/handlers_githubwebhooks.go#L337-L342\n\nTo create a reader from the incoming request, `readerFromRequest` first reads the request body entirely into memory on line 368:\n\nhttps://github.com/stacklok/minder/blob/ee66f6c0763212503c898cfefb65ce1450c7f5ac/internal/controlplane/handlers_githubwebhooks.go#L367-L377\n\nThis 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.\n\nNote that this occurs before Minder has validated the request, and as such, the request is still untrusted.\n\nTo test this out, we can use the existing `TestHandleWebHookRepository` unit test and modify the HTTP request body to be large. \n\nTo do that, change these lines:\n\nhttps://github.com/stacklok/minder/blob/ee66f6c0763212503c898cfefb65ce1450c7f5ac/internal/controlplane/handlers_githubwebhooks_test.go#L278-L283\n\n... to these lines:\n```go\n\tpackageJson, err := json.Marshal(event)\n\trequire.NoError(t, err, \"failed to marshal package event\")\n\n        maliciousBody := strings.NewReader(strings.Repeat(\"1337\", 1000000000))\n        maliciousBodyReader := io.MultiReader(maliciousBody, maliciousBody, maliciousBody, maliciousBody, maliciousBody)\n        _ = packageJson\n\n\tclient := \u0026http.Client{}\n\treq, err := http.NewRequest(\"POST\", fmt.Sprintf(\"http://%s\", addr), maliciousBodyReader)\n\trequire.NoError(t, err, \"failed to create request\")\n```\n\nThen run the unit test again. WARNING, SAVE ALL WORK BEFORE DOING THIS.\n\nOn my local machine, this causes the machine to freeze, and Go finally performs a sigkill: \n\n```\nsignal: killed\nFAIL      github.com/stacklok/minder/internal/controlplane          30.759s\nFAIL\n```",
  "id": "GHSA-9c5w-9q3f-3hv7",
  "modified": "2024-05-10T21:33:54Z",
  "published": "2024-05-07T13:02:42Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/stacklok/minder/security/advisories/GHSA-9c5w-9q3f-3hv7"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-34084"
    },
    {
      "type": "WEB",
      "url": "https://github.com/stacklok/minder/commit/3e5a527d2f1b535159206161d1d519602c75bd0d"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/stacklok/minder"
    },
    {
      "type": "WEB",
      "url": "https://github.com/stacklok/minder/blob/ee66f6c0763212503c898cfefb65ce1450c7f5ac/internal/controlplane/handlers_githubwebhooks.go#L213-L218"
    },
    {
      "type": "WEB",
      "url": "https://github.com/stacklok/minder/blob/ee66f6c0763212503c898cfefb65ce1450c7f5ac/internal/controlplane/handlers_githubwebhooks.go#L337-L342"
    },
    {
      "type": "WEB",
      "url": "https://github.com/stacklok/minder/blob/ee66f6c0763212503c898cfefb65ce1450c7f5ac/internal/controlplane/handlers_githubwebhooks.go#L367-L377"
    },
    {
      "type": "WEB",
      "url": "https://github.com/stacklok/minder/blob/ee66f6c0763212503c898cfefb65ce1450c7f5ac/internal/controlplane/handlers_githubwebhooks_test.go#L278-L283"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "Minder\u0027s GitHub Webhook Handler vulnerable to DoS from un-validated requests"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.


Loading…

Detection rules are retrieved from Rulezet.

Loading…

Loading…